]> source.dussan.org Git - sonarqube.git/commitdiff
Replace protobuf compilation from antrun to maven plugin
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 7 Sep 2016 08:32:44 +0000 (10:32 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 12 Sep 2016 12:10:30 +0000 (14:10 +0200)
pom.xml

diff --git a/pom.xml b/pom.xml
index 52e2f87a2d1244d2b34831b00eb940b0e5cb8bcb..4c90de4bb506950c126c27eb67b3ae15a3cdbd20 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -71,7 +71,6 @@
     <jackson.version>2.6.6</jackson.version>
 
     <protobuf.version>3.0.0-beta-2</protobuf.version>
-    <protobuf.compiler>${settings.localRepository}/com/google/protobuf/protoc/${protobuf.version}/protoc-${protobuf.version}-${os.detected.classifier}.exe</protobuf.compiler>
 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <maven.min.version>3.2</maven.min.version>
             <checkTestClasspath>false</checkTestClasspath>
           </configuration>
         </plugin>
+        <plugin>
+          <groupId>org.xolstice.maven.plugins</groupId>
+          <artifactId>protobuf-maven-plugin</artifactId>
+          <version>0.5.0</version>
+        </plugin>
       </plugins>
     </pluginManagement>
 
       </properties>
     </profile>
     <profile>
-      <id>release</id>      
+      <id>release</id>
       <build>
         <plugins>
           <plugin>
       <build>
         <plugins>
           <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-antrun-plugin</artifactId>
+            <groupId>org.xolstice.maven.plugins</groupId>
+            <artifactId>protobuf-maven-plugin</artifactId>
             <executions>
               <execution>
-                <id>compile-protobuf-sources</id>
-                <phase>generate-sources</phase>
+                <id>generate-protobuf-java-sources</id>
                 <goals>
-                  <goal>run</goal>
+                  <goal>compile</goal>
                 </goals>
                 <configuration>
-                  <target>
-                    <fileset id="fileset" dir="${project.basedir}/src/main/protobuf">
-                      <include name="*.proto" />
-                    </fileset>
-                    <pathconvert refid="fileset" property="protos" pathsep=" " />
-                    <mkdir dir="${project.build.directory}/generated-sources/protobuf" />
-                    <chmod file="${protobuf.compiler}" perm="u+x" />
-                    <exec failonerror="true" executable="${protobuf.compiler}">
-                      <arg value="--proto_path=${project.basedir}/src/main/protobuf" />
-                      <arg value="--java_out=${project.build.directory}/generated-sources/protobuf" />
-                      <arg line="${protos}" />
-                    </exec>
-                  </target>
+                  <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
+                  <protoSourceRoot>${project.basedir}/src/main/protobuf</protoSourceRoot>
+                  <outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory>
                 </configuration>
               </execution>
             </executions>
                 <groupId>com.google.protobuf</groupId>
                 <artifactId>protoc</artifactId>
                 <version>${protobuf.version}</version>
-                <classifier>${os.detected.classifier}</classifier>
                 <type>exe</type>
+                <classifier>${os.detected.classifier}</classifier>
               </dependency>
             </dependencies>
           </plugin>
       <build>
         <plugins>
           <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-antrun-plugin</artifactId>
+            <groupId>org.xolstice.maven.plugins</groupId>
+            <artifactId>protobuf-maven-plugin</artifactId>
             <executions>
               <execution>
-                <id>compile-protobuf-tests</id>
-                <phase>generate-sources</phase>
+                <id>generate-protobuf-java-tests</id>
                 <goals>
-                  <goal>run</goal>
+                  <goal>test-compile</goal>
                 </goals>
                 <configuration>
-                  <target>
-                    <fileset id="fileset" dir="${project.basedir}/src/test/protobuf">
-                      <include name="*.proto" />
-                    </fileset>
-                    <pathconvert refid="fileset" property="protos" pathsep=" " />
-                    <mkdir dir="${project.build.directory}/generated-test-sources/protobuf" />
-                    <chmod file="${protobuf.compiler}" perm="u+x" />
-                    <exec failonerror="true" executable="${protobuf.compiler}">
-                      <arg value="--proto_path=${project.basedir}/src/test/protobuf" />
-                      <arg value="--java_out=${project.build.directory}/generated-test-sources/protobuf" />
-                      <arg line="${protos}" />
-                    </exec>
-                  </target>
+                  <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
+                  <protoTestSourceRoot>${project.basedir}/src/test/protobuf</protoTestSourceRoot>
+                  <outputDirectory>${project.build.directory}/generated-test-sources/protobuf</outputDirectory>
                 </configuration>
               </execution>
             </executions>
         <module>it</module>
         <module>tests</module>
       </modules>
-    </profile>    
+    </profile>
   </profiles>
 
 </project>