mirror of https://github.com/dspinellis/UMLGraph
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:
parent
381301b1e3
commit
f309d89222
6
pom.xml
6
pom.xml
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
umlgraph.version=${pom.version}
|
||||
Loading…
Reference in New Issue