diff --git a/release/src/main/kotlin/com/bakdata/gradle/ReleasePlugin.kt b/release/src/main/kotlin/com/bakdata/gradle/ReleasePlugin.kt index 89ee023..154e1af 100644 --- a/release/src/main/kotlin/com/bakdata/gradle/ReleasePlugin.kt +++ b/release/src/main/kotlin/com/bakdata/gradle/ReleasePlugin.kt @@ -42,7 +42,7 @@ class ReleasePlugin : Plugin { apply(plugin = "net.researchgate.release") val disablePushToRemote: String? = project.findProperty("disablePushToRemote") as? String - disablePushToRemote?.takeIf { it.toBoolean() }.apply { + if (disablePushToRemote?.toBoolean() == true) { configure { git { pushToRemote.set(false) diff --git a/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt b/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt index dfc38fb..5c8aabf 100644 --- a/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt +++ b/release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt @@ -32,6 +32,7 @@ import org.assertj.core.api.Condition import org.assertj.core.api.SoftAssertions import org.gradle.api.Project import org.gradle.api.internal.project.DefaultProject +import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.findByType import org.gradle.testfixtures.ProjectBuilder import org.junit.jupiter.api.Test @@ -54,8 +55,8 @@ internal class ReleasePluginTest { SoftAssertions.assertSoftly { softly -> softly.assertThat(project.plugins) .haveExactly(1, Condition({ it is ReleasePlugin }, "Has release plugin")) - softly.assertThat(project.extensions.findByType()?.git?.pushToRemote) - .isNull() + softly.assertThat(project.extensions.findByType()?.git?.pushToRemote?.get()) + .isEqualTo("origin") } } @@ -64,16 +65,16 @@ internal class ReleasePluginTest { val project = ProjectBuilder.builder().build() assertThatCode { + project.extra.set("disablePushToRemote", "false") project.pluginManager.apply("com.bakdata.release") - project.setProperty("disablePushToRemote", "true") project.evaluate() }.doesNotThrowAnyException() SoftAssertions.assertSoftly { softly -> softly.assertThat(project.plugins) .haveExactly(1, Condition({ it is ReleasePlugin }, "Has release plugin")) - softly.assertThat(project.extensions.findByType()?.git?.pushToRemote) - .isEqualTo(false) + softly.assertThat(project.extensions.findByType()?.git?.pushToRemote?.get()) + .isEqualTo("origin") } } @@ -82,16 +83,16 @@ internal class ReleasePluginTest { val project = ProjectBuilder.builder().build() assertThatCode { + project.extra.set("disablePushToRemote", "true") project.pluginManager.apply("com.bakdata.release") - project.setProperty("disablePushToRemote", "true") project.evaluate() }.doesNotThrowAnyException() SoftAssertions.assertSoftly { softly -> softly.assertThat(project.plugins) .haveExactly(1, Condition({ it is ReleasePlugin }, "Has release plugin")) - softly.assertThat(project.extensions.findByType()?.git?.pushToRemote) - .isNull() + softly.assertThat(project.extensions.findByType()?.git?.pushToRemote?.get()) + .isEqualTo(false) } }