mirror of
https://github.com/gradle/actions.git
synced 2025-12-08 17:15:46 +08:00
Fix Develocity deprecation warnings triggered by init-scripts
This commit is contained in:
@@ -80,13 +80,9 @@ def BUILD_SCAN_PLUGIN_CLASS = 'com.gradle.scan.plugin.BuildScanPlugin'
|
||||
|
||||
def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
|
||||
def GRADLE_ENTERPRISE_PLUGIN_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin'
|
||||
def GRADLE_ENTERPRISE_EXTENSION_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension'
|
||||
|
||||
def DEVELOCITY_PLUGIN_ID = 'com.gradle.develocity'
|
||||
def DEVELOCITY_PLUGIN_CLASS = 'com.gradle.develocity.agent.gradle.DevelocityPlugin'
|
||||
def DEVELOCITY_CONFIGURATION_CLASS = 'com.gradle.develocity.agent.gradle.DevelocityConfiguration'
|
||||
|
||||
def SETTINGS_EXTENSION_CLASSES = [GRADLE_ENTERPRISE_EXTENSION_CLASS, DEVELOCITY_CONFIGURATION_CLASS]
|
||||
|
||||
def CI_AUTO_INJECTION_CUSTOM_VALUE_NAME = 'CI auto injection'
|
||||
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'
|
||||
@@ -194,6 +190,8 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
||||
}
|
||||
|
||||
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
|
||||
// Only execute if develocity plugin isn't applied.
|
||||
if (gradle.rootProject.extensions.findByName("develocity")) return
|
||||
afterEvaluate {
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
buildScan.server = develocityUrl
|
||||
@@ -242,61 +240,64 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
||||
applyPluginExternally(settings.pluginManager, pluginClass)
|
||||
if (develocityUrl) {
|
||||
logger.lifecycle("Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
|
||||
eachDevelocitySettingsExtension(settings) { ext ->
|
||||
ext.server = develocityUrl
|
||||
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||
}
|
||||
}
|
||||
|
||||
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
|
||||
eachDevelocitySettingsExtension(settings) { ext ->
|
||||
ext.buildScan.uploadInBackground = buildScanUploadInBackground
|
||||
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, ciAutoInjectionCustomValueValue
|
||||
}
|
||||
|
||||
eachDevelocitySettingsExtension(settings, [GRADLE_ENTERPRISE_EXTENSION_CLASS]) { ext ->
|
||||
ext.buildScan.publishAlways()
|
||||
if (isAtLeast(develocityPluginVersion, '2.1')) {
|
||||
eachDevelocitySettingsExtension(settings,
|
||||
{ develocity ->
|
||||
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||
if (isAtLeast(develocityPluginVersion, '3.7')) {
|
||||
ext.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
||||
} else {
|
||||
ext.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
||||
develocity.buildScan.capture.fileFingerprints = develocityCaptureFileFingerprints
|
||||
},
|
||||
{ gradleEnterprise ->
|
||||
gradleEnterprise.buildScan.publishAlways()
|
||||
if (isAtLeast(develocityPluginVersion, '2.1')) {
|
||||
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||
if (isAtLeast(develocityPluginVersion, '3.7')) {
|
||||
gradleEnterprise.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
||||
} else {
|
||||
gradleEnterprise.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eachDevelocitySettingsExtension(settings, [DEVELOCITY_CONFIGURATION_CLASS]) { ext ->
|
||||
ext.buildScan.capture.fileFingerprints = develocityCaptureFileFingerprints
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
logger.lifecycle("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||
}
|
||||
|
||||
eachDevelocitySettingsExtension(settings, [GRADLE_ENTERPRISE_EXTENSION_CLASS]) { ext ->
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
ext.server = develocityUrl
|
||||
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||
}
|
||||
eachDevelocitySettingsExtension(settings,
|
||||
{ develocity ->
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
develocity.server = develocityUrl
|
||||
develocity.allowUntrustedServer = develocityAllowUntrustedServer
|
||||
}
|
||||
|
||||
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||
ext.buildScan.termsOfServiceUrl = buildScanTermsOfUseUrl
|
||||
ext.buildScan.termsOfServiceAgree = buildScanTermsOfUseAgree
|
||||
}
|
||||
}
|
||||
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||
develocity.buildScan.termsOfUseUrl = buildScanTermsOfUseUrl
|
||||
develocity.buildScan.termsOfUseAgree = buildScanTermsOfUseAgree
|
||||
}
|
||||
},
|
||||
{ gradleEnterprise ->
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
gradleEnterprise.server = develocityUrl
|
||||
gradleEnterprise.allowUntrustedServer = develocityAllowUntrustedServer
|
||||
}
|
||||
|
||||
eachDevelocitySettingsExtension(settings, [DEVELOCITY_CONFIGURATION_CLASS]) { ext ->
|
||||
if (develocityUrl && develocityEnforceUrl) {
|
||||
ext.server = develocityUrl
|
||||
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||
gradleEnterprise.buildScan.termsOfServiceUrl = buildScanTermsOfUseUrl
|
||||
gradleEnterprise.buildScan.termsOfServiceAgree = buildScanTermsOfUseAgree
|
||||
}
|
||||
}
|
||||
|
||||
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||
ext.buildScan.termsOfUseUrl = buildScanTermsOfUseUrl
|
||||
ext.buildScan.termsOfUseAgree = buildScanTermsOfUseAgree
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (ccudPluginVersion) {
|
||||
@@ -331,10 +332,26 @@ void applyPluginExternally(def pluginManager, String pluginClassName) {
|
||||
}
|
||||
}
|
||||
|
||||
static def eachDevelocitySettingsExtension(def settings, List<String> publicTypes, def action) {
|
||||
settings.extensions.extensionsSchema.elements.findAll { publicTypes.contains(it.publicType.concreteClass.name) }
|
||||
/**
|
||||
* Apply the `dvAction` to all 'develocity' extensions.
|
||||
* If no 'develocity' extensions are found, apply the `geAction` to all 'gradleEnterprise' extensions.
|
||||
* (The develocity plugin creates both extensions, and we want to prefer configuring 'develocity').
|
||||
*/
|
||||
static def eachDevelocitySettingsExtension(def settings, def dvAction, def geAction = dvAction) {
|
||||
def GRADLE_ENTERPRISE_EXTENSION_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension'
|
||||
def DEVELOCITY_CONFIGURATION_CLASS = 'com.gradle.develocity.agent.gradle.DevelocityConfiguration'
|
||||
|
||||
def dvExtensions = settings.extensions.extensionsSchema.elements
|
||||
.findAll { it.publicType.concreteClass.name == DEVELOCITY_CONFIGURATION_CLASS }
|
||||
.collect { settings[it.name] }
|
||||
if (!dvExtensions.empty) {
|
||||
dvExtensions.each(dvAction)
|
||||
} else {
|
||||
def geExtensions = settings.extensions.extensionsSchema.elements
|
||||
.findAll { it.publicType.concreteClass.name == GRADLE_ENTERPRISE_EXTENSION_CLASS }
|
||||
.collect { settings[it.name] }
|
||||
.each(action)
|
||||
geExtensions.each(geAction)
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isAtLeast(String versionUnderTest, String referenceVersion) {
|
||||
|
||||
Reference in New Issue
Block a user