Skip to content

Commit fddc75f

Browse files
committed
Add clarifying comments
1 parent f747762 commit fddc75f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

components/scripts/gradle/gradle-init-scripts/configure-gradle-enterprise.gradle

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ initscript {
1010
return
1111
}
1212

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]
1315
def getInputParam = { String name ->
1416
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
1517
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
1618
}
1719

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
1822
def pluginRepositoryUrl = getInputParam('com.gradle.enterprise.build-validation.gradle.plugin-repository.url')
1923
def gePluginVersion = getInputParam('com.gradle.enterprise.build-validation.gradle-enterprise.plugin.version')
2024
def ccudPluginVersion = getInputParam('com.gradle.enterprise.build-validation.ccud.plugin.version')
@@ -59,11 +63,15 @@ if (!isTopLevelBuild) {
5963
return
6064
}
6165

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]
6268
def getInputParam = { String name ->
6369
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
6470
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
6571
}
6672

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
6775
def geUrl = getInputParam('com.gradle.enterprise.build-validation.gradle-enterprise.url')
6876
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('com.gradle.enterprise.build-validation.gradle-enterprise.allow-untrusted-server'))
6977
def gePluginVersion = getInputParam('com.gradle.enterprise.build-validation.gradle-enterprise.plugin.version')
@@ -86,11 +94,15 @@ if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
8694
def registerBuildScanActions = { def buildScan ->
8795
def scanFile = new File(expDir, 'build-scans.csv')
8896
buildScan.buildScanPublished { publishedBuildScan ->
89-
def getInputParamCompatibleWithCC = { String name ->
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 ->
90102
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
91103
return System.getProperty(name) ?: System.getenv(envVarName)
92104
}
93-
def runNum = getInputParamCompatibleWithCC('com.gradle.enterprise.build-validation.runNum')
105+
def runNum = getRunNumInputParam('com.gradle.enterprise.build-validation.runNum')
94106
def buildScanUri = publishedBuildScan.buildScanUri
95107
def buildScanId = publishedBuildScan.buildScanId
96108
def port = (buildScanUri.port != -1) ? ':' + buildScanUri.port : ''

components/scripts/gradle/gradle-init-scripts/configure-local-build-caching.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ if (!isTopLevelBuild) {
33
return
44
}
55

6+
// the way this closure reads system properties means they are not tracked as inputs to the configuration cache model,
7+
// the same is the case when reading environment variables with Gradle [6.5, 7.3]
68
def getInputParam = { String name ->
79
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
810
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
911
}
1012

13+
// the following local variable does not change between the build invocations of the same experiment run
14+
// thus, reading its value in way that the configuration cache does not track it is acceptable
1115
def expDir = getInputParam('com.gradle.enterprise.build-validation.expDir')
1216

1317
settingsEvaluated { settings ->

components/scripts/gradle/gradle-init-scripts/configure-remote-build-caching.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ if (!isTopLevelBuild) {
33
return
44
}
55

6+
// the way this closure reads system properties means they are not tracked as inputs to the configuration cache model,
7+
// the same is the case when reading environment variables with Gradle [6.5, 7.3]
68
def getInputParam = { String name ->
79
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
810
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
911
}
1012

13+
// the following local variable does not change between the build invocations of the same experiment run
14+
// thus, reading its value in way that the configuration cache does not track it is acceptable
1115
def remoteBuildCacheUrl = getInputParam('com.gradle.enterprise.build-validation.remoteBuildCacheUrl')
1216

1317
settingsEvaluated { settings ->

0 commit comments

Comments
 (0)