Deal with unnamed Gradle inputs/outputs

Fix the only unnamed input added to a Gradle task at runtime.
Add a test that checks for unnamed task inputs.

Issue #KT-23085 Fixed
This commit is contained in:
Sergey Igushkin
2018-03-12 21:54:03 +03:00
parent 97700316f5
commit 07b811460a
2 changed files with 29 additions and 1 deletions
@@ -729,4 +729,30 @@ class KotlinGradleIT: BaseGradleIT() {
}
}
}
@Test
fun testNoUnnamedInputsOutputs() {
// Use a new Gradle version to enable the usage of the input/output builders, which are new API:
val gradleVersionRequirement = GradleVersionRequired.AtLeast("4.4")
val projects = listOf(
Project("simpleProject", gradleVersionRequirement),
Project("kotlin2JsProject", gradleVersionRequirement),
Project("multiplatformProject", gradleVersionRequirement),
Project("simple", gradleVersionRequirement, "kapt2")
)
projects.forEach {
it.apply {
// Enable caching to make sure Gradle reports the task inputs/outputs during key construction:
val options = defaultBuildOptions().copy(withBuildCache = true)
build("assemble", options = options) {
// Check that all inputs/outputs added at runtime have proper names
// (the unnamed ones are listed as $1, $2 etc.):
assertNotContains("Appending inputPropertyHash for '\\$\\d+'".toRegex())
assertNotContains("Appending outputPropertyName to build cache key: \\$\\d+".toRegex())
}
}
}
}
}
@@ -690,7 +690,9 @@ internal fun configureJavaTask(kotlinTask: KotlinCompile, javaTask: AbstractComp
// Make Gradle check if the javaTask is up-to-date based on the Kotlin classes
javaTask.inputsCompatible.run {
if (isBuildCacheSupported()) {
dir(kotlinTask.destinationDir).withNormalizer(CompileClasspathNormalizer::class.java)
dir(kotlinTask.destinationDir)
.withNormalizer(CompileClasspathNormalizer::class.java)
.withPropertyName("${kotlinTask.name} output classes")
}
else {
dirCompatible(kotlinTask.destinationDir)