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

View File

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