mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-09 03:37:57 +01:00
Extract pgpainless-sop-version property via resource filtering
This commit is contained in:
parent
a43ae43722
commit
5018386318
4 changed files with 10 additions and 22 deletions
pgpainless-cli
pgpainless-sop
|
@ -6,25 +6,6 @@ plugins {
|
||||||
id 'application'
|
id 'application'
|
||||||
id "com.github.johnrengelman.shadow" version "6.1.0"
|
id "com.github.johnrengelman.shadow" version "6.1.0"
|
||||||
}
|
}
|
||||||
def generatedVersionDir = "${buildDir}/generated-version"
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
output.dir(generatedVersionDir, builtBy: 'generateVersionProperties')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task generateVersionProperties {
|
|
||||||
doLast {
|
|
||||||
def propertiesFile = file "$generatedVersionDir/version.properties"
|
|
||||||
propertiesFile.parentFile.mkdirs()
|
|
||||||
propertiesFile.createNewFile()
|
|
||||||
// Instead of using a Properties object here, we directly write to the file
|
|
||||||
// since Properties adds a timestamp, ruining reproducibility
|
|
||||||
propertiesFile.write("version="+rootProject.version.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
processResources.dependsOn generateVersionProperties
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
import org.apache.tools.ant.filters.*
|
||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,12 @@ dependencies {
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
filter ReplaceTokens, tokens: [
|
||||||
|
"project.version": project.version.toString()
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
environment("test.implementation", "sop.testsuite.pgpainless.PGPainlessSopInstanceFactory")
|
environment("test.implementation", "sop.testsuite.pgpainless.PGPainlessSopInstanceFactory")
|
||||||
|
|
|
@ -49,11 +49,11 @@ https://www.bouncycastle.org/java.html"""
|
||||||
// See https://stackoverflow.com/a/50119235
|
// See https://stackoverflow.com/a/50119235
|
||||||
return try {
|
return try {
|
||||||
val resourceIn: InputStream =
|
val resourceIn: InputStream =
|
||||||
javaClass.getResourceAsStream("/version.properties")
|
javaClass.getResourceAsStream("/pgpainless-sop.properties")
|
||||||
?: throw IOException("File version.properties not found.")
|
?: throw IOException("File version.properties not found.")
|
||||||
|
|
||||||
val properties = Properties().apply { load(resourceIn) }
|
val properties = Properties().apply { load(resourceIn) }
|
||||||
properties.getProperty("version")
|
properties.getProperty("pgpainless-sop-version")
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
"DEVELOPMENT"
|
"DEVELOPMENT"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pgpainless-sop-version=@project.version@
|
Loading…
Reference in a new issue