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:
+26
@@ -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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -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
|
// Make Gradle check if the javaTask is up-to-date based on the Kotlin classes
|
||||||
javaTask.inputsCompatible.run {
|
javaTask.inputsCompatible.run {
|
||||||
if (isBuildCacheSupported()) {
|
if (isBuildCacheSupported()) {
|
||||||
dir(kotlinTask.destinationDir).withNormalizer(CompileClasspathNormalizer::class.java)
|
dir(kotlinTask.destinationDir)
|
||||||
|
.withNormalizer(CompileClasspathNormalizer::class.java)
|
||||||
|
.withPropertyName("${kotlinTask.name} output classes")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dirCompatible(kotlinTask.destinationDir)
|
dirCompatible(kotlinTask.destinationDir)
|
||||||
|
|||||||
Reference in New Issue
Block a user