From 2fcc691b1680b15bf500840a67d1dd28d5e0a438 Mon Sep 17 00:00:00 2001 From: Apekshit Sharma Date: Thu, 1 Sep 2016 18:18:48 -0700 Subject: [PATCH] HBASE-16538 Changes the way version information is stored during build. Instead of writing package-info.java with VersionAnnotation, saveVersion.sh now writes Version.java with static members. Change-Id: I009f440fa049f409e10cb3f1c3afb483bc2aa876 --- .../hadoop/hbase/VersionAnnotation.java | 69 ------------------- .../apache/hadoop/hbase/util/VersionInfo.java | 32 +++------ hbase-common/src/saveVersion.sh | 14 ++-- 3 files changed, 18 insertions(+), 97 deletions(-) delete mode 100644 hbase-common/src/main/java/org/apache/hadoop/hbase/VersionAnnotation.java diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/VersionAnnotation.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/VersionAnnotation.java deleted file mode 100644 index f93d7f214a7..00000000000 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/VersionAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.hbase; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.apache.hadoop.hbase.classification.InterfaceAudience; - -/** - * A package attribute that captures the version of hbase that was compiled. - * Copied down from hadoop. All is same except name of interface. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PACKAGE) -@InterfaceAudience.Private -public @interface VersionAnnotation { - - /** - * Get the Hadoop version - * @return the version string "0.6.3-dev" - */ - String version(); - - /** - * Get the username that compiled Hadoop. - */ - String user(); - - /** - * Get the date when Hadoop was compiled. - * @return the date in unix 'date' format - */ - String date(); - - /** - * Get the url for the subversion repository. - */ - String url(); - - /** - * Get the subversion revision. - * @return the revision number as a string (eg. "451451") - */ - String revision(); - - /** - * Get a checksum of the source files from which HBase was compiled. - * @return a string that uniquely identifies the source - **/ - String srcChecksum(); -} diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java index d0462dd1330..908689c1c63 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java @@ -23,40 +23,24 @@ import java.io.PrintWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.VersionAnnotation; +import org.apache.hadoop.hbase.Version; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; /** - * This class finds the package info for hbase and the VersionAnnotation - * information. Taken from hadoop. Only name of annotation is different. + * This class finds the Version information for HBase. */ @InterfaceAudience.Public @InterfaceStability.Evolving public class VersionInfo { private static final Log LOG = LogFactory.getLog(VersionInfo.class.getName()); - private static Package myPackage; - private static VersionAnnotation version; - - static { - myPackage = VersionAnnotation.class.getPackage(); - version = myPackage.getAnnotation(VersionAnnotation.class); - } - - /** - * Get the meta-data for the hbase package. - * @return package - */ - static Package getPackage() { - return myPackage; - } /** * Get the hbase version. * @return the hbase version string, eg. "0.6.3-dev" */ public static String getVersion() { - return version != null ? version.version() : "Unknown"; + return Version.version; } /** @@ -64,7 +48,7 @@ public class VersionInfo { * @return the revision number, eg. "451451" */ public static String getRevision() { - return version != null ? version.revision() : "Unknown"; + return Version.revision; } /** @@ -72,7 +56,7 @@ public class VersionInfo { * @return the compilation date in unix date format */ public static String getDate() { - return version != null ? version.date() : "Unknown"; + return Version.date; } /** @@ -80,7 +64,7 @@ public class VersionInfo { * @return the username of the user */ public static String getUser() { - return version != null ? version.user() : "Unknown"; + return Version.user; } /** @@ -88,7 +72,7 @@ public class VersionInfo { * @return the url */ public static String getUrl() { - return version != null ? version.url() : "Unknown"; + return Version.url; } static String[] versionReport() { @@ -105,7 +89,7 @@ public class VersionInfo { * @return a string that uniquely identifies the source **/ public static String getSrcChecksum() { - return version != null ? version.srcChecksum() : "Unknown"; + return Version.srcChecksum; } public static void writeTo(PrintWriter out) { diff --git a/hbase-common/src/saveVersion.sh b/hbase-common/src/saveVersion.sh index 890dc5a8415..4c2182943f9 100644 --- a/hbase-common/src/saveVersion.sh +++ b/hbase-common/src/saveVersion.sh @@ -55,13 +55,19 @@ fi popd mkdir -p "$outputDirectory/org/apache/hadoop/hbase" -cat >"$outputDirectory/org/apache/hadoop/hbase/package-info.java" <"$outputDirectory/org/apache/hadoop/hbase/Version.java" <