Do not autogenerate Version class on every compile.

Instead, use a properties template file and Maven filtering
to set the correct version while building the output jar.
At runtime, load the properties file from the classpath and
statically initialize the version parameter.
This commit is contained in:
Georgios Gousios 2012-06-27 18:35:02 +02:00
parent 381301b1e3
commit f309d89222
3 changed files with 36 additions and 0 deletions

View File

@ -36,6 +36,12 @@
<dependencies/>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -0,0 +1,29 @@
package org.umlgraph.doclet;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
class Version {
private final static String filename = "version.properties";
private final static String key = "umlgraph.version";
public static String VERSION;
static {
Properties props = new Properties();
InputStream in = Version.class.getClassLoader().getResourceAsStream(filename);
try {
props.load(in);
if (props.get(key) == null) {
System.err.println("Could not find version property");
VERSION = "0";
} else {
VERSION = props.get(key).toString();
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1 @@
umlgraph.version=${pom.version}