1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-25 22:02:05 +01:00

Sop: Sync version with gradle version variable and fix format

This commit is contained in:
Paul Schaub 2021-03-05 13:04:28 +01:00
parent bfbb2ba31b
commit 8e3b61b76e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 34 additions and 3 deletions

View file

@ -171,6 +171,25 @@ subprojects {
required { signingRequired }
sign publishing.publications.mavenJava
}
def generatedVersionDir = "${buildDir}/generated-version"
sourceSets {
main {
output.dir(generatedVersionDir, builtBy: 'generateVersionProperties')
}
}
task generateVersionProperties {
doLast {
def propertiesFile = file "$generatedVersionDir/version.properties"
propertiesFile.parentFile.mkdirs()
def properties = new Properties()
properties.setProperty("version", rootProject.version.toString())
propertiesFile.withWriter { properties.store(it, null) }
}
}
processResources.dependsOn generateVersionProperties
}
def getAndroidRuntimeJar(androidSdkApiLevel) {

View file

@ -15,15 +15,27 @@
*/
package org.pgpainless.sop.commands;
import picocli.CommandLine;
import static org.pgpainless.sop.Print.print_ln;
import java.io.IOException;
import java.util.Properties;
import picocli.CommandLine;
@CommandLine.Command(name = "version", description = "Display version information about the tool")
public class Version implements Runnable {
@Override
public void run() {
print_ln("PGPainless CLI version 0.0.1");
// See https://stackoverflow.com/a/50119235
String version;
try {
Properties properties = new Properties();
properties.load(getClass().getResourceAsStream("/version.properties"));
version = properties.getProperty("version");
} catch (IOException e) {
version = "DEVELOPMENT";
}
print_ln("PGPainlessCLI " + version);
}
}