1
1
import org.gradle.util.GradleVersion
2
2
import java.nio.charset.StandardCharsets
3
3
4
- static getInputParam (String name ) {
4
+ static getInputParam (Gradle gradle , String name ) {
5
5
def ENV_VAR_PREFIX = ' '
6
6
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)
8
8
}
9
9
10
10
def isTopLevelBuild = ! gradle. parent
@@ -17,10 +17,10 @@ def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
17
17
def DEVELOCITY_PLUGIN_ID = ' com.gradle.develocity'
18
18
def CCUD_PLUGIN_ID = ' com.gradle.common-custom-user-data-gradle-plugin'
19
19
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' )
24
24
25
25
def atLeastGradle5 = GradleVersion . current() >= GradleVersion . version(' 5.0' )
26
26
@@ -31,6 +31,11 @@ def registerBuildScanActions = { def buildScan, def rootProjectName ->
31
31
// the configuration of the build, and given its value changes between consecutive build invocations
32
32
// it would always invalidate the configuration cache model from the first build invocation
33
33
// 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
34
39
def getInputParam = { String name ->
35
40
def ENV_VAR_PREFIX = ' '
36
41
def envVarName = ENV_VAR_PREFIX + name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
0 commit comments