slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00144
[Merge] lp:~ralf-claussnitzer/goobi-production/standalone-cli into lp:goobi-production
Ralf Claussnitzer has proposed merging lp:~ralf-claussnitzer/goobi-production/standalone-cli into lp:goobi-production.
Requested reviews:
Henning Gerhardt (henning-gerhardt)
For more details, see:
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/standalone-cli/+merge/102142
--
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/standalone-cli/+merge/102142
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== modified file 'build.xml'
--- build.xml 2012-04-16 08:47:18 +0000
+++ build.xml 2012-04-16 16:31:26 +0000
@@ -43,6 +43,7 @@
<property name="build.dist.vendor" value="SLUB Dresden"/>
<property name="build.dist.url" value="http://launchpad.net/goobi-production"/>
<property name="build.dist.war" value="${build.dist.dir}/${build.dist.name}-${build.dist.version}.war"/>
+ <property name="build.dist.jar" value="${build.dist.dir}/${build.dist.name}-${build.dist.version}.jar"/>
<property name="lib.dir" value="${basedir}/lib"/>
@@ -93,7 +94,7 @@
<echoproperties/>
</target>
- <target name="dist" depends="war" description="Produce the distributable."/>
+ <target name="dist" depends="war, jar" description="Produce the distributables."/>
<target name="distclean" description="Clean up the distribution files only.">
<delete dir="${build.dist.dir}"/>
@@ -154,6 +155,7 @@
<!-- Create needed directories -->
<target name="createDirs">
<mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.dist.dir}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.classes.test}"/>
<delete dir="${doc.javadocs.dir}"/>
@@ -269,6 +271,30 @@
</target>
+ <!-- Build standalone CLI jar -->
+ <target name="jar" depends="compile, copy-config">
+
+ <manifestclasspath property="manifest.classpath" jarfile="${build.dist.jar}">
+ <classpath>
+ <fileset dir="${lib.dir}" includes="*.jar"/>
+ </classpath>
+ </manifestclasspath>
+
+ <jar destfile="${build.dist.jar}">
+ <fileset dir="${build.classes}" includes="**/*.class, log4j.properties, GoobiConfig.properties, hibernate.cfg.xml"/>
+ <zipfileset dir="${lib.dir}" prefix="lib"/>
+
+ <manifest>
+ <attribute name="Implementation-Title" value="${ant.project.name}"/>
+ <attribute name="Implementation-Version" value="${build.dist.version}"/>
+ <attribute name="Implementation-Vendor" value="${build.dist.vendor}"/>
+ <attribute name="Implementation-URL" value="${build.dist.url}"/>
+ <attribute name="Implementation-Build-Date" value="${TODAY_UK}"/>
+ <attribute name="Class-Path" value=". ${manifest.classpath}"/>
+ <attribute name="Main-Class" value="org.goobi.production.cli.CommandLineInterface"/>
+ </manifest>
+ </jar>
+ </target>
<!-- Copy configuration files to build directory -->
<target name="copy-config">
=== modified file 'src/org/goobi/production/cli/CommandLineInterface.java'
--- src/org/goobi/production/cli/CommandLineInterface.java 2012-02-22 07:43:02 +0000
+++ src/org/goobi/production/cli/CommandLineInterface.java 2012-04-16 16:31:26 +0000
@@ -24,10 +24,12 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.jar.Manifest;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -91,9 +93,18 @@
// Version.
if (commandLine.hasOption('V')) {
- System.out.println("Goobi version: " + GoobiVersion.getVersion());
- System.out.println("Goobi build date: " + GoobiVersion.getBuilddate());
- System.out.println("Goobi build version: " + GoobiVersion.getBuildversion());
+ try {
+ // Use Manifest to setup version information
+ Manifest m = getManifestForClass(CommandLineInterface.class);
+ GoobiVersion.setupFromManifest(m);
+
+ System.out.println("Goobi version: " + GoobiVersion.getVersion());
+ System.out.println("Goobi build date: " + GoobiVersion.getBuilddate());
+ System.out.println("Goobi build version: " + GoobiVersion.getBuildversion());
+ } catch (Exception e) {
+ System.err.println("Cannot obtain version information from MANIFEST file: " + e.getMessage());
+ return 1;
+ }
return 0;
}
// testing command
@@ -228,7 +239,18 @@
return 0;
}
-
+ private static Manifest getManifestForClass(Class c) throws IOException {
+ String className = c.getSimpleName() + ".class";
+ String classPath = c.getResource(className).toString();
+
+ if (!classPath.startsWith("jar")) {
+ throw new IOException("Cannot read Manifest file.");
+ }
+
+ String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
+ return new Manifest(new URL(manifestPath).openStream());
+ }
+
public static int generateNewProcess(Integer vorlageId, String importFolder) throws ReadException, PreferencesException, SwapException, DAOException, WriteException, IOException, InterruptedException {
Prozess vorlage = new ProzessDAO().get(vorlageId);
File dir = new File(importFolder);
Follow ups