我正在尝试为协议缓冲区构建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
更多细节
protoc
命令将.proto文件转换为.java文件。谁能看到可能出了什么问题?
编辑:对我来说,执行此构建过程是一个相当新的过程,我假设如果此过程成功完成,我将获得一个.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] 删除。
我来说两句