diff --git a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/main/kotlin/dev/sigstore/sign/SigstoreSignExtension.kt b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/main/kotlin/dev/sigstore/sign/SigstoreSignExtension.kt index 22fd84b7..e2fb43fc 100644 --- a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/main/kotlin/dev/sigstore/sign/SigstoreSignExtension.kt +++ b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/main/kotlin/dev/sigstore/sign/SigstoreSignExtension.kt @@ -84,7 +84,7 @@ abstract class SigstoreSignExtension(private val project: Project) { } val removeSigstoreAsc = - project.findProperty("dev.sigstore.sign.remove.sigstore.json.asc")?.toString()?.toBoolean() != false + project.providers.gradleProperty("dev.sigstore.sign.remove.sigstore.json.asc").orNull?.toBoolean() != false val publicationName = publication.name diff --git a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/OidcDslTest.kt b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/OidcDslTest.kt index 0a183c3c..0567fd4c 100644 --- a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/OidcDslTest.kt +++ b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/OidcDslTest.kt @@ -46,6 +46,7 @@ class OidcDslTest: BaseGradleTest() { """.trimIndent() ) enableConfigurationCache(gradle) + enableProjectIsolation(gradle) prepare(gradle.version, "printConfig", "-s") .build() } diff --git a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/SigstoreSignTest.kt b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/SigstoreSignTest.kt index 77978f96..e7eb9299 100644 --- a/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/SigstoreSignTest.kt +++ b/sigstore-gradle/sigstore-gradle-sign-base-plugin/src/test/kotlin/dev/sigstore/gradle/SigstoreSignTest.kt @@ -55,6 +55,7 @@ class SigstoreSignTest: BaseGradleTest() { """.trimIndent() ) enableConfigurationCache(case.gradle) + enableProjectIsolation(case.gradle) prepare(case.gradle.version, "signFile", "-s") .build() assertThat(projectDir.resolve("build/helloProps.txt.sigstore.json")) diff --git a/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/RemoveSigstoreAscTest.kt b/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/RemoveSigstoreAscTest.kt index bb648c53..b63b51fd 100644 --- a/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/RemoveSigstoreAscTest.kt +++ b/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/RemoveSigstoreAscTest.kt @@ -41,7 +41,7 @@ class RemoveSigstoreAscTest : BaseGradleTest() { // Gradle < 8.1 + configuration cache=on which is incompatible with signing plugin. listOf( TestedGradleAndSigstoreJava( - TestedGradle(GradleVersion.version("8.1"), ConfigurationCache.OFF), + TestedGradle(GradleVersion.version("8.1"), ConfigurationCache.OFF, ProjectIsolation.OFF), SIGSTORE_JAVA_CURRENT_VERSION ) ) @@ -147,6 +147,7 @@ class RemoveSigstoreAscTest : BaseGradleTest() { """.trimIndent() ) enableConfigurationCache(case.gradle) + enableProjectIsolation(case.gradle) } private fun SoftAssertions.assertSignatures(name: String, expectSigstoreAsc: Boolean = false) { diff --git a/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/SigstorePublishSignTest.kt b/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/SigstorePublishSignTest.kt index d6552cb5..85597c69 100644 --- a/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/SigstorePublishSignTest.kt +++ b/sigstore-gradle/sigstore-gradle-sign-plugin/src/test/kotlin/dev/sigstore/gradle/SigstorePublishSignTest.kt @@ -65,6 +65,7 @@ class SigstorePublishSignTest : BaseGradleTest() { """.trimIndent() ) enableConfigurationCache(case.gradle) + enableProjectIsolation(case.gradle) prepare(case.gradle.version, "publishAllPublicationsToTmpRepository", "-s") .build() diff --git a/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/BaseGradleTest.kt b/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/BaseGradleTest.kt index b761b1d2..06781f27 100644 --- a/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/BaseGradleTest.kt +++ b/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/BaseGradleTest.kt @@ -29,11 +29,15 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.Arguments.arguments import java.io.File import java.nio.file.Path +import kotlin.io.path.appendText open class BaseGradleTest { enum class ConfigurationCache { ON, OFF } + enum class ProjectIsolation { + ON, OFF + } // to debug these tests, add .withDebug(true) before running a test in debug mode protected val gradleRunner = GradleRunner.create().withPluginClasspath() @@ -63,16 +67,16 @@ open class BaseGradleTest { if (!isCI) { // Execute a single combination only when running locally return listOf( - TestedGradle(gradleVersions().first(), ConfigurationCache.ON) + TestedGradle(gradleVersions().first(), ConfigurationCache.ON, ProjectIsolation.ON) ) } return buildList { addAll( - gradleVersions().map { TestedGradle(it, ConfigurationCache.ON) } + gradleVersions().map { TestedGradle(it, ConfigurationCache.ON, ProjectIsolation.ON) } ) // Test the first and the last version without configuration cache - add(TestedGradle(gradleVersions().first(), ConfigurationCache.OFF)) - add(TestedGradle(gradleVersions().last(), ConfigurationCache.OFF)) + add(TestedGradle(gradleVersions().first(), ConfigurationCache.OFF, ProjectIsolation.OFF)) + add(TestedGradle(gradleVersions().last(), ConfigurationCache.OFF, ProjectIsolation.OFF)) } } @@ -202,6 +206,23 @@ open class BaseGradleTest { ) } + protected fun enableProjectIsolation( + gradle: TestedGradle, + ) { + if (gradle.projectIsolation != ProjectIsolation.ON) { + return + } + require(gradle.configurationCache == ConfigurationCache.ON) { + "Project isolation requires Configuration Cache." + } + projectDir.resolve("gradle.properties").appendText( + """ + + org.gradle.unsafe.isolated-projects=true + """.trimIndent() + ) + } + protected fun assertSoftly(body: SoftAssertions.() -> Unit) = SoftAssertions.assertSoftly(body) diff --git a/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/TestedGradle.kt b/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/TestedGradle.kt index b6ee684b..8990fae7 100644 --- a/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/TestedGradle.kt +++ b/sigstore-testkit/src/main/kotlin/dev/sigstore/testkit/TestedGradle.kt @@ -23,5 +23,6 @@ import org.gradle.util.GradleVersion */ data class TestedGradle( val version: GradleVersion, - val configurationCache: BaseGradleTest.ConfigurationCache + val configurationCache: BaseGradleTest.ConfigurationCache, + val projectIsolation: BaseGradleTest.ProjectIsolation, )