编译Java运行时库时出现Protobuf错误

王莎莎|

我正在尝试为协议缓冲区构建Java运行时库通过遵循Protocol Buffers项目(从https://github.com/google/protobuf克隆)中Java目录下的README指令,我在Windows和OS X上均出现错误

当我mvn test在protobuf / java目录中运行时发生以下错误

来自OS X的错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (generate-sources) on project protobuf-java: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /Users/wangsa/Work/ProtoBuffer/protobuf/java/core/generate-sources-build.xml:4: Execute failed: java.io.IOException: Cannot run program "/Users/wangsa/Work/ProtoBuffer/protobuf/java/core/../../src/protoc" (in directory "/Users/wangsa/Work/ProtoBuffer/protobuf/java/core"): error=2, No such file or directory

Windows错误

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.google.protobuf:protobuf-java:bundle:2.6.1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 57, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 64, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.felix:maven-bundle-plugin is missing. @ line 143, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Protocol Buffer Java API 2.6.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (generate-sources) @ protobuf-java ---
[INFO] Executing tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.030 s
[INFO] Finished at: 2016-06-07T10:03:48+12:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (generate-sources) on project protobuf-java: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "..\src\protoc": CreateProcess error=2, The system cannot find the file specified -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

更多细节

  • Maven已正确安装(版本3.3.9)
  • 正确安装了Java JDK(对于OS X,版本1.7;对于Windows,版本1.8)
  • Protobuf已正确安装。我可以使用protoc命令将.proto文件转换为.java文件
  • 对于已安装的二进制文件和我尝试构建的Java软件包,protobuf的版本均为2.6.1。

谁能看到可能出了什么问题?

编辑:对我来说,执行此构建过程是一个相当新的过程,我假设如果此过程成功完成,我将获得一个.jar文件,该文件可以包含在我的android程序中,以便使用从我的proto文件生成的protobuf方法来序列化数据并通过TCP发送,这是我的最终目标。

王莎莎|

最后,它进行了以下更改:

更改1:我改为使用来自https://github.com/google/protobuf/releases/tag/v2.6.1的Java源,而不是https://github.com/google/protobuf/tree/v2.6.1/爪哇

更改2:对于Windows计算机,我需要将protoc.exe复制到src位于java文件夹的父文件夹中的文件夹。以前,我将protoc.exe复制到了不起作用src的java文件夹中。

之后,我mvn test在java文件夹中运行,一切正常。我能够生成使用.jar文件mvn install,然后mvn package根据README文件。

注意:我不明白为什么protobuf / tree / v2.6.1中的代码不起作用,但是因为在github上,构建状态也显示失败(截至6月7日),所以我认为这就是原因。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Java库运行时与编译时

Java中的编译时库和运行时库有什么区别?

迭代.next()时出现Java“ ConcurrentModificationException”运行时错误

Micronaut中的DI错误在运行时而不是编译时出现?

运行Go代码时出现运行时错误

使用Trim时出现运行时错误13

替换公式时出现运行时错误1004

渲染图像时出现Flutter运行时错误

连接到SQL数据库时出现VBA运行时错误

从FormControl ListBox检索值时出现运行时错误

运行时错误与编译时错误

使用g ++编译Objective-C项目时出现运行时错误

在Java中创建非常简单的Web服务时出现运行时建模器错误

尝试连接数据库表时出现运行时错误

运行“粘贴”时,出现VBA运行时错误438

在IntelliJ IDEA 13中运行已编译的Groovy代码时出现运行时错误

3265检索表信息时出现运行时错误

设置图像javafx时出现运行时错误IllegalArgumentException

打开Word文件时出现运行时错误'1004'

加载运行时编译源时格式错误的Java包类名

尝试使用pip时出现运行时错误

保存NewWorkbook时出现运行时错误

在 VBA 中执行 SQL 时出现运行时错误

将“:”更改为“;”时出现运行时错误 VBA

生成邮件合并时出现运行时错误 424

在运行时动态加载库时出现“未解析的外部符号”错误

使用动态数组时出现运行时错误 1004

在 LWJGL 中加载纹理时出现 Java 致命运行时错误

在具有例程调用的并行区域中使用 PGI 而不是 Cray 进行编译时出现运行时错误