From 0e28d612e723cedb37b2323f7a201a958ec872f3 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Mon, 21 Aug 2017 15:22:37 +0300 Subject: [PATCH] Add a test for the opt-out flag for disabling separate classes directory (cherry picked from commit 393966d) --- .../kotlin/gradle/KotlinGradlePluginIT.kt | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index 9314f4c50be..4a9417fb344 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel 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.util.checkBytecodeContains import org.jetbrains.kotlin.gradle.util.getFileByName @@ -596,4 +597,66 @@ class KotlinGradleIT: BaseGradleIT() { "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) + } + } + } } \ No newline at end of file