Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object BuildServices {
): ScriptCache {

val hasBuildCacheIntegration =
startParameters.isBuildCacheEnabled && startParameters.isKotlinDslBuildCacheEnabled
startParameters.isBuildCacheEnabled && isKotlinDslBuildCacheEnabled

return ScriptCache(
cacheRepository,
Expand All @@ -46,5 +46,5 @@ object BuildServices {


private
val StartParameter.isKotlinDslBuildCacheEnabled: Boolean
get() = projectProperties.getOrDefault("org.gradle.kotlin.dsl.caching.buildcache", null) == "true"
val isKotlinDslBuildCacheEnabled: Boolean
get() = System.getProperty("org.gradle.kotlin.dsl.caching.buildcache", null) == "true"
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ abstract class AbstractScriptCachingIntegrationTest : AbstractIntegrationTest()

protected
fun buildWithUniqueGradleHome(vararg arguments: String): BuildResult =
buildForCacheInspection("-g", uniqueGradleHome(), *arguments)
buildWithGradleHome(uniqueGradleHome(), *arguments)

protected
fun buildWithGradleHome(gradleHomePath: String, vararg arguments: String) =
buildForCacheInspection("-g", gradleHomePath, *arguments)

protected
fun <T> withUniqueGradleHome(f: (String) -> T): T =
f(uniqueGradleHome())

private
fun uniqueGradleHome() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BuildCacheIntegrationTest : AbstractScriptCachingIntegrationTest() {

@LeaksFileHandles("on the separate Gradle homes")
@Test
fun `build cache integration is enabled via project property`() {
fun `build cache integration is enabled via system property`() {

val buildCacheDir =
existing("build-cache")
Expand Down Expand Up @@ -91,15 +91,22 @@ class BuildCacheIntegrationTest : AbstractScriptCachingIntegrationTest() {
assertThat(output, containsString(expectedOutput))
}

// Cache hit from build cache
buildWithUniqueGradleHome("--build-cache", withBuildCacheIntegration).apply {
// Cache hit from build cache (enabled via gradle.properties file)
withUniqueGradleHome { gradleHome ->

compilationCache {
misses(cachedSettingsFile)
hits(cachedBuildFile)
}
File(gradleHome, "gradle.properties").writeText(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradleHome.resolve("gradle.properties")?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradleHome is a String

"systemProp.$kotlinDslBuildCacheEnabled"
)

assertThat(output, containsString(expectedOutput))
buildWithGradleHome(gradleHome, "--build-cache").apply {

compilationCache {
misses(cachedSettingsFile)
hits(cachedBuildFile)
}

assertThat(output, containsString(expectedOutput))
}
}

// Cache miss without build cache integration
Expand All @@ -115,7 +122,10 @@ class BuildCacheIntegrationTest : AbstractScriptCachingIntegrationTest() {
}

private
val withBuildCacheIntegration = "-Porg.gradle.kotlin.dsl.caching.buildcache=true"
val kotlinDslBuildCacheEnabled = "org.gradle.kotlin.dsl.caching.buildcache=true"

private
val withBuildCacheIntegration = "-D$kotlinDslBuildCacheEnabled"

private
fun withLocalBuildCacheSettings(buildCacheDir: File): File =
Expand Down