Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B011EEE77 for ; Fri, 18 Jan 2013 22:18:37 +0000 (UTC) Received: (qmail 54760 invoked by uid 500); 18 Jan 2013 22:18:37 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 54686 invoked by uid 500); 18 Jan 2013 22:18:37 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 54678 invoked by uid 99); 18 Jan 2013 22:18:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jan 2013 22:18:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jan 2013 22:18:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5632523888D2; Fri, 18 Jan 2013 22:18:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1435372 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: ./ dev-support/ src/main/java/org/apache/hadoop/ src/main/java/org/apache/hadoop/util/ src/main/resources/ Date: Fri, 18 Jan 2013 22:18:13 -0000 To: common-commits@hadoop.apache.org From: suresh@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130118221813.5632523888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: suresh Date: Fri Jan 18 22:18:12 2013 New Revision: 1435372 URL: http://svn.apache.org/viewvc?rev=1435372&view=rev 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/trunk/hadoop-common-project/hadoop-common/src/main/resources/common-version-info.properties Removed: hadoop/common/trunk/hadoop-common-project/hadoop-common/dev-support/saveVersion.sh hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/HadoopVersionAnnotation.java Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1435372&r1=1435371&r2=1435372&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Fri Jan 18 22:18:12 2013 @@ -447,6 +447,9 @@ Release 2.0.3-alpha - Unreleased HADOOP-9216. CompressionCodecFactory#getCodecClasses should trim the result of parsing by Configuration. (Tsuyoshi Ozawa via todd) + HADOOP-8924. Add maven plugin alternative to shell script to save + package-info.java. (Alejandro Abdelnur, Chris Nauroth via suresh) + OPTIMIZATIONS HADOOP-8866. SampleQuantiles#query is O(N^2) instead of O(N). (Andrew Wang Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml?rev=1435372&r1=1435371&r2=1435372&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml Fri Jan 18 22:18:12 2013 @@ -244,8 +244,52 @@ + + + + ${basedir}/src/main/resources + + common-version-info.properties + + false + + + ${basedir}/src/main/resources + + common-version-info.properties + + true + + + org.apache.hadoop + hadoop-maven-plugins + + + version-info + + version-info + + + + ${basedir}/src/main + + java/**/*.java + proto/**/*.proto + + + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -289,22 +333,6 @@ - save-version - generate-sources - - run - - - - - - - - - - - generate-test-sources generate-test-sources Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java?rev=1435372&r1=1435371&r2=1435372&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java Fri Jan 18 22:18:12 2013 @@ -20,41 +20,78 @@ package org.apache.hadoop.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.HadoopVersionAnnotation; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + /** - * This class finds the package info for Hadoop and the HadoopVersionAnnotation - * information. + * This class returns build information about Hadoop components. */ @InterfaceAudience.Private @InterfaceStability.Unstable public class VersionInfo { private static final Log LOG = LogFactory.getLog(VersionInfo.class); - private static Package myPackage; - private static HadoopVersionAnnotation version; - - static { - myPackage = HadoopVersionAnnotation.class.getPackage(); - version = myPackage.getAnnotation(HadoopVersionAnnotation.class); + private Properties info; + + protected VersionInfo(String component) { + info = new Properties(); + String versionInfoFile = component + "-version-info.properties"; + try { + InputStream is = Thread.currentThread().getContextClassLoader() + .getResourceAsStream(versionInfoFile); + info.load(is); + } catch (IOException ex) { + LogFactory.getLog(getClass()).warn("Could not read '" + + versionInfoFile + "', " + ex.toString(), ex); + } } - /** - * Get the meta-data for the Hadoop package. - * @return - */ - static Package getPackage() { - return myPackage; + protected String _getVersion() { + return info.getProperty("version", "Unknown"); } - + + protected String _getRevision() { + return info.getProperty("revision", "Unknown"); + } + + protected String _getBranch() { + return info.getProperty("branch", "Unknown"); + } + + protected String _getDate() { + return info.getProperty("date", "Unknown"); + } + + protected String _getUser() { + return info.getProperty("user", "Unknown"); + } + + protected String _getUrl() { + return info.getProperty("url", "Unknown"); + } + + protected String _getSrcChecksum() { + return info.getProperty("srcChecksum", "Unknown"); + } + + protected String _getBuildVersion(){ + return getVersion() + + " from " + _getRevision() + + " by " + _getUser() + + " source checksum " + _getSrcChecksum(); + } + + private static VersionInfo COMMON_VERSION_INFO = new VersionInfo("common"); /** * Get the Hadoop version. * @return the Hadoop version string, eg. "0.6.3-dev" */ public static String getVersion() { - return version != null ? version.version() : "Unknown"; + return COMMON_VERSION_INFO._getVersion(); } /** @@ -62,7 +99,7 @@ public class VersionInfo { * @return the revision number, eg. "451451" */ public static String getRevision() { - return version != null ? version.revision() : "Unknown"; + return COMMON_VERSION_INFO._getRevision(); } /** @@ -70,7 +107,7 @@ public class VersionInfo { * @return The branch name, e.g. "trunk" or "branches/branch-0.20" */ public static String getBranch() { - return version != null ? version.branch() : "Unknown"; + return COMMON_VERSION_INFO._getBranch(); } /** @@ -78,7 +115,7 @@ public class VersionInfo { * @return the compilation date in unix date format */ public static String getDate() { - return version != null ? version.date() : "Unknown"; + return COMMON_VERSION_INFO._getDate(); } /** @@ -86,14 +123,14 @@ public class VersionInfo { * @return the username of the user */ public static String getUser() { - return version != null ? version.user() : "Unknown"; + return COMMON_VERSION_INFO._getUser(); } /** * Get the subversion URL for the root Hadoop directory. */ public static String getUrl() { - return version != null ? version.url() : "Unknown"; + return COMMON_VERSION_INFO._getUrl(); } /** @@ -101,7 +138,7 @@ public class VersionInfo { * built. **/ public static String getSrcChecksum() { - return version != null ? version.srcChecksum() : "Unknown"; + return COMMON_VERSION_INFO._getSrcChecksum(); } /** @@ -109,14 +146,11 @@ public class VersionInfo { * revision, user and date. */ public static String getBuildVersion(){ - return VersionInfo.getVersion() + - " from " + VersionInfo.getRevision() + - " by " + VersionInfo.getUser() + - " source checksum " + VersionInfo.getSrcChecksum(); + return COMMON_VERSION_INFO._getBuildVersion(); } public static void main(String[] args) { - LOG.debug("version: "+ version); + LOG.debug("version: "+ getVersion()); System.out.println("Hadoop " + getVersion()); System.out.println("Subversion " + getUrl() + " -r " + getRevision()); System.out.println("Compiled by " + getUser() + " on " + getDate()); Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/resources/common-version-info.properties URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/resources/common-version-info.properties?rev=1435372&view=auto ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/resources/common-version-info.properties (added) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/resources/common-version-info.properties Fri Jan 18 22:18:12 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}