mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-01 16:52:08 +01:00
Sop: Sync version with gradle version variable and fix format
This commit is contained in:
parent
bfbb2ba31b
commit
8e3b61b76e
2 changed files with 34 additions and 3 deletions
19
build.gradle
19
build.gradle
|
@ -171,6 +171,25 @@ subprojects {
|
||||||
required { signingRequired }
|
required { signingRequired }
|
||||||
sign publishing.publications.mavenJava
|
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) {
|
def getAndroidRuntimeJar(androidSdkApiLevel) {
|
||||||
|
|
|
@ -15,15 +15,27 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.sop.commands;
|
package org.pgpainless.sop.commands;
|
||||||
|
|
||||||
import picocli.CommandLine;
|
|
||||||
|
|
||||||
import static org.pgpainless.sop.Print.print_ln;
|
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")
|
@CommandLine.Command(name = "version", description = "Display version information about the tool")
|
||||||
public class Version implements Runnable {
|
public class Version implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue