Skip to content

Commit f00d365

Browse files
committed
Detect toolchainVersion when it is set in gradle.properties
Closes gh-100
1 parent d81ba93 commit f00d365

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The build scans will be customized to:
2828
- Add tags:
2929
- `JDK-<version>`.
3030
When using Maven, `<version>` is the specification version of the JDK running the build.
31-
When using Gradle, `<version>` is the value of the `toolchainVersion` project property or, when not set, it's the specification version of the JDK running the build.
31+
When using Gradle, `<version>` is the value of the `toolchainVersion` property or, when not set, it's the specification version of the JDK running the build.
3232
- `CI` or `Local` depending on where the build is executing.
3333
- `dirty` if the git working copy is dirty.
3434
- Name of the git branch being built.

develocity-conventions-gradle-plugin/src/main/java/io/spring/develocity/conventions/gradle/DevelocityConventionsPlugin.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.gradle.api.Plugin;
3535
import org.gradle.api.initialization.Settings;
3636
import org.gradle.api.internal.ProcessOperations;
37+
import org.gradle.api.provider.Provider;
3738

3839
/**
3940
* {@link Plugin plugin} for configuring the use of Develocity hosted at
@@ -60,8 +61,7 @@ public void apply(Settings settings) {
6061
return;
6162
}
6263
if (isBuildScanEnabled(settings)) {
63-
configureBuildScanConventions(extension, extension.getBuildScan(), settings.getStartParameter(),
64-
settings.getRootDir());
64+
configureBuildScanConventions(extension, extension.getBuildScan(), settings);
6565
}
6666
if (settings.getStartParameter().isBuildCacheEnabled()) {
6767
settings.buildCache((buildCacheConfiguration) -> new BuildCacheConventions()
@@ -99,16 +99,16 @@ private boolean containsPropertiesTask(StartParameter startParameter) {
9999
}
100100

101101
private void configureBuildScanConventions(DevelocityConfiguration develocity, BuildScanConfiguration buildScan,
102-
StartParameter startParameter, File rootDir) {
102+
Settings settings) {
103+
Provider<String> toolchainVersion = settings.getProviders().gradleProperty("toolchainVersion");
103104
ProcessOperationsProcessRunner processRunner = new ProcessOperationsProcessRunner(
104-
new WorkingDirectoryProcessOperations(this.processOperations, rootDir));
105-
if (startParameter.isBuildScan()) {
105+
new WorkingDirectoryProcessOperations(this.processOperations, settings.getRootDir()));
106+
if (settings.getStartParameter().isBuildScan()) {
106107
new AnonymousPublicationBuildScanConventions(processRunner) {
107108

108109
@Override
109110
protected String getJdkVersion() {
110-
String toolchainVersion = startParameter.getProjectProperties().get("toolchainVersion");
111-
return (toolchainVersion != null) ? toolchainVersion : super.getJdkVersion();
111+
return toolchainVersion.getOrElse(super.getJdkVersion());
112112
}
113113

114114
}.execute(new GradleConfigurableDevelocity(develocity), new GradleConfigurableBuildScan(buildScan));
@@ -118,8 +118,7 @@ protected String getJdkVersion() {
118118

119119
@Override
120120
protected String getJdkVersion() {
121-
String toolchainVersion = startParameter.getProjectProperties().get("toolchainVersion");
122-
return (toolchainVersion != null) ? toolchainVersion : super.getJdkVersion();
121+
return toolchainVersion.getOrElse(super.getJdkVersion());
123122
}
124123

125124
}.execute(new GradleConfigurableDevelocity(develocity), new GradleConfigurableBuildScan(buildScan));

0 commit comments

Comments
 (0)