diff --git a/pom.xml b/pom.xml index bbdfe39..edf96a2 100644 --- a/pom.xml +++ b/pom.xml @@ -89,41 +89,6 @@ - - com.google.code.maven-replacer-plugin - replacer - 1.5.3 - - - replace-version-number - generate-sources - - replace - - - - - ${project.basedir}/src/main/java - - **/CliVersionInfo.java - - true - - - MAVEN_PROJECT_NAME = ".*" - MAVEN_PROJECT_NAME = "${project.name}" - - - MAVEN_PROJECT_VERSION = ".*" - MAVEN_PROJECT_VERSION = "${project.version}" - - - BUILD_NO = ".*" - BUILD_NO = "${travisBuildNumber}" - - - - org.apache.maven.plugins maven-surefire-plugin @@ -162,6 +127,22 @@ + + + src/main/resources + true + + **/utplsql-cli.version + + + + src/main/resources + false + + **/utplsql-cli.version + + + diff --git a/src/main/java/org/utplsql/cli/CliVersionInfo.java b/src/main/java/org/utplsql/cli/CliVersionInfo.java index 96fbc4c..c7ab283 100644 --- a/src/main/java/org/utplsql/cli/CliVersionInfo.java +++ b/src/main/java/org/utplsql/cli/CliVersionInfo.java @@ -1,5 +1,13 @@ package org.utplsql.cli; +import org.utplsql.api.JavaApiVersionInfo; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URISyntaxException; + /** This class is getting updated automatically by the build process. * Please do not update its constants manually cause they will be overwritten. * @@ -7,14 +15,25 @@ */ public class CliVersionInfo { - private static final String BUILD_NO = "local"; - private static final String MAVEN_PROJECT_NAME = "cli"; - private static final String MAVEN_PROJECT_VERSION = "3.1.1-SNAPSHOT"; + private static final String MAVEN_PROJECT_NAME = "utPLSL-cli"; + private static String MAVEN_PROJECT_VERSION = "unknown"; - public static String getVersion() { - return MAVEN_PROJECT_VERSION + "." + BUILD_NO; + static { + try { + try ( InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-cli.version")) { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + MAVEN_PROJECT_VERSION = reader.readLine(); + + reader.close(); + } + } + catch ( IOException e ) { + System.out.println("WARNING: Could not get Version information!"); + } } + public static String getVersion() { return MAVEN_PROJECT_VERSION; } public static String getInfo() { return MAVEN_PROJECT_NAME + " " + getVersion(); } + } diff --git a/src/main/resources/utplsql-cli.version b/src/main/resources/utplsql-cli.version new file mode 100644 index 0000000..3fb16e7 --- /dev/null +++ b/src/main/resources/utplsql-cli.version @@ -0,0 +1 @@ +${project.version}.${travisBuildNumber} \ No newline at end of file diff --git a/src/test/java/org/utplsql/cli/CliVersionInfoTest.java b/src/test/java/org/utplsql/cli/CliVersionInfoTest.java new file mode 100644 index 0000000..fc1957b --- /dev/null +++ b/src/test/java/org/utplsql/cli/CliVersionInfoTest.java @@ -0,0 +1,14 @@ +package org.utplsql.cli; + +import org.junit.jupiter.api.Test; +import org.utplsql.api.JavaApiVersionInfo; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class CliVersionInfoTest { + + @Test + void getCliVersionInfo() { + assertTrue(CliVersionInfo.getVersion().startsWith("3.1")); + } +}