Log property overrides once for both extensions

This commit is contained in:
Pavlo Shevchenko 2024-02-08 14:01:38 +01:00
parent e8310b38da
commit 28edd504af
No known key found for this signature in database
GPG Key ID: A52E2C6DAD8A5DDC
2 changed files with 10 additions and 10 deletions

View File

@ -147,16 +147,15 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
}
if (develocityUrl && develocityEnforceUrl) {
logger.quiet("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer for Build Scan plugin")
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
afterEvaluate {
logger.quiet("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer for Build Scan plugin")
buildScan.server = develocityUrl
buildScan.allowUntrustedServer = develocityAllowUntrustedServer
}
}
pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) {
afterEvaluate {
logger.quiet("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer for Develocity plugin")
develocity.server = develocityUrl
develocity.allowUntrustedServer = develocityAllowUntrustedServer
}
@ -190,12 +189,15 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
def pluginClass = dvOrGe(DEVELOCITY_PLUGIN_CLASS, GRADLE_ENTERPRISE_PLUGIN_CLASS)
logger.quiet("Applying $pluginClass via init script")
applyPluginExternally(settings.pluginManager, pluginClass)
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
if (develocityUrl) {
logger.quiet("Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer")
if (develocityUrl) {
logger.quiet("Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer")
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
ext.server = develocityUrl
ext.allowUntrustedServer = develocityAllowUntrustedServer
}
}
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
if (!shouldApplyDevelocityPlugin) {
// Develocity plugin publishes build scans by default
ext.buildScan.publishAlways()
@ -206,8 +208,8 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
}
if (develocityUrl && develocityEnforceUrl) {
logger.quiet("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer")
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
logger.quiet("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer")
ext.server = develocityUrl
ext.allowUntrustedServer = develocityAllowUntrustedServer
}

View File

@ -310,8 +310,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
void outputContainsDevelocityConnectionInfo(BuildResult result, String develocityUrl, boolean develocityAllowUntrustedServer) {
def develocityConnectionInfo = "Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer"
assert result.output.contains(develocityConnectionInfo)
// Develocity plugin configures both the deprecated and new extensions
assert 2 == result.output.count(develocityConnectionInfo)
assert 1 == result.output.count(develocityConnectionInfo)
}
void outputContainsPluginRepositoryInfo(BuildResult result, String gradlePluginRepositoryUrl) {
@ -323,8 +322,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
void outputEnforcesDevelocityUrl(BuildResult result, String develocityUrl, boolean develocityAllowUntrustedServer) {
def enforceUrl = "Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer"
assert result.output.contains(enforceUrl)
// Develocity plugin configures both the deprecated and new extensions
assert 2 == result.output.count(enforceUrl)
assert 1 == result.output.count(enforceUrl)
}
private BuildResult run(TestGradleVersion testGradleVersion, TestConfig config, List<String> args = ["help"]) {