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
This commit is contained in:
parent
5e905c02d9
commit
2fcc691b16
|
@ -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();
|
|
||||||
}
|
|
|
@ -23,40 +23,24 @@ import java.io.PrintWriter;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class finds the package info for hbase and the VersionAnnotation
|
* This class finds the Version information for HBase.
|
||||||
* information. Taken from hadoop. Only name of annotation is different.
|
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class VersionInfo {
|
public class VersionInfo {
|
||||||
private static final Log LOG = LogFactory.getLog(VersionInfo.class.getName());
|
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.
|
* Get the hbase version.
|
||||||
* @return the hbase version string, eg. "0.6.3-dev"
|
* @return the hbase version string, eg. "0.6.3-dev"
|
||||||
*/
|
*/
|
||||||
public static String getVersion() {
|
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"
|
* @return the revision number, eg. "451451"
|
||||||
*/
|
*/
|
||||||
public static String getRevision() {
|
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
|
* @return the compilation date in unix date format
|
||||||
*/
|
*/
|
||||||
public static String getDate() {
|
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
|
* @return the username of the user
|
||||||
*/
|
*/
|
||||||
public static String getUser() {
|
public static String getUser() {
|
||||||
return version != null ? version.user() : "Unknown";
|
return Version.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +72,7 @@ public class VersionInfo {
|
||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public static String getUrl() {
|
public static String getUrl() {
|
||||||
return version != null ? version.url() : "Unknown";
|
return Version.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String[] versionReport() {
|
static String[] versionReport() {
|
||||||
|
@ -105,7 +89,7 @@ public class VersionInfo {
|
||||||
* @return a string that uniquely identifies the source
|
* @return a string that uniquely identifies the source
|
||||||
**/
|
**/
|
||||||
public static String getSrcChecksum() {
|
public static String getSrcChecksum() {
|
||||||
return version != null ? version.srcChecksum() : "Unknown";
|
return Version.srcChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTo(PrintWriter out) {
|
public static void writeTo(PrintWriter out) {
|
||||||
|
|
|
@ -55,13 +55,19 @@ fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
mkdir -p "$outputDirectory/org/apache/hadoop/hbase"
|
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
|
* Generated by src/saveVersion.sh
|
||||||
*/
|
*/
|
||||||
@VersionAnnotation(version="$version", revision="$revision",
|
|
||||||
user="$user", date="$date", url="$url",
|
|
||||||
srcChecksum="$srcChecksum")
|
|
||||||
package org.apache.hadoop.hbase;
|
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
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue