You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by tu...@apache.org on 2013/08/15 00:29:46 UTC

svn commit: r1514074 - in /hadoop/common/branches/branch-2: ./ hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/ hadoop-project/

Author: tucu
Date: Wed Aug 14 22:29:46 2013
New Revision: 1514074

URL: http://svn.apache.org/r1514074
Log:
HADOOP-9872. Improve protoc version handling and detection. (tucu)

Modified:
    hadoop/common/branches/branch-2/BUILDING.txt
    hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
    hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
    hadoop/common/branches/branch-2/hadoop-project/pom.xml

Modified: hadoop/common/branches/branch-2/BUILDING.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/BUILDING.txt?rev=1514074&r1=1514073&r2=1514074&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/BUILDING.txt (original)
+++ hadoop/common/branches/branch-2/BUILDING.txt Wed Aug 14 22:29:46 2013
@@ -7,7 +7,7 @@ Requirements:
 * JDK 1.6
 * Maven 3.0
 * Findbugs 1.3.9 (if running findbugs)
-* ProtocolBuffer 2.4.1+ (for MapReduce and HDFS)
+* ProtocolBuffer 2.5.0
 * CMake 2.6 or newer (if compiling native code)
 * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
 
@@ -100,6 +100,16 @@ time out after a while, using the Maven 
 to update SNAPSHOTs from external repos.
 
 ----------------------------------------------------------------------------------
+Protocol Buffer compiler
+
+The version of Protocol Buffer compiler, protoc, must match the version of the
+protobuf JAR.
+
+If you have multiple versions of protoc in your system, you can set in your 
+build shell the HADOOP_PROTOC_PATH environment variable to point to the one you 
+want to use for the Hadoop build. If you don't define this environment variable,
+protoc is looked up in the PATH.
+----------------------------------------------------------------------------------
 Importing projects to eclipse
 
 When you import the project to eclipse, install hadoop-maven-plugins at first.

Modified: hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java?rev=1514074&r1=1514073&r2=1514074&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java (original)
+++ hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/protoc/ProtocMojo.java Wed Aug 14 22:29:46 2013
@@ -45,7 +45,7 @@ public class ProtocMojo extends Abstract
   @Parameter(required=true)
   private FileSet source;
 
-  @Parameter(defaultValue="protoc")
+  @Parameter
   private String protocCommand;
 
   @Parameter(required=true)
@@ -53,21 +53,22 @@ public class ProtocMojo extends Abstract
 
   public void execute() throws MojoExecutionException {
     try {
+      if (protocCommand == null || protocCommand.trim().isEmpty()) {
+        protocCommand = "protoc";
+      }
       List<String> command = new ArrayList<String>();
       command.add(protocCommand);
       command.add("--version");
       Exec exec = new Exec(this);
       List<String> out = new ArrayList<String>();
-      if (exec.run(command, out) != 0) {
-        getLog().error("protoc, could not get version");
-        for (String s : out) {
-          getLog().error(s);
-        }
+      if (exec.run(command, out) == 127) {
+        getLog().error("protoc, not found at: " + protocCommand);
         throw new MojoExecutionException("protoc failure");        
       } else {
-        if (out.size() == 0) {
+        if (out.isEmpty()) {
+          getLog().error("stdout: " + out);
           throw new MojoExecutionException(
-              "'protoc -version' did not return a version");
+              "'protoc --version' did not return a version");
         } else {
           if (!out.get(0).endsWith(protocVersion)) {
             throw new MojoExecutionException(

Modified: hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java?rev=1514074&r1=1514073&r2=1514074&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java (original)
+++ hadoop/common/branches/branch-2/hadoop-maven-plugins/src/main/java/org/apache/hadoop/maven/plugin/util/Exec.java Wed Aug 14 22:29:46 2013
@@ -63,11 +63,10 @@ public class Exec {
         for (String s : stdErr.getOutput()) {
           mojo.getLog().debug(s);
         }
-      } else {
-        stdOut.join();
-        stdErr.join();
-        output.addAll(stdOut.getOutput());
       }
+      stdOut.join();
+      stdErr.join();
+      output.addAll(stdOut.getOutput());
     } catch (Exception ex) {
       mojo.getLog().warn(command + " failed: " + ex.toString());
     }

Modified: hadoop/common/branches/branch-2/hadoop-project/pom.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-project/pom.xml?rev=1514074&r1=1514073&r2=1514074&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-project/pom.xml (original)
+++ hadoop/common/branches/branch-2/hadoop-project/pom.xml Wed Aug 14 22:29:46 2013
@@ -62,6 +62,7 @@
     <!-- ProtocolBuffer version, used to verify the protoc version and -->
     <!-- define the protobuf JAR version                               -->
     <protobuf.version>2.5.0</protobuf.version>
+    <protoc.path>${env.HADOOP_PROTOC_PATH}</protoc.path>
   </properties>
 
   <dependencyManagement>