We can get these info from manifest.
Add below plugin in the parent pom.xml
In the child pom.xml, setup below
<artifactId>com.test.app</artifactId>
<name>AppName</name>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${maven.build.timestamp}</Implementation-Build>
<APP-ID>${artifactId}</APP-ID>
<APP-NAME>${name}</APP-NAME>
<APP-VERSION>${version}</APP-VERSION>
</manifestEntries>
</archive>
</configuration>
</plugin>
def getAppInfo: (String, String) = { val p = getClass.getPackage val appName = Option(p.getImplementationTitle) .getOrElse("MyApp") val version = Option(p.getImplementationVersion) .getOrElse("SNAPSHOT") (appName, version) }
No comments:
Post a Comment