11import org.gradle.util.GradleVersion
22import java.nio.charset.StandardCharsets
33
4- static getInputParam (String name ) {
4+ static getInputParam (Gradle gradle , String name ) {
55 def ENV_VAR_PREFIX = ' '
66 def envVarName = ENV_VAR_PREFIX + name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
7- return System . getProperty(name) ?: System . getenv(envVarName)
7+ return gradle . startParameter . systemPropertiesArgs[name] ?: System . getProperty(name) ?: System . getenv(envVarName)
88}
99
1010def isTopLevelBuild = ! gradle. parent
@@ -17,10 +17,10 @@ def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
1717def DEVELOCITY_PLUGIN_ID = ' com.gradle.develocity'
1818def CCUD_PLUGIN_ID = ' com.gradle.common-custom-user-data-gradle-plugin'
1919
20- def expDir = getInputParam(' develocity.build-validation.expDir' )
21- def expId = getInputParam(' develocity.build-validation.expId' )
22- def runId = getInputParam(' develocity.build-validation.runId' )
23- def scriptsVersion = getInputParam(' develocity.build-validation.scriptsVersion' )
20+ def expDir = getInputParam(gradle, ' develocity.build-validation.expDir' )
21+ def expId = getInputParam(gradle, ' develocity.build-validation.expId' )
22+ def runId = getInputParam(gradle, ' develocity.build-validation.runId' )
23+ def scriptsVersion = getInputParam(gradle, ' develocity.build-validation.scriptsVersion' )
2424
2525def atLeastGradle5 = GradleVersion . current() >= GradleVersion . version(' 5.0' )
2626
@@ -31,6 +31,11 @@ def registerBuildScanActions = { def buildScan, def rootProjectName ->
3131 // the configuration of the build, and given its value changes between consecutive build invocations
3232 // it would always invalidate the configuration cache model from the first build invocation
3333 // in the second build invocation
34+ //
35+ // System.getProperty can be used here because system properties can be read at *execution* time
36+ // safely for Gradle 7.0.2 and earlier, and we must do so anyway because referencing a Gradle
37+ // script object, e.g., 'gradle.startParameter', from a Groovy closure is not compatible with
38+ // configuration cache
3439 def getInputParam = { String name ->
3540 def ENV_VAR_PREFIX = ' '
3641 def envVarName = ENV_VAR_PREFIX + name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
0 commit comments