@@ -10,11 +10,15 @@ initscript {
10
10
return
11
11
}
12
12
13
+ // the way this closure reads system properties means they are not tracked as inputs to the configuration cache model,
14
+ // the same is the case when reading environment variables with Gradle [6.5, 7.3]
13
15
def getInputParam = { String name ->
14
16
def envVarName = name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
15
- return System . getProperty( name) ?: System . getenv(envVarName)
17
+ return gradle . startParameter . systemPropertiesArgs[ name] ?: System . getenv(envVarName)
16
18
}
17
19
20
+ // the following local variables do not change between the build invocations of the same experiment run
21
+ // thus, reading their values in way that the configuration cache does not track them is acceptable
18
22
def pluginRepositoryUrl = getInputParam(' com.gradle.enterprise.build-validation.gradle.plugin-repository.url' )
19
23
def gePluginVersion = getInputParam(' com.gradle.enterprise.build-validation.gradle-enterprise.plugin.version' )
20
24
def ccudPluginVersion = getInputParam(' com.gradle.enterprise.build-validation.ccud.plugin.version' )
@@ -59,11 +63,15 @@ if (!isTopLevelBuild) {
59
63
return
60
64
}
61
65
66
+ // the way this closure reads system properties means they are not tracked as inputs to the configuration cache model,
67
+ // the same is the case when reading environment variables with Gradle [6.5, 7.3]
62
68
def getInputParam = { String name ->
63
69
def envVarName = name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
64
- return System . getProperty( name) ?: System . getenv(envVarName)
70
+ return gradle . startParameter . systemPropertiesArgs[ name] ?: System . getenv(envVarName)
65
71
}
66
72
73
+ // the following local variables do not change between the build invocations of the same experiment run
74
+ // thus, reading their values in way that the configuration cache does not track them is acceptable
67
75
def geUrl = getInputParam(' com.gradle.enterprise.build-validation.gradle-enterprise.url' )
68
76
def geAllowUntrustedServer = Boolean . parseBoolean(getInputParam(' com.gradle.enterprise.build-validation.gradle-enterprise.allow-untrusted-server' ))
69
77
def gePluginVersion = getInputParam(' com.gradle.enterprise.build-validation.gradle-enterprise.plugin.version' )
@@ -72,7 +80,6 @@ def ccudPluginVersion = getInputParam('com.gradle.enterprise.build-validation.cc
72
80
def expDir = getInputParam(' com.gradle.enterprise.build-validation.expDir' )
73
81
def expId = getInputParam(' com.gradle.enterprise.build-validation.expId' )
74
82
def runId = getInputParam(' com.gradle.enterprise.build-validation.runId' )
75
- def runNum = getInputParam(' com.gradle.enterprise.build-validation.runNum' )
76
83
def scriptsVersion = getInputParam(' com.gradle.enterprise.build-validation.scriptsVersion' )
77
84
78
85
def atLeastGradle4 = GradleVersion . current() >= GradleVersion . version(' 4.0' )
@@ -87,6 +94,15 @@ if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
87
94
def registerBuildScanActions = { def buildScan ->
88
95
def scanFile = new File (expDir, ' build-scans.csv' )
89
96
buildScan. buildScanPublished { publishedBuildScan ->
97
+ // defer reading the `runNum` system property until execution time since it does not affect
98
+ // the configuration of the build, and given its value changes between consecutive build invocations
99
+ // it would always invalidate the configuration cache model from the first build invocation
100
+ // in the second build invocation
101
+ def getRunNumInputParam = { String name ->
102
+ def envVarName = name. toUpperCase(). replace(' .' , ' _' ). replace(' -' , ' _' )
103
+ return System . getProperty(name) ?: System . getenv(envVarName)
104
+ }
105
+ def runNum = getRunNumInputParam(' com.gradle.enterprise.build-validation.runNum' )
90
106
def buildScanUri = publishedBuildScan. buildScanUri
91
107
def buildScanId = publishedBuildScan. buildScanId
92
108
def port = (buildScanUri. port != -1 ) ? ' :' + buildScanUri. port : ' '
0 commit comments