]> source.dussan.org Git - sonarqube.git/commitdiff
compile_protobuf.sh does not need local installation of protoc
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 1 Aug 2015 12:20:10 +0000 (14:20 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 1 Aug 2015 12:20:32 +0000 (14:20 +0200)
compile_protobuf.sh

index 38429335487efb07098d2f52347dcb6306a85db5..e4bd4d963264ca824257de1d25248655c1f7d85f 100755 (executable)
@@ -1,7 +1,12 @@
 #!/bin/bash
 
 # Compiles all the Protocol Buffers files (*.proto) to Java source code.
-# IMPORTANT - protobuf 2.6.1 must be installed. Other versions are not supported.
+# Local installation of protobuf compiler is NOT needed.
+
+# Available versions listed at http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.os72%22%20AND%20a%3A%22protoc-jar%22
+PROTOBUF_VERSION="2.6.1.4"
+
+mvn org.apache.maven.plugins:maven-dependency-plugin::copy -Dartifact=com.github.os72:protoc-jar:$PROTOBUF_VERSION -DoutputDirectory=target
 
 # Usage: compile_protobuf <module> <type: main or test>
 function compile_protobuf {
@@ -13,7 +18,7 @@ function compile_protobuf {
     echo "Compiling [$INPUT] to [$OUTPUT]..."
     rm -rf $OUTPUT
     mkdir -p $OUTPUT
-    protoc --proto_path=$INPUT --java_out=$OUTPUT $INPUT/*.proto
+    java -jar target/protoc-jar-$PROTOBUF_VERSION.jar --proto_path=$INPUT --java_out=$OUTPUT $INPUT/*.proto
   fi
 }