Skip to content

Commit

Permalink
Create release plugin
Browse files Browse the repository at this point in the history
Fixes #28
  • Loading branch information
philipp94831 committed Mar 1, 2024
1 parent 0dd3437 commit 4fba9b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ReleasePlugin : Plugin<Project> {
apply(plugin = "net.researchgate.release")

val disablePushToRemote: String? = project.findProperty("disablePushToRemote") as? String
disablePushToRemote?.takeIf { it.toBoolean() }.apply {
if (disablePushToRemote?.toBoolean() == true) {
configure<ReleaseExtension> {
git {
pushToRemote.set(false)
Expand Down
17 changes: 9 additions & 8 deletions release/src/test/kotlin/com/bakdata/gradle/ReleasePluginTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ReleaseExtension>()?.git?.pushToRemote)
.isNull()
softly.assertThat(project.extensions.findByType<ReleaseExtension>()?.git?.pushToRemote?.get())
.isEqualTo("origin")
}
}

Expand All @@ -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<ReleaseExtension>()?.git?.pushToRemote)
.isEqualTo(false)
softly.assertThat(project.extensions.findByType<ReleaseExtension>()?.git?.pushToRemote?.get())
.isEqualTo("origin")
}
}

Expand All @@ -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<ReleaseExtension>()?.git?.pushToRemote)
.isNull()
softly.assertThat(project.extensions.findByType<ReleaseExtension>()?.git?.pushToRemote?.get())
.isEqualTo(false)
}
}

Expand Down

0 comments on commit 4fba9b9

Please sign in to comment.