Author: tucu Date: Thu Feb 14 01:30:50 2013 New Revision: 1446018 URL: http://svn.apache.org/r1446018 Log: HADOOP-8924. Add maven plugin alternative to shell script to save package-info.java. Contributed by Alejandro Abdelnur and Chris Nauroth.
Added: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-version-info.properties Removed: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/scripts/saveVersion.sh Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml?rev=1446018&r1=1446017&r2=1446018&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml (original) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml Thu Feb 14 01:30:50 2013 @@ -45,6 +45,29 @@ </dependencies> <build> + <!-- + Include all files in src/main/resources. By default, do not apply property + substitution (filtering=false), but do apply property substitution to + yarn-version-info.properties (filtering=true). This will substitute the + version information correctly, but prevent Maven from altering other files + like yarn-default.xml. + --> + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <excludes> + <exclude>yarn-version-info.properties</exclude> + </excludes> + <filtering>false</filtering> + </resource> + <resource> + <directory>${basedir}/src/main/resources</directory> + <includes> + <include>yarn-version-info.properties</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> <plugins> <plugin> <groupId>org.apache.rat</groupId> @@ -65,6 +88,27 @@ </configuration> </plugin> <plugin> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-maven-plugins</artifactId> + <executions> + <execution> + <id>version-info</id> + <goals> + <goal>version-info</goal> + </goals> + <configuration> + <source> + <directory>${basedir}/src/main</directory> + <includes> + <include>java/**/*.java</include> + <include>proto/**/*.proto</include> + </includes> + </source> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> @@ -127,20 +171,6 @@ <goal>exec</goal> </goals> </execution> - <execution> - <id>generate-version</id> - <phase>generate-sources</phase> - <configuration> - <executable>scripts/saveVersion.sh</executable> - <arguments> - <argument>${project.version}</argument> - <argument>${project.build.directory}</argument> - </arguments> - </configuration> - <goals> - <goal>exec</goal> - </goals> - </execution> </executions> </plugin> Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java?rev=1446018&r1=1446017&r2=1446018&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java (original) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/YarnVersionInfo.java Thu Feb 14 01:30:50 2013 @@ -20,7 +20,7 @@ package org.apache.hadoop.yarn.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.yarn.YarnVersionAnnotation; +import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -30,31 +30,20 @@ import org.apache.hadoop.classification. */ @InterfaceAudience.Private @InterfaceStability.Unstable -public class YarnVersionInfo { +public class YarnVersionInfo extends VersionInfo { private static final Log LOG = LogFactory.getLog(YarnVersionInfo.class); - private static Package myPackage; - private static YarnVersionAnnotation version; - - static { - myPackage = YarnVersionAnnotation.class.getPackage(); - version = myPackage.getAnnotation(YarnVersionAnnotation.class); - } + private static YarnVersionInfo YARN_VERSION_INFO = new YarnVersionInfo(); - /** - * Get the meta-data for the Yarn package. - * @return - */ - static Package getPackage() { - return myPackage; + protected YarnVersionInfo() { + super("yarn"); } - /** * Get the Yarn version. * @return the Yarn version string, eg. "0.6.3-dev" */ public static String getVersion() { - return version != null ? version.version() : "Unknown"; + return YARN_VERSION_INFO._getVersion(); } /** @@ -62,7 +51,7 @@ public class YarnVersionInfo { * @return the revision number, eg. "451451" */ public static String getRevision() { - return version != null ? version.revision() : "Unknown"; + return YARN_VERSION_INFO._getRevision(); } /** @@ -70,7 +59,7 @@ public class YarnVersionInfo { * @return The branch name, e.g. "trunk" or "branches/branch-0.20" */ public static String getBranch() { - return version != null ? version.branch() : "Unknown"; + return YARN_VERSION_INFO._getBranch(); } /** @@ -78,7 +67,7 @@ public class YarnVersionInfo { * @return the compilation date in unix date format */ public static String getDate() { - return version != null ? version.date() : "Unknown"; + return YARN_VERSION_INFO._getDate(); } /** @@ -86,14 +75,14 @@ public class YarnVersionInfo { * @return the username of the user */ public static String getUser() { - return version != null ? version.user() : "Unknown"; + return YARN_VERSION_INFO._getUser(); } /** * Get the subversion URL for the root Yarn directory. */ public static String getUrl() { - return version != null ? version.url() : "Unknown"; + return YARN_VERSION_INFO._getUrl(); } /** @@ -101,7 +90,7 @@ public class YarnVersionInfo { * built. **/ public static String getSrcChecksum() { - return version != null ? version.srcChecksum() : "Unknown"; + return YARN_VERSION_INFO._getSrcChecksum(); } /** @@ -109,14 +98,11 @@ public class YarnVersionInfo { * revision, user and date. */ public static String getBuildVersion(){ - return YarnVersionInfo.getVersion() + - " from " + YarnVersionInfo.getRevision() + - " by " + YarnVersionInfo.getUser() + - " source checksum " + YarnVersionInfo.getSrcChecksum(); + return YARN_VERSION_INFO._getBuildVersion(); } public static void main(String[] args) { - LOG.debug("version: "+ version); + LOG.debug("version: "+ getVersion()); System.out.println("Yarn " + getVersion()); System.out.println("Subversion " + getUrl() + " -r " + getRevision()); System.out.println("Compiled by " + getUser() + " on " + getDate()); Added: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-version-info.properties URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-version-info.properties?rev=1446018&view=auto ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-version-info.properties (added) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-version-info.properties Thu Feb 14 01:30:50 2013 @@ -0,0 +1,25 @@ +# +# 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. +# + +version=${pom.version} +revision=${version-info.scm.commit} +branch=${version-info.scm.branch} +user=${user.name} +date=${version-info.build.time} +url=${version-info.scm.uri} +srcChecksum=${version-info.source.md5}