mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-293 now reading the version from the resource file "map.version"
This commit is contained in:
@@ -17,13 +17,15 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>net.openhft</groupId>
|
||||
<artifactId>java-parent-pom</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<relativePath />
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -141,6 +143,24 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>**/map.version</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<excludes>
|
||||
<exclude>**/map.version</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
|
||||
@@ -21,16 +21,14 @@ package net.openhft.chronicle.map;
|
||||
import shaded.org.apache.maven.model.Model;
|
||||
import shaded.org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.Reader;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* gets the version of the current build
|
||||
*/
|
||||
class BuildVersion {
|
||||
|
||||
private static String version = null;
|
||||
private static String version = null;
|
||||
|
||||
/**
|
||||
* @return version of ChronicleMap being used, or NULL if its not known
|
||||
@@ -41,7 +39,23 @@ class BuildVersion {
|
||||
return version;
|
||||
}
|
||||
|
||||
// the best way to get the version is to read it from the manifest
|
||||
try {
|
||||
// the best way to get the version is to read the map.version file
|
||||
InputStream resource = BuildVersion.class.getClassLoader().getResourceAsStream("map" +
|
||||
".version");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(resource));
|
||||
|
||||
version = in.readLine().trim();
|
||||
if (!"${project.version}".equals(version()))
|
||||
return version;
|
||||
|
||||
return version;
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// another way to get the version is to read it from the manifest
|
||||
final String versionFromManifest = getVersionFromManifest();
|
||||
|
||||
if (versionFromManifest != null) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
${project.version}
|
||||
Reference in New Issue
Block a user