Skip to content

Commit

Permalink
printing version (for support)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattulbrich committed Dec 8, 2022
1 parent 1a0401c commit 639fa7a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
19 changes: 17 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ plugins {
id 'antlr'
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.github.hierynomus.license' version '0.16.1'
id "org.ajoberstar.grgit" version "1.7.2"
}

group 'edu.kit.kastel.formal'
version '1.1-SNAPSHOT'
version '1.1.0'

task versionFile() {
def resourcesDir = sourceSets.main.output.resourcesDir
outputs.dir resourcesDir
doFirst {
resourcesDir.mkdirs()
new File(resourcesDir, "VERSION").text = "$version (${grgit.head().abbreviatedId})"
print( "$resourcesDir/VERSION created.")
}
}

compileJava.configure {
dependsOn versionFile
}

repositories {
mavenCentral()
Expand All @@ -25,12 +40,12 @@ java {
}
}


application {
mainClass = "edu.kit.kastel.formal.mimaflux.MimaFlux"
}

shadowJar {
dependsOn versionFile
dependencies {
exclude(dependency('org.antlr:antlr4:.*'))
exclude(dependency('com.ibm.icu:.*:.*'))
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/edu/kit/kastel/formal/mimaflux/MimaFlux.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@
import edu.kit.kastel.formal.mimaflux.gui.GUI;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import java.util.List;

public class MimaFlux {

public static final String VERSION;
static {
URL u = MimaFlux.class.getResource("/VERSION");
String version = "<unknown>";
try {
try (InputStream in = u.openStream()) {
version = new String(in.readAllBytes(), StandardCharsets.UTF_8);
}
} catch(Exception ex) {
ex.printStackTrace();
}
VERSION = version;
}

public static MimaFluxArgs mmargs;

public static void main(String[] args) throws Exception {
Expand All @@ -35,6 +52,8 @@ public static void main(String[] args) throws Exception {
.build();
jc.parse(args);

System.out.println("Mima Flux Capacitor " + VERSION);

if (mmargs.help) {
jc.usage();
System.exit(0);
Expand Down

0 comments on commit 639fa7a

Please sign in to comment.