Merge lp:~ralf-claussnitzer-deactivatedaccount/goobi-production/standalone-cli into lp:goobi-production/1.7

Proposed by Ralf Claussnitzer
Status: Merged
Approved by: Henning Gerhardt
Approved revision: 58
Merged at revision: 53
Proposed branch: lp:~ralf-claussnitzer-deactivatedaccount/goobi-production/standalone-cli
Merge into: lp:goobi-production/1.7
Diff against target: 118 lines (+53/-5)
2 files modified
build.xml (+27/-1)
src/org/goobi/production/cli/CommandLineInterface.java (+26/-4)
To merge this branch: bzr merge lp:~ralf-claussnitzer-deactivatedaccount/goobi-production/standalone-cli
Reviewer Review Type Date Requested Status
Henning Gerhardt Approve
Review via email: mp+102142@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Henning Gerhardt (henning-gerhardt) wrote :

looks ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.xml'
2--- build.xml 2012-04-16 08:47:18 +0000
3+++ build.xml 2012-04-16 16:33:23 +0000
4@@ -43,6 +43,7 @@
5 <property name="build.dist.vendor" value="SLUB Dresden"/>
6 <property name="build.dist.url" value="http://launchpad.net/goobi-production"/>
7 <property name="build.dist.war" value="${build.dist.dir}/${build.dist.name}-${build.dist.version}.war"/>
8+ <property name="build.dist.jar" value="${build.dist.dir}/${build.dist.name}-${build.dist.version}.jar"/>
9
10 <property name="lib.dir" value="${basedir}/lib"/>
11
12@@ -93,7 +94,7 @@
13 <echoproperties/>
14 </target>
15
16- <target name="dist" depends="war" description="Produce the distributable."/>
17+ <target name="dist" depends="war, jar" description="Produce the distributables."/>
18
19 <target name="distclean" description="Clean up the distribution files only.">
20 <delete dir="${build.dist.dir}"/>
21@@ -154,6 +155,7 @@
22 <!-- Create needed directories -->
23 <target name="createDirs">
24 <mkdir dir="${build.dir}"/>
25+ <mkdir dir="${build.dist.dir}"/>
26 <mkdir dir="${build.classes}"/>
27 <mkdir dir="${build.classes.test}"/>
28 <delete dir="${doc.javadocs.dir}"/>
29@@ -269,6 +271,30 @@
30
31 </target>
32
33+ <!-- Build standalone CLI jar -->
34+ <target name="jar" depends="compile, copy-config">
35+
36+ <manifestclasspath property="manifest.classpath" jarfile="${build.dist.jar}">
37+ <classpath>
38+ <fileset dir="${lib.dir}" includes="*.jar"/>
39+ </classpath>
40+ </manifestclasspath>
41+
42+ <jar destfile="${build.dist.jar}">
43+ <fileset dir="${build.classes}" includes="**/*.class, log4j.properties, GoobiConfig.properties, hibernate.cfg.xml"/>
44+ <zipfileset dir="${lib.dir}" prefix="lib"/>
45+
46+ <manifest>
47+ <attribute name="Implementation-Title" value="${ant.project.name}"/>
48+ <attribute name="Implementation-Version" value="${build.dist.version}"/>
49+ <attribute name="Implementation-Vendor" value="${build.dist.vendor}"/>
50+ <attribute name="Implementation-URL" value="${build.dist.url}"/>
51+ <attribute name="Implementation-Build-Date" value="${TODAY_UK}"/>
52+ <attribute name="Class-Path" value=". ${manifest.classpath}"/>
53+ <attribute name="Main-Class" value="org.goobi.production.cli.CommandLineInterface"/>
54+ </manifest>
55+ </jar>
56+ </target>
57
58 <!-- Copy configuration files to build directory -->
59 <target name="copy-config">
60
61=== modified file 'src/org/goobi/production/cli/CommandLineInterface.java'
62--- src/org/goobi/production/cli/CommandLineInterface.java 2012-02-22 07:43:02 +0000
63+++ src/org/goobi/production/cli/CommandLineInterface.java 2012-04-16 16:33:23 +0000
64@@ -24,10 +24,12 @@
65
66 import java.io.File;
67 import java.io.IOException;
68+import java.net.URL;
69 import java.util.ArrayList;
70 import java.util.Collections;
71 import java.util.HashMap;
72 import java.util.List;
73+import java.util.jar.Manifest;
74
75 import org.apache.commons.cli.CommandLine;
76 import org.apache.commons.cli.CommandLineParser;
77@@ -91,9 +93,18 @@
78
79 // Version.
80 if (commandLine.hasOption('V')) {
81- System.out.println("Goobi version: " + GoobiVersion.getVersion());
82- System.out.println("Goobi build date: " + GoobiVersion.getBuilddate());
83- System.out.println("Goobi build version: " + GoobiVersion.getBuildversion());
84+ try {
85+ // Use Manifest to setup version information
86+ Manifest m = getManifestForClass(CommandLineInterface.class);
87+ GoobiVersion.setupFromManifest(m);
88+
89+ System.out.println("Goobi version: " + GoobiVersion.getVersion());
90+ System.out.println("Goobi build date: " + GoobiVersion.getBuilddate());
91+ System.out.println("Goobi build version: " + GoobiVersion.getBuildversion());
92+ } catch (Exception e) {
93+ System.err.println("Cannot obtain version information from MANIFEST file: " + e.getMessage());
94+ return 1;
95+ }
96 return 0;
97 }
98 // testing command
99@@ -228,7 +239,18 @@
100 return 0;
101 }
102
103-
104+ private static Manifest getManifestForClass(Class c) throws IOException {
105+ String className = c.getSimpleName() + ".class";
106+ String classPath = c.getResource(className).toString();
107+
108+ if (!classPath.startsWith("jar")) {
109+ throw new IOException("Cannot read Manifest file.");
110+ }
111+
112+ String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
113+ return new Manifest(new URL(manifestPath).openStream());
114+ }
115+
116 public static int generateNewProcess(Integer vorlageId, String importFolder) throws ReadException, PreferencesException, SwapException, DAOException, WriteException, IOException, InterruptedException {
117 Prozess vorlage = new ProzessDAO().get(vorlageId);
118 File dir = new File(importFolder);

Subscribers

People subscribed via source and target branches

to all changes: