Skip to content

Commit

Permalink
Fix version reported when injecting in Gradle 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Nov 8, 2024
1 parent 343d9ff commit 4778149
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/develocity-injection.init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void enableDevelocityInjection() {
}
if (!scanPluginComponent) {
def pluginClass = dvOrGe(DEVELOCITY_PLUGIN_CLASS, BUILD_SCAN_PLUGIN_CLASS)
def pluginVersion = dvOrGe(develocityPluginVersion, "1.16")
def pluginVersion = atLeastGradle5 ? develocityPluginVersion : "1.16"
applyPluginExternally(pluginManager, pluginClass, pluginVersion)
def rootExtension = dvOrGe(
{ develocity },
Expand Down
8 changes: 7 additions & 1 deletion src/test/groovy/com/gradle/TestDevelocityInjection.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,22 @@ class TestDevelocityInjection extends BaseInitScriptTest {

void outputContainsDevelocityPluginApplicationViaInitScript(BuildResult result, GradleVersion gradleVersion, String pluginVersion = DEVELOCITY_PLUGIN_VERSION) {
def pluginApplicationLogMsgGradle4 = "Applying com.gradle.scan.plugin.BuildScanPlugin with version 1.16 via init script"
def pluginApplicationLogMsgBuildScanPlugin = "Applying com.gradle.scan.plugin.BuildScanPlugin with version ${pluginVersion} via init script"
def pluginApplicationLogMsgGEPlugin = "Applying com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin with version ${pluginVersion} via init script"
def pluginApplicationLogMsgDVPlugin = "Applying com.gradle.develocity.agent.gradle.DevelocityPlugin with version ${pluginVersion} via init script"

def isGEPluginVersion = GradleVersion.version(pluginVersion) < GradleVersion.version("3.17")

if (gradleVersion < GRADLE_5 || (gradleVersion < GRADLE_6 && isGEPluginVersion)) {
if (gradleVersion < GRADLE_5) {
assert result.output.contains(pluginApplicationLogMsgGradle4)
assert 1 == result.output.count(pluginApplicationLogMsgGradle4)
assert !result.output.contains(pluginApplicationLogMsgGEPlugin)
assert !result.output.contains(pluginApplicationLogMsgDVPlugin)
} else if (gradleVersion < GRADLE_6 && isGEPluginVersion) {
assert result.output.contains(pluginApplicationLogMsgBuildScanPlugin)
assert 1 == result.output.count(pluginApplicationLogMsgBuildScanPlugin)
assert !result.output.contains(pluginApplicationLogMsgGEPlugin)
assert !result.output.contains(pluginApplicationLogMsgDVPlugin)
} else if (isGEPluginVersion) {
assert result.output.contains(pluginApplicationLogMsgGEPlugin)
assert 1 == result.output.count(pluginApplicationLogMsgGEPlugin)
Expand Down

0 comments on commit 4778149

Please sign in to comment.