LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  April 2015

HPS-SVN April 2015

Subject:

r2697 - in /java/trunk: distribution/ distribution/src/main/java/org/hps/ distribution/src/main/resources/ distribution/src/main/resources/org/ distribution/src/main/resources/org/hps/ record-util/src/main/java/org/hps/job/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Tue, 14 Apr 2015 22:23:51 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (183 lines)

Author: [log in to unmask]
Date: Tue Apr 14 15:23:24 2015
New Revision: 2697

Log:
Print out HPS Java project properties when running command line job.  HPSJAVA-487

Added:
    java/trunk/distribution/src/main/java/org/hps/HPSJavaProperties.java
    java/trunk/distribution/src/main/resources/
    java/trunk/distribution/src/main/resources/org/
    java/trunk/distribution/src/main/resources/org/hps/
    java/trunk/distribution/src/main/resources/org/hps/hps-java.properties
Modified:
    java/trunk/distribution/pom.xml
    java/trunk/record-util/src/main/java/org/hps/job/JobManager.java

Modified: java/trunk/distribution/pom.xml
 =============================================================================
--- java/trunk/distribution/pom.xml	(original)
+++ java/trunk/distribution/pom.xml	Tue Apr 14 15:23:24 2015
@@ -6,6 +6,8 @@
     <description>module for creating a standalone runnable bin jar for HPS Java</description>
     <properties>
         <maven.javadoc.skip>true</maven.javadoc.skip>
+        <timestamp>${maven.build.timestamp}</timestamp>
+        <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
     </properties>
     <parent>
         <groupId>org.hps</groupId>
@@ -18,7 +20,13 @@
         <connection>scm:svn:svn://svn.freehep.org/hps/java/trunk/distribution/</connection>
         <developerConnection>scm:svn:svn://svn.freehep.org/hps/java/trunk/distribution/</developerConnection>
     </scm>
-    <build>              
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>        
+        </resources>              
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>

Added: java/trunk/distribution/src/main/java/org/hps/HPSJavaProperties.java
 =============================================================================
--- java/trunk/distribution/src/main/java/org/hps/HPSJavaProperties.java	(added)
+++ java/trunk/distribution/src/main/java/org/hps/HPSJavaProperties.java	Tue Apr 14 15:23:24 2015
@@ -0,0 +1,97 @@
+package org.hps;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * This class provides information about the HPS Java build environment for the current distribution jar that is being
+ * executed.
+ *
+ * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
+ */
+public final class HPSJavaProperties {
+
+    /**
+     * Properties file containing properties with values inserted from Maven resource filtering.
+     */
+    Properties properties = new Properties();
+
+    /**
+     * Class constructor.
+     *
+     * @throws IOException if there is problem loading the properties
+     */
+    public HPSJavaProperties() throws IOException {
+        final InputStream is = getClass().getResourceAsStream("/org/hps/hps-java.properties");
+        this.properties.load(is);
+        is.close();
+    }
+
+    /**
+     * Get the Java home from the build environment.
+     *
+     * @return the Java home directory
+     */
+    public String getJavaVersion() {
+        return this.properties.getProperty("java.version");
+    }
+
+    /**
+     * Get the LCSim version string.
+     *
+     * @return the LCSim version string
+     */
+    public String getLCSimVersion() {
+        return this.properties.getProperty("lcsimVersion");
+    }
+
+    /**
+     * Get the project name.
+     *
+     * @return the project name
+     */
+    public String getProjectArtifactId() {
+        return this.properties.getProperty("project.artifactId");
+    }
+
+    /**
+     * Get the local build directory.
+     *
+     * @return the local build directory
+     */
+    public String getProjectBuildDirectory() {
+        return this.properties.getProperty("project.build.directory");
+    }
+
+    /**
+     * Get the project version.
+     *
+     * @return the project version
+     */
+    public String getProjectVersion() {
+        return this.properties.getProperty("project.version");
+    }
+
+    /**
+     * Get the Maven build timestamp.
+     *
+     * @return the Maven build timestamp
+     */
+    public String getTimestamp() {
+        return this.properties.getProperty("timestamp");
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer();
+        sb.append("HPS Java properties" + '\n');
+        sb.append("project.artifactId: " + getProjectArtifactId() + '\n');
+        sb.append("project.version: " + getProjectVersion() + '\n');
+        sb.append("lcsimVersion: " + getLCSimVersion() + '\n');
+        sb.append("java.version: " + getJavaVersion() + '\n');
+        sb.append("project.build.directory: " + getProjectBuildDirectory() + '\n');
+        sb.append("timestamp: " + getTimestamp() + '\n');
+        return sb.toString();
+    }
+}

Added: java/trunk/distribution/src/main/resources/org/hps/hps-java.properties
 =============================================================================
--- java/trunk/distribution/src/main/resources/org/hps/hps-java.properties	(added)
+++ java/trunk/distribution/src/main/resources/org/hps/hps-java.properties	Tue Apr 14 15:23:24 2015
@@ -0,0 +1,7 @@
+project.artifactId: ${project.artifactId}
+project.version: ${project.version}
+timestamp: ${timestamp}
+lcsimVersion: ${lcsimVersion}
+project.build.directory: ${project.build.directory}
+java.version: ${java.version}
+project.attachedArtifact: ${project.attachedArtifact[0]}

Modified: java/trunk/record-util/src/main/java/org/hps/job/JobManager.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/job/JobManager.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/job/JobManager.java	Tue Apr 14 15:23:24 2015
@@ -27,6 +27,15 @@
      * Class constructor.
      */
     public JobManager() {
+
+        try {
+            // Since this is packaged with the distribution, the class is not directly accessible.
+            final Object hpsJavaProperties = Class.forName("org.hps.HPSJavaProperties").newInstance();
+            logger.info(hpsJavaProperties.toString());
+        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+            // Just don't print info if not accessible (running in test case?).
+        }
+
         // Always want to reset conditions system before starting the job.
         DatabaseConditionsManager.resetInstance();
     }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use