Add a test for the opt-out flag for disabling separate classes directory
(cherry picked from commit 393966d)
This commit is contained in:
+63
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle
|
|||||||
|
|
||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
|
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus
|
||||||
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
||||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||||
@@ -596,4 +597,66 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
"my/pack/name/util/JUtil.util")
|
"my/pack/name/util/JUtil.util")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDisableSeparateClassesDirs() {
|
||||||
|
val separateDirPath = "build/classes/kotlin/main/demo/KotlinGreetingJoiner.class"
|
||||||
|
val singleDirPath = "build/classes/java/main/demo/KotlinGreetingJoiner.class"
|
||||||
|
|
||||||
|
fun CompiledProject.check(copyClassesToJavaOutput: Boolean?,
|
||||||
|
expectBuildCacheWarning: Boolean,
|
||||||
|
expectGradleLowVersionWarning: Boolean) {
|
||||||
|
assertSuccessful()
|
||||||
|
when (copyClassesToJavaOutput) {
|
||||||
|
true -> {
|
||||||
|
assertNoSuchFile(separateDirPath)
|
||||||
|
assertFileExists(singleDirPath)
|
||||||
|
}
|
||||||
|
false -> {
|
||||||
|
assertFileExists(separateDirPath)
|
||||||
|
assertNoSuchFile(singleDirPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectBuildCacheWarning)
|
||||||
|
assertContains(CopyClassesToJavaOutputStatus.buildCacheWarningMessage)
|
||||||
|
else
|
||||||
|
assertNotContains(CopyClassesToJavaOutputStatus.buildCacheWarningMessage)
|
||||||
|
|
||||||
|
if (expectGradleLowVersionWarning)
|
||||||
|
assertContains(CopyClassesToJavaOutputStatus.gradleVersionTooLowWarningMessage)
|
||||||
|
else
|
||||||
|
assertNotContains(CopyClassesToJavaOutputStatus.gradleVersionTooLowWarningMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
Project("simpleProject", "4.0").apply {
|
||||||
|
build("build") {
|
||||||
|
check(copyClassesToJavaOutput = false,
|
||||||
|
expectBuildCacheWarning = false,
|
||||||
|
expectGradleLowVersionWarning = false)
|
||||||
|
}
|
||||||
|
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
||||||
|
build("clean", "build") {
|
||||||
|
check(copyClassesToJavaOutput = true,
|
||||||
|
expectBuildCacheWarning = false,
|
||||||
|
expectGradleLowVersionWarning = false)
|
||||||
|
}
|
||||||
|
build("clean", "build", "--build-cache") {
|
||||||
|
check(copyClassesToJavaOutput = true,
|
||||||
|
expectBuildCacheWarning = true,
|
||||||
|
expectGradleLowVersionWarning = false)
|
||||||
|
}
|
||||||
|
projectDir.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
Project("simpleProject", "3.4").apply {
|
||||||
|
setupWorkingDir()
|
||||||
|
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
||||||
|
build("build") {
|
||||||
|
check(copyClassesToJavaOutput = null,
|
||||||
|
expectBuildCacheWarning = false,
|
||||||
|
expectGradleLowVersionWarning = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user