Skip to content

Commit

Permalink
Apply TOS agreement even if plugin is already applied
Browse files Browse the repository at this point in the history
Fixes #1044
  • Loading branch information
bigdaz committed Jan 25, 2024
1 parent 87a99e3 commit 803ee15
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer
} else if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
buildScan.publishAlways()
if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16
Expand All @@ -128,6 +125,11 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
}
}
}

if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
}

if (ccudPluginVersion && atLeastGradle4) {
Expand All @@ -147,14 +149,11 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
if (!settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) {
logger.quiet("Applying $DEVELOCITY_PLUGIN_CLASS via init script")
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) {
logger.quiet("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
} else if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
ext.buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
ext.buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
ext.buildScan.publishAlways()
ext.buildScan.uploadInBackground = buildScanUploadInBackground
Expand All @@ -163,12 +162,19 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
}

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")
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
}
}

if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
ext.buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
ext.buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
}
}
}

if (ccudPluginVersion) {
Expand All @@ -195,8 +201,9 @@ void applyPluginExternally(def pluginManager, String pluginClassName) {
}
}

static def extensionsWithPublicType(def container, String publicType) {
container.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
static def eachDevelocityExtension(def settings, def publicType, def action) {
settings.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
.collect { settings[it.name] }.each(action)
}

static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {
Expand Down

0 comments on commit 803ee15

Please sign in to comment.