java.lang.Object
io.aiven.commons.util.strings.Version
Reads a list of versions from a configuration file. Versions may be retrieved by calling
of(String). By default, reads versions from "app.properties" Recommended usage is to add a
package version property in the pom.xml that looks something like
<properties>
<my-groupid-and-artifactid-version>1.3.4</my-groupid-and-artifactid-version>
</properties>
use the properties-maven-plugin to generate the properties file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>write-project-properties</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputFile>${project.build.outputDirectory}/${project.groupId}/${artifactId}.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
and then retrieve the code in the project as
public static String VERSION = new Version("groupid/artifactid.properties").of("my-groupid-and-artifactid-version");
If additional values from the properties are desired then creating an instance of Version
and calling of(String) for the desired properties will work.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Version
public Version()Default constructor. Reads "app.properties" -
Version
property loader. Reads properties from the specified file which must be in the classpath.- Parameters:
propertyFileName- the name of the property file to read
-
-
Method Details
-
of
Retrieve a string for the property as defined in the property file.- Parameters:
property- the name of the property.- Returns:
- the property stirng, "unknown" if not set, or an error message if the file was not read.
-