Skip to content

Commit 501c28d

Browse files
committed
fix: make sure to use up-to-date version
when running `spotless --version`
1 parent 99a7a1e commit 501c28d

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ plugins {
1010
id 'buildlogic.java-graalvm-conventions'
1111
}
1212

13+
version = rootProject.version
14+
1315
dependencies {
1416
implementation 'org.apache.commons:commons-text'
1517
implementation project(':utilities')

build-logic/src/main/groovy/buildlogic.picocli-conventions.gradle

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,32 @@ compileJava {
1818
]
1919
}
2020

21-
tasks.withType(ProcessResources).configureEach(new ApplicationPropertiesProcessResourcesAction(project.version))
21+
tasks.withType(ProcessResources)
22+
.configureEach(new ApplicationPropertiesProcessResourcesAction(
23+
[
24+
"cli.version": rootProject.version
25+
]
26+
))
2227

2328
class ApplicationPropertiesProcessResourcesAction implements Action<ProcessResources> {
2429

25-
private final String cliVersion
30+
private final Map<String, String> properties = [:]
2631

27-
ApplicationPropertiesProcessResourcesAction(String cliVersion) {
28-
this.cliVersion = cliVersion
32+
ApplicationPropertiesProcessResourcesAction(Map<String, String> props) {
33+
this.properties.putAll(props)
2934
}
3035

3136
@Override
3237
void execute(ProcessResources processResources) {
33-
def localCliVersion = cliVersion // prevent issues with decorated closure
38+
def localProps = properties // prevent issues with decorated closure
39+
// make sure to rerun task if properties change
40+
processResources.inputs.properties(localProps)
41+
42+
// replace tokens in application.properties
3443
processResources.filesMatching("application.properties") {
3544
filter(
3645
org.apache.tools.ant.filters.ReplaceTokens,
37-
tokens: [
38-
'cli.version': localCliVersion
39-
]
46+
tokens: localProps
4047
)
4148
}
4249
}

0 commit comments

Comments
 (0)