Skip to content
Permalink
Browse files

VersionName: Use annotation proc to generate as constant.

Instead of loading it from manifest.
Much more reliable, regarding class loading of different envs, JDKs,
and GraalVM native images, where there is no Jar containig the manifest.
  • Loading branch information...
schnatterer committed Jun 27, 2019
1 parent 100e33f commit 6e43a580b9db0c3c5328d90e0fcac3720dd1ab3d
Showing with 23 additions and 10 deletions.
  1. +15 −2 cli/pom.xml
  2. +3 −7 cli/src/main/java/info/schnatterer/colander/cli/ColanderCli.java
  3. +5 −1 pom.xml
@@ -67,8 +67,10 @@

<dependency>
<groupId>com.cloudogu.versionName</groupId>
<artifactId>versionName</artifactId>
<version>2.0.0</version>
<artifactId>processor</artifactId>
<version>2.1.0</version>
<!-- This dependency is only needed during compile time and should not be packaged into final JAR -->
<scope>provided</scope>
</dependency>

<!-- test -->
@@ -120,6 +122,17 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<!-- Provide version name to versionName processor-->
<arg>-AversionName=${versionName}</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
<!-- Assemble zip -->
<groupId>org.apache.maven.plugins</groupId>
@@ -23,7 +23,7 @@
*/
package info.schnatterer.colander.cli;

import com.cloudogu.versionname.VersionNames;
import com.cloudogu.versionname.VersionName;
import info.schnatterer.colander.Colander;
import info.schnatterer.colander.cli.ArgumentsParser.ArgumentException;
import org.slf4j.Logger;
@@ -32,6 +32,7 @@
/**
* Main class of Command Line Interface for colander.
*/
@VersionName
class ColanderCli {
private static final String PROGRAM_NAME = "colander";
private static final Logger LOG = LoggerFactory.getLogger(ColanderCli.class);
@@ -77,12 +78,7 @@ ExitStatus execute(String[] args) {
}

private String createProgramNameWithVersion() {
String programName = PROGRAM_NAME;
String versionNameFromManifest = VersionNames.getVersionNameFromManifest();
if (!versionNameFromManifest.isEmpty()) {
programName = programName + " " + versionNameFromManifest;
}
return programName;
return PROGRAM_NAME + " " + Version.NAME;
}

/**
@@ -137,13 +137,17 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>

0 comments on commit 6e43a58

Please sign in to comment.
You can’t perform that action at this time.