Skip to content

Commit

Permalink
Merge pull request #769 from gradle/erichaagdev/injection-script-sys-…
Browse files Browse the repository at this point in the history
…prop

Custom logic to transform common Develocity injection script is reverted
  • Loading branch information
erichaagdev authored Dec 11, 2024
2 parents d69ec7d + e6991c9 commit 0e68f4d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 43 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ val copyGradleScripts by tasks.registering(Sync::class) {
from(develocityInjectionResolvable) {
rename { "develocity-injection.gradle" }
into("lib/scripts/gradle-init-scripts")
filter(TransformDevelocityInjectionScript())
}
from(layout.projectDirectory.dir("components/scripts")) {
include("README.md")
Expand Down
27 changes: 0 additions & 27 deletions buildSrc/src/main/kotlin/TransformDevelocityInjectionScript.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import org.gradle.util.GradleVersion
import java.nio.charset.StandardCharsets

def getInputParam = { String name ->
static getInputParam(Gradle gradle, String name) {
def ENV_VAR_PREFIX = ''
def envVarName = ENV_VAR_PREFIX + name.toUpperCase().replace('.', '_').replace('-', '_')
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getProperty(name) ?: System.getenv(envVarName)
}

def isTopLevelBuild = !gradle.parent
Expand All @@ -17,10 +17,10 @@ def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
def DEVELOCITY_PLUGIN_ID = 'com.gradle.develocity'
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'

def expDir = getInputParam('develocity.build-validation.expDir')
def expId = getInputParam('develocity.build-validation.expId')
def runId = getInputParam('develocity.build-validation.runId')
def scriptsVersion = getInputParam('develocity.build-validation.scriptsVersion')
def expDir = getInputParam(gradle, 'develocity.build-validation.expDir')
def expId = getInputParam(gradle, 'develocity.build-validation.expId')
def runId = getInputParam(gradle, 'develocity.build-validation.runId')
def scriptsVersion = getInputParam(gradle, 'develocity.build-validation.scriptsVersion')

def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')

Expand All @@ -36,11 +36,12 @@ def registerBuildScanActions = { def buildScan, def rootProjectName ->
// safely for Gradle 7.0.2 and earlier, and we must do so anyway because referencing a Gradle
// script object, e.g., 'gradle.startParameter', from a Groovy closure is not compatible with
// configuration cache
def getRunNumInputParam = { String name ->
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
def getInputParam = { String name ->
def ENV_VAR_PREFIX = ''
def envVarName = ENV_VAR_PREFIX + name.toUpperCase().replace('.', '_').replace('-', '_')
return System.getProperty(name) ?: System.getenv(envVarName)
}
def runNum = getRunNumInputParam('develocity.build-validation.runNum')
def runNum = getInputParam('develocity.build-validation.runNum')
def buildScanUri = publishedBuildScan.buildScanUri
def buildScanId = publishedBuildScan.buildScanId
def port = (buildScanUri.port != -1) ? ':' + buildScanUri.port : ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def getInputParam = { String name ->
static getInputParam(Gradle gradle, String name) {
def ENV_VAR_PREFIX = ''
def envVarName = ENV_VAR_PREFIX + name.toUpperCase().replace('.', '_').replace('-', '_')
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getProperty(name) ?: System.getenv(envVarName)
}

def expDir = getInputParam('develocity.build-validation.expDir')
def expDir = getInputParam(gradle, 'develocity.build-validation.expDir')

settingsEvaluated { settings ->
settings.buildCache {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def getInputParam = { String name ->
static getInputParam(Gradle gradle, String name) {
def ENV_VAR_PREFIX = ''
def envVarName = ENV_VAR_PREFIX + name.toUpperCase().replace('.', '_').replace('-', '_')
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getenv(envVarName)
return gradle.startParameter.systemPropertiesArgs[name] ?: System.getProperty(name) ?: System.getenv(envVarName)
}

def remoteBuildCacheUrl = getInputParam('develocity.build-validation.remoteBuildCacheUrl')
def remoteBuildCacheUrl = getInputParam(gradle, 'develocity.build-validation.remoteBuildCacheUrl')

settingsEvaluated { settings ->
settings.buildCache {
Expand Down

0 comments on commit 0e68f4d

Please sign in to comment.