gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1444462 - in /gora/trunk: CHANGES.txt bin/gora gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java gora-core/src/main/java/org/apache/gora/util/VersionInfo.java
Date Sat, 09 Feb 2013 22:50:59 GMT
Author: lewismc
Date: Sat Feb  9 22:50:58 2013
New Revision: 1444462

URL: http://svn.apache.org/r1444462
Log:
GORA-190 Add version switch to bin/gora script

Added:
    gora/trunk/gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java
    gora/trunk/gora-core/src/main/java/org/apache/gora/util/VersionInfo.java
Modified:
    gora/trunk/CHANGES.txt
    gora/trunk/bin/gora

Modified: gora/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/trunk/CHANGES.txt?rev=1444462&r1=1444461&r2=1444462&view=diff
==============================================================================
--- gora/trunk/CHANGES.txt (original)
+++ gora/trunk/CHANGES.txt Sat Feb  9 22:50:58 2013
@@ -6,6 +6,8 @@ Gora Change Log
 
 trunk (current development)
 
+* GORA-190 Add "version" switch to bin/gora script (lewismc)
+
 * GORA-169 Implement correct logging for KeySpaces and attributes in CassandraMappingManager
(lewismc)
 
 * GORA-27 Optionally add license headers to generated files (lewismc + rmarroquin)

Modified: gora/trunk/bin/gora
URL: http://svn.apache.org/viewvc/gora/trunk/bin/gora?rev=1444462&r1=1444461&r2=1444462&view=diff
==============================================================================
--- gora/trunk/bin/gora (original)
+++ gora/trunk/bin/gora Sat Feb  9 22:50:58 2013
@@ -49,6 +49,7 @@ if [ $# = 0 ]; then
   echo "  logmanager                 Run the tutorial log manager"
   echo "  loganalytics               Run the tutorial log analytics"
   echo "  junit         	     Run the given JUnit test"
+  echo "  version         	     Print Gora version to terminal"
   echo " or"
   echo " MODULE CLASSNAME   run the class named CLASSNAME in module MODULE"
   echo "Most commands print help when invoked w/o parameters."
@@ -132,6 +133,10 @@ elif [ "$COMMAND" = "junit" ] ; then
   MODULE=*
   CLASSPATH=$CLASSPATH:$GORA_HOME/$MODULE/target/test-classes/
   CLASS=junit.textui.TestRunner
+elif [ "$COMMAND" = "version" ] ; then
+  MODULE=gora-core
+  CLASSPATH=$CLASSPATH:$GORA_HOME/$MODULE/target/classes/
+  CLASS=org.apache.gora.util.VersionInfo
 else
   MODULE="$COMMAND"
   CLASS=$1

Added: gora/trunk/gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java?rev=1444462&view=auto
==============================================================================
--- gora/trunk/gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java (added)
+++ gora/trunk/gora-core/src/main/java/org/apache/gora/GoraVersionAnnotation.java Sat Feb
 9 22:50:58 2013
@@ -0,0 +1,66 @@
+/*
+ * 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.gora;
+
+import java.lang.annotation.*;
+
+/**
+ * A package attribute that captures the version of Gora that was compiled.
+ * This implementation reflects that used in Apache Hadoop.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+public @interface GoraVersionAnnotation {
+ 
+  /**
+   * Get the Gora version
+   * @return the version string e.g. "X.Y"
+   */
+  String version();
+  
+  /**
+   * Get the username .
+   * @return the username of the person that compiled Gora
+   */
+  String user();
+  
+  /**
+   * Get the date when Gora was compiled.
+   * @return the date in unix 'date' format
+   */
+  String date();
+  
+  /**
+   * Get the url for the subversion repository.
+   * @return the appropriate Gora URL in SVN
+   */
+  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
+   * Gora was compiled.
+   * @return a string that uniquely identifies the source
+   **/
+  String srcChecksum();
+}

Added: gora/trunk/gora-core/src/main/java/org/apache/gora/util/VersionInfo.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-core/src/main/java/org/apache/gora/util/VersionInfo.java?rev=1444462&view=auto
==============================================================================
--- gora/trunk/gora-core/src/main/java/org/apache/gora/util/VersionInfo.java (added)
+++ gora/trunk/gora-core/src/main/java/org/apache/gora/util/VersionInfo.java Sat Feb  9 22:50:58
2013
@@ -0,0 +1,109 @@
+/*
+ * 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.gora.util;
+
+import org.apache.gora.GoraVersionAnnotation;
+
+/**
+ * This class finds the package info for Gora and the GoraVersionAnnotation
+ * information.
+ */
+public class VersionInfo {
+  private static Package myPackage;
+  private static GoraVersionAnnotation version;
+  
+  static {
+    myPackage = GoraVersionAnnotation.class.getPackage();
+    version = myPackage.getAnnotation(GoraVersionAnnotation.class);
+  }
+
+  /**
+   * Get the meta-data for the Gora package.
+   * @return
+   */
+  static Package getPackage() {
+    return myPackage;
+  }
+  
+  /**
+   * Get the Gora version.
+   * @return the Gora version string, eg. "X.Y"
+   */
+  public static String getVersion() {
+    return version != null ? version.version() : "Unknown";
+  }
+  
+  /**
+   * Get the subversion revision number for the root directory
+   * @return the revision number, eg. "451451"
+   */
+  public static String getRevision() {
+    return version != null ? version.revision() : "Unknown";
+  }
+  
+  /**
+   * The date that Gora was compiled.
+   * @return the compilation date in unix date format
+   */
+  public static String getDate() {
+    return version != null ? version.date() : "Unknown";
+  }
+  
+  /**
+   * The user that compiled Gora.
+   * @return the username of the user
+   */
+  public static String getUser() {
+    return version != null ? version.user() : "Unknown";
+  }
+  
+  /**
+   * Get the subversion URL for the root Gora directory.
+   */
+  public static String getUrl() {
+    return version != null ? version.url() : "Unknown";
+  }
+
+  /**
+   * Get the checksum of the source files from which Gora was
+   * built.
+   **/
+  public static String getSrcChecksum() {
+    return version != null ? version.srcChecksum() : "Unknown";
+  }
+  
+  /**
+   * Returns the buildVersion which includes version, 
+   * revision, user and date. 
+   */
+  public static String getBuildVersion(){
+    return VersionInfo.getVersion() + 
+    " from " + VersionInfo.getRevision() +
+    " by " + VersionInfo.getUser() + 
+    " source checksum " + VersionInfo.getSrcChecksum();
+  }
+  
+  public static void main(String[] args) {
+    System.out.println("Gora " + getVersion());
+    System.out.println("Subversion " + getUrl() + " -r " + getRevision());
+    System.out.println("Compiled by " + getUser() + " on " + getDate());
+    System.out.println("From source with checksum " + getSrcChecksum());
+
+  }
+}



Mime
View raw message