Apply TOS agreement even if plugin is already applied

Fixes #1044
This commit is contained in:
daz 2024-01-24 16:26:29 -07:00
parent 4062866f05
commit 90d7c1a069
No known key found for this signature in database

View File

@ -110,9 +110,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer") logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
buildScan.server = geUrl buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer buildScan.allowUntrustedServer = geAllowUntrustedServer
} else if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
} }
buildScan.publishAlways() buildScan.publishAlways()
if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16 if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16
@ -128,6 +125,11 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
} }
} }
} }
if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
} }
if (ccudPluginVersion && atLeastGradle4) { if (ccudPluginVersion && atLeastGradle4) {
@ -147,14 +149,11 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
if (!settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) { if (!settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) {
logger.quiet("Applying $DEVELOCITY_PLUGIN_CLASS via init script") logger.quiet("Applying $DEVELOCITY_PLUGIN_CLASS via init script")
applyPluginExternally(settings.pluginManager, DEVELOCITY_PLUGIN_CLASS) applyPluginExternally(settings.pluginManager, DEVELOCITY_PLUGIN_CLASS)
extensionsWithPublicType(settings, DEVELOCITY_EXTENSION_CLASS).collect { settings[it.name] }.each { ext -> eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
if (geUrl) { if (geUrl) {
logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer") logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer ext.allowUntrustedServer = geAllowUntrustedServer
} else if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
ext.buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
ext.buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
} }
ext.buildScan.publishAlways() ext.buildScan.publishAlways()
ext.buildScan.uploadInBackground = buildScanUploadInBackground ext.buildScan.uploadInBackground = buildScanUploadInBackground
@ -163,12 +162,19 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
} }
if (geUrl && geEnforceUrl) { if (geUrl && geEnforceUrl) {
extensionsWithPublicType(settings, DEVELOCITY_EXTENSION_CLASS).collect { settings[it.name] }.each { ext -> eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
logger.quiet("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer") logger.quiet("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer ext.allowUntrustedServer = geAllowUntrustedServer
} }
} }
if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
ext.buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
ext.buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
}
} }
if (ccudPluginVersion) { if (ccudPluginVersion) {
@ -195,8 +201,9 @@ void applyPluginExternally(def pluginManager, String pluginClassName) {
} }
} }
static def extensionsWithPublicType(def container, String publicType) { static def eachDevelocityExtension(def settings, def publicType, def action) {
container.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType } settings.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
.collect { settings[it.name] }.each(action)
} }
static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) { static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {