Sas*_*ang 6 java protocol-buffers
我正在尝试为Protocol Buffers构建 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
Run Code Online (Sandbox Code Playgroud)
来自 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
Run Code Online (Sandbox Code Playgroud)
更多细节
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 复制到srcjava 文件夹内,但不起作用。
之后我mvn test在java文件夹中运行,一切正常。我能够使用mvn install然后mvn package基于 README 文件生成 .jar 文件。
注意:我不明白为什么 protobuf/tree/v2.6.1 中的代码不起作用,但因为在 github 上,构建状态也显示失败(截至 6 月 7 日),所以我认为这就是原因。
| 归档时间: |
|
| 查看次数: |
25805 次 |
| 最近记录: |