Avoid having -d and -module set at the same time

#KT-14619 fixed
This commit is contained in:
Alexey Tsvetkov
2017-02-03 17:37:50 +03:00
parent 667c00e3ed
commit 6e0f3b7f1f
5 changed files with 43 additions and 3 deletions
@@ -425,6 +425,8 @@ class IncrementalJvmCompilerRunner(
javaSourceRoots = javaSourceRoots,
classpath = classpath,
friendDirs = listOf())
val destination = args.destination
args.destination = null
args.module = moduleFile.absolutePath
val outputItemCollector = OutputItemsCollectorImpl()
@Suppress("NAME_SHADOWING")
@@ -446,6 +448,7 @@ class IncrementalJvmCompilerRunner(
return CompileChangedResults(exitCode, generatedFiles)
}
finally {
args.destination = destination
moduleFile.delete()
}
}
@@ -237,6 +237,15 @@ abstract class BaseGradleIT {
assertNull(regex.find(output), "Output should not contain '$regex'")
}
fun CompiledProject.assertNoWarnings() {
val warnings = "w: .*$".toRegex().findAll(output).map { it.groupValues[0] }
if (warnings.any()) {
val message = (listOf("Output should not contain any warnings:") + warnings).joinToString(SYSTEM_LINE_SEPARATOR)
throw IllegalStateException(message)
}
}
fun CompiledProject.fileInWorkingDir(path: String) = File(File(workingDir, project.projectName), path)
fun CompiledProject.assertReportExists(pathToReport: String = ""): CompiledProject {
@@ -48,6 +48,7 @@ open class ExecutionStrategyIT : BaseGradleIT() {
assertSuccessful()
assertContains(finishMessage)
checkOutput()
assertNoWarnings()
}
val fKt = project.projectDir.getFileByName("f.kt")
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.gradle
import org.gradle.api.logging.LogLevel
import org.jetbrains.kotlin.gradle.tasks.USING_EXPERIMENTAL_INCREMENTAL_MESSAGE
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.getFilesByNames
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import java.io.File
@@ -159,6 +160,30 @@ class KotlinGradleIT: BaseGradleIT() {
}
}
@Test
fun testIncremental() {
val project = Project("kotlinProject", GRADLE_VERSION)
val options = defaultBuildOptions().copy(incremental = true)
project.build("build", options = options) {
assertSuccessful()
assertNoWarnings()
}
val greeterKt = project.projectDir.getFileByName("Greeter.kt")
greeterKt.modify {
it.replace("greeting: String", "greeting: CharSequence")
}
project.build("build", options = options) {
assertSuccessful()
assertNoWarnings()
val affectedSources = project.projectDir.getFilesByNames("Greeter.kt", "KotlinGreetingJoiner.kt",
"TestGreeter.kt", "TestKotlinGreetingJoiner.kt")
assertCompiledKotlinSources(project.relativize(affectedSources), weakTesting = false)
}
}
@Test
fun testSimpleMultiprojectIncremental() {
fun Project.modify(body: Project.() -> Unit): Project {
@@ -58,18 +58,20 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
args: K2JVMCompilerArguments,
environment: GradleCompilerEnvironment
): ExitCode {
val outputDir = args.destinationAsFile
val moduleFile = makeModuleFile(
args.moduleName,
isTest = false,
outputDir = outputDir,
outputDir = args.destinationAsFile,
sourcesToCompile = sourcesToCompile,
javaSourceRoots = javaSourceRoots,
classpath = args.classpathAsList,
friendDirs = args.friendPaths?.map(::File) ?: emptyList())
args.module = moduleFile.absolutePath
if (environment !is GradleIncrementalCompilerEnvironment) {
args.destination = null
}
try {
return runCompiler(K2JVM_COMPILER, args, environment)
}