Skip to content

Commit

Permalink
VersionName: Use annotation proc to generate as constant.
Browse files Browse the repository at this point in the history
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 6e43a58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
17 changes: 15 additions & 2 deletions cli/pom.xml
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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>
Expand Down
10 changes: 3 additions & 7 deletions cli/src/main/java/info/schnatterer/colander/cli/ColanderCli.java
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 6e43a58

Please sign in to comment.