Closed shvachko closed 8 years ago
I'd rather commit generated files. The reason is that we need to have a specific version of protoc on every host where we are compiling our project. I think it is better just to have profile to run protoc when needed (and may run it everytime on jenkins to be sure).
Yes compiling sources will require protoc. The package
target should add them to the appropriate jars. So users will not need to compile or have protoc.
I don't see any reason to keep transient code in the repo. It is the same as committing generated jars in the repo or compiled libraries. You can, but what's the point. Besides if there are any differences in how protoc generates Java code for different providers/versions of Java or OSs, then there is no other way.
I told about developers. That become not possible to just download and compile giraffa. One need to install protobuf expected version. Just not very convent in comparison of very rare changes of .proto files. External dependency is not good. But I'm ok with that. Just pointed out that it would introduce external dependency for build process.
I spent some time on this issue but I am not sure if I am on the right track.
For now I add some lines in giraffa-core/pom.xml
in maven-antrun
's generate-sources
phase
<exec executable="protoc">
<arg value="-I=${basedir}/src/main/proto" />
<arg value="--java_out=${generated.sources}/java"/>
<arg value="${basedir}/src/main/proto/grfa.proto"/>
</exec>
The java file can be generated as target/generated-sources/java/org/apache/giraffa/GiraffaProtos.java
After removing original src/main/java/org/apache/giraffa/GiraffaProtos.java
We can use mvn clean install
to build the project.
However, there are two problems I can not solve now
GiraffaPBHelper.java
imports GiraffaProtos.java
and the later file is not ready yet.
Any suggestion? Quick update for the IDE problem I mentioned above.
It turns out to be my IDE project setting problem. The problem disappeared after I deleted the setting file and reload the project to IDE again.
I test the code with both Eclipse and Intellij could load the generated java file under target/generated-sources/java/org/apache/giraffa/
correctly.
GiraffaProtos.java
from source folder GiraffaProtos.java
will be generated undertarget/generated-sources/java/org/apache/giraffa/
in maven-antrun
's generate-sources
phasePlamen and I have a short discussion about how we deal with this issue properly. We believe we should talk about it further before commit code. Below are some concerns need to be addressed.
If we don't put GiraffaProtos.java
in repository. Developers need install protoc themselves.
No matter users generate GiraffaProtos.java
manually or by mvn command, the protoc is required.
That introduce additional dependency.
It's in target/generated-sources/java/org/apache/giraffa/
To put in src/java/org/apache/giraffa/
and to edit gitignore to ignore this file.
target/generated-sources/java/org/apache/giraffa/
so that we don't need maintain gitignore file. Otherwise, we need change gitignore when there's new generated file.A requirement for protoc compiler should be fine for developers. Other projects do that: https://wiki.apache.org/hadoop/HowToContribute#Build_Tools
We can link this guide from Giraffa wiki: https://wiki.apache.org/hadoop/ProtocolBuffers
Works for me. Both command-line and Eclipse builds worked.
You got two +1 (Cos and me). Should be able to push changes to trunk. Please follow the code sharing instructions
Currently we commit both .proto definitions and the generated Java sources. We should add a build target, which would generate Java sources from .proto under
target/generated-sources
. Then we can remove the Java files from the source tree. Note: add Apache license togrfa.proto
as a part of this.