Skip to content

Commit

Permalink
automatic project version and EO version
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailLipanin committed Nov 28, 2022
1 parent 32a553a commit 3997153
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ SOFTWARE.
<artifactId>picocli</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-manifests</artifactId>
<!-- version from parent POM -->
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -197,6 +202,7 @@ SOFTWARE.
<archive>
<manifestEntries>
<Main-Class>org.eolang.dejump.Main</Main-Class>
<Dejump-Version>${project.version}</Dejump-Version>
</manifestEntries>
</archive>
<descriptorRefs>
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/org/eolang/dejump/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.eolang.dejump;

import com.jcabi.manifests.Manifests;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.Callable;
Expand All @@ -34,10 +35,12 @@
* @since 0.0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@CommandLine.Command(name = "dejump",
@CommandLine.Command(
name = "dejump",
mixinStandardHelpOptions = true,
version = "Version 0.0.1",
description = "Replaces objects GOTO with semantically equivalent")
description = "Replaces objects GOTO with semantically equivalent",
versionProvider = Main.Version.class
)
public final class Main implements Callable<Integer> {

/**
Expand Down Expand Up @@ -68,4 +71,22 @@ public Integer call() throws IOException {
public static void main(final String[] args) {
new CommandLine(new Main()).execute(args);
}

/**
* Version.
* @since 0.0.2
*/
static final class Version implements CommandLine.IVersionProvider {
@Override
public String[] getVersion() {
return new String[]{
String.format(
"Dejump version is %s\nEO version is %s",
Manifests.read("Dejump-Version"),
Manifests.read("EO-Version")
),
};
}
}

}

0 comments on commit 3997153

Please sign in to comment.