err = new ArrayList<>();
+ if (exec.run(command, out, err) != 0) {
+ mojo.getLog().error("protoc compiler error");
+ for (String s : out) {
+ mojo.getLog().error(s);
+ }
+ for (String s : err) {
+ mojo.getLog().error(s);
+ }
+ throw new MojoExecutionException("protoc failure");
+ }
+ // Write the new checksum file on success.
+ comparator.writeChecksums();
+ }
+ } catch (Throwable ex) {
+ throw new MojoExecutionException(ex.toString(), ex);
+ }
+ if(test) {
+ project.addTestCompileSourceRoot(output.getAbsolutePath());
+ } else {
+ project.addCompileSourceRoot(output.getAbsolutePath());
+ }
+ }
+
+}
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java
new file mode 100644
index 00000000000..c50f6cabed6
--- /dev/null
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocTestMojo.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.maven.plugin.protoc;
+
+import org.apache.maven.model.FileSet;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+
+/**
+ * Mojo to generate java test classes from .proto files using protoc.
+ * See package info for examples of use in a maven pom.
+ */
+@Mojo(name="test-protoc", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES)
+public class ProtocTestMojo extends AbstractMojo {
+
+ @Parameter(defaultValue="${project}", readonly=true)
+ private MavenProject project;
+
+ @Parameter
+ private File[] imports;
+
+ @Parameter(defaultValue=
+ "${project.build.directory}/generated-test-sources/java")
+ private File output;
+
+ @Parameter(required=true)
+ private FileSet source;
+
+ @Parameter(defaultValue="protoc")
+ private String protocCommand;
+
+ @Parameter(required=true)
+ private String protocVersion;
+
+ @Parameter(defaultValue =
+ "${project.build.directory}/hadoop-maven-plugins-protoc-checksums.json")
+ private String checksumPath;
+
+ public void execute() throws MojoExecutionException {
+ final ProtocRunner protoc = new ProtocRunner(project, imports, output,
+ source, protocCommand, protocVersion, checksumPath, this, true);
+ protoc.execute();
+ }
+}
diff --git a/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java
new file mode 100644
index 00000000000..c4c30ce7d2b
--- /dev/null
+++ b/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/package-info.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Plugins to generate Java files based on protocol buffers with the protoc
+ * command.
+ *
+ *
For generated files intended for primary build artifacts use like:
+ *
+ * <plugins>
+ * ... SNIP ...
+ * <plugin>
+ * <groupId>org.apache.hadoop</groupId>
+ * <artifactId>hadoop-maven-plugins</artifactId>
+ * <executions>
+ * ... SNIP ...
+ * <execution>
+ * <id>compile-protoc</id>
+ * <goals>
+ * <goal>protoc</goal>
+ * </goals>
+ * <configuration>
+ * <protocVersion>${protobuf.version}</protocVersion>
+ * <protocCommand>${protoc.path}</protocCommand>
+ * <imports>
+ * <param>${basedir}/src/main/proto</param>
+ * </imports>
+ * <source>
+ * <directory>${basedir}/src/main/proto</directory>
+ * <includes>
+ * <include>HAServiceProtocol.proto</include>
+ * ... SNIP ...
+ * <include>RefreshCallQueueProtocol.proto</include>
+ * <include>GenericRefreshProtocol.proto</include>
+ * </includes>
+ * </source>
+ * </configuration>
+ * </execution>
+ * ... SNIP ...
+ * </executions>
+ * ... SNIP ...
+ * </plugin>
+ * </plugins>
+ *
+ *
+ * For generated files intended only for test, use like:
+ *
+ * <plugins>
+ * ... SNIP ...
+ * <plugin>
+ * <groupId>org.apache.hadoop</groupId>
+ * <artifactId>hadoop-maven-plugins</artifactId>
+ * <executions>
+ * ... SNIP ...
+ * <execution>
+ * <id>compile-test-protoc</id>
+ * <goals>
+ * <goal>test-protoc</goal>
+ * </goals>
+ * <configuration>
+ * <protocVersion>${protobuf.version}</protocVersion>
+ * <protocCommand>${protoc.path}</protocCommand>
+ * <imports>
+ * <param>${basedir}/src/test/proto</param>
+ * </imports>
+ * <source>
+ * <directory>${basedir}/src/test/proto</directory>
+ * <includes>
+ * <include>test.proto</include>
+ * <include>test_rpc_service.proto</include>
+ * </includes>
+ * </source>
+ * </configuration>
+ * </execution>
+ * ... SNIP ...
+ * </executions>
+ * ... SNIP ...
+ * </plugin>
+ * </plugins>
+ *
+ *
+ */
+package org.apache.hadoop.maven.plugin.protoc;
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
index 52e276b4aa8..71014e4970f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
@@ -100,7 +100,6 @@
compile-protoc
- generate-sources
protoc
@@ -128,7 +127,6 @@
server/SCM_Admin_protocol.proto
-
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
index 668c50d9df5..a53ec57a358 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
@@ -154,7 +154,6 @@
compile-protoc
- generate-sources
protoc
@@ -172,7 +171,6 @@
test_amrm_token.proto
-
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
index b2d3f32d5fe..f55c48831aa 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
@@ -262,7 +262,6 @@