You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2016/11/01 19:48:03 UTC

[25/50] hbase git commit: 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.

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


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f4aa4046
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f4aa4046
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f4aa4046

Branch: refs/heads/0.98
Commit: f4aa4046f2f7a7ccc3ba81ad5566b6a84ee2b436
Parents: 0ac78f4
Author: Apekshit Sharma <ap...@apache.org>
Authored: Thu Sep 1 18:18:48 2016 -0700
Committer: Apekshit Sharma <ap...@apache.org>
Committed: Fri Sep 2 16:46:39 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/VersionAnnotation.java  | 66 --------------------
 .../apache/hadoop/hbase/util/VersionInfo.java   | 34 +++-------
 hbase-common/src/saveVersion.sh                 | 14 +++--
 3 files changed, 19 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f4aa4046/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 f3137ae..0000000
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/VersionAnnotation.java
+++ /dev/null
@@ -1,66 +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.*;
-
-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();
-}

http://git-wip-us.apache.org/repos/asf/hbase/blob/f4aa4046/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java
----------------------------------------------------------------------
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 8061b4d..2b1fce7 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
@@ -22,41 +22,25 @@ import org.apache.commons.logging.LogFactory;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 
+import org.apache.commons.logging.Log;
+import org.apache.hadoop.hbase.Version;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
-import org.apache.hadoop.hbase.VersionAnnotation;
-import org.apache.commons.logging.Log;
 
 /**
- * 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) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/f4aa4046/hbase-common/src/saveVersion.sh
----------------------------------------------------------------------
diff --git a/hbase-common/src/saveVersion.sh b/hbase-common/src/saveVersion.sh
index 890dc5a..4c21829 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" <<EOF
+cat >"$outputDirectory/org/apache/hadoop/hbase/Version.java" <<EOF
 /*
  * Generated by src/saveVersion.sh
  */
-@VersionAnnotation(version="$version", revision="$revision",
-                         user="$user", date="$date", url="$url",
-                         srcChecksum="$srcChecksum")
 package org.apache.hadoop.hbase;
+
+public class Version {
+  public static final String version = "$version";
+  public static final String revision = "$revision";
+  public static final String user = "$user";
+  public static final String date = "$date";
+  public static final String url = "$url";
+  public static final String srcChecksum = "$srcChecksum";
+}
 EOF