2
0
Fork 0

Added build info and clean poms a bit.

This commit is contained in:
Willem Cazander 2012-12-02 14:40:18 +01:00
parent c259e28e44
commit afd821c360
27 changed files with 298 additions and 176 deletions

View file

@ -9,6 +9,46 @@
<artifactId>vasc-demo-server-core</artifactId>
<name>vasc-demo-server-core</name>
<description>vasc-server-tech-core</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>generate-version-class</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}/generated-sources/net/forwardfire/vasc/demo/server/core" />
<echo file="${project.build.directory}/generated-sources/net/forwardfire/vasc/demo/server/core/VascTechDemoBuildInfoImpl.java">
package net.forwardfire.vasc.demo.server.core;
/** Automatically generated by ant. */
public class VascTechDemoBuildInfoImpl implements VascTechDemoBuildInfo {
static public final String VERSION = "${project.version}";
static public final String BUILD_DATE = "${maven.build.timestamp}";
public String getVersion() {
return VERSION;
}
public String getBuildDate() {
return BUILD_DATE;
}
}
</echo>
</target>
<sourceRoot>
${project.build.directory}/generated-sources
</sourceRoot>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.x4o</groupId>

View file

@ -0,0 +1,42 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.server.core;
/**
* VascTechDemoBuildInfo provides interfaces for build system so we have version and build date.
*
* @author Willem Cazander
* @version 1.0 Dec 1, 2012
*/
public interface VascTechDemoBuildInfo {
/**
* @return Returns the build version.
*/
String getVersion();
/**
* @return Returns the build date.
*/
String getBuildDate();
}

View file

@ -25,6 +25,7 @@ package net.forwardfire.vasc.demo.server.core;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Date;
import java.util.logging.Handler;
import java.util.logging.Logger;
@ -52,6 +53,7 @@ public class VascTechDemoStartup {
private TomcatService tomcatService = null;
private VascControllerService vascControllerService = null;
private ServerGuiService swingGuiService = null;
private VascTechDemoBuildInfo buildInfo = null;
static private VascTechDemoStartup instance = null;
/**
@ -136,6 +138,30 @@ public class VascTechDemoStartup {
logger.info("Logging is ready for application log;");
}
private void setupBuildInfo() {
if (buildInfo!=null) {
return;
}
try {
Class<?> infoClass = Class.forName(VascTechDemoBuildInfo.class.getPackage().getName()+"."+VascTechDemoBuildInfo.class.getSimpleName()+"Impl");
buildInfo = (VascTechDemoBuildInfo)infoClass.newInstance();
return;
} catch (Exception e) {
logger.warning("Could not load build info impl fallback to local one.");
}
buildInfo = new VascTechDemoBuildInfo() {
@Override
public String getVersion() {
return "0.0.0-dev";
}
@Override
public String getBuildDate() {
return new Date().toString();
}
};
}
/**
* Init all demo service beans.
* @param argu
@ -147,6 +173,7 @@ public class VascTechDemoStartup {
System.setProperty("java.security.auth.login.config", "file:conf/login.config");
setupAutoDir();
setupLogging();
setupBuildInfo();
logger.info("VascTechDemo initializing ...");
databaseService = new DatabaseService();
tomcatService = new TomcatService();
@ -239,4 +266,8 @@ public class VascTechDemoStartup {
public ServerGuiService getSwingGuiService() {
return swingGuiService;
}
public VascTechDemoBuildInfo getBuildInfo() {
return buildInfo;
}
}

View file

@ -98,7 +98,7 @@ public class JStatusPanel extends JPanel implements ActionListener {
statusPanel.add(new JLabel("vasc-demo-server-core"));
statusPanel.add(new JLabel("Version:"));
statusPanel.add(new JLabel("0.X.X"));
statusPanel.add(new JLabel(VascTechDemoStartup.getInstance().getBuildInfo().getVersion()));
statusPanel.add(new JLabel("Groups:"));
statusPanel.add(infoVascGroups);