Not clearing incremental cache on compilation error.
This commit is contained in:
@@ -196,10 +196,13 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val compilationErrors = Utils.ERRORS_DETECTED_KEY[context, false]
|
||||||
|
|
||||||
for ((target, cache) in incrementalCaches) {
|
for ((target, cache) in incrementalCaches) {
|
||||||
cache.clearCacheForRemovedFiles(
|
cache.clearCacheForRemovedFiles(
|
||||||
KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, target),
|
KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, target),
|
||||||
target.getOutputDir()!!
|
target.getOutputDir()!!,
|
||||||
|
!compilationErrors
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,12 +96,14 @@ public class IncrementalCacheImpl(val baseDir: File): StorageOwner, IncrementalC
|
|||||||
return DO_NOTHING
|
return DO_NOTHING
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun clearCacheForRemovedFiles(removedSourceFiles: Collection<String>, outDirectory: File) {
|
public fun clearCacheForRemovedFiles(removedSourceFiles: Collection<String>, outDirectory: File, compilationSuccessful: Boolean) {
|
||||||
removedSourceFiles.forEach { packagePartMap.remove(it) }
|
removedSourceFiles.forEach { packagePartMap.remove(it) }
|
||||||
|
|
||||||
inlineFunctionsMap.clearOutdated(outDirectory)
|
if (compilationSuccessful) {
|
||||||
constantsMap.clearOutdated(outDirectory)
|
inlineFunctionsMap.clearOutdated(outDirectory)
|
||||||
protoMap.clearOutdated(outDirectory)
|
constantsMap.clearOutdated(outDirectory)
|
||||||
|
protoMap.clearOutdated(outDirectory)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun getRemovedPackageParts(compiledSourceFilesToFqName: Map<File, String>): Collection<String> {
|
public override fun getRemovedPackageParts(compiledSourceFilesToFqName: Map<File, String>): Collection<String> {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.jetbrains.jps.builders.impl.BuildDataPathsImpl
|
|||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
import java.util.HashMap
|
import java.util.HashMap
|
||||||
import org.jetbrains.jet.utils.keysToMap
|
import org.jetbrains.jet.utils.keysToMap
|
||||||
|
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||||
|
|
||||||
public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() {
|
public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() {
|
||||||
private var testDataDir: File by Delegates.notNull()
|
private var testDataDir: File by Delegates.notNull()
|
||||||
@@ -52,8 +53,13 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() {
|
|||||||
val logger = MyLogger(FileUtil.toSystemIndependentName(workDir.getAbsolutePath()))
|
val logger = MyLogger(FileUtil.toSystemIndependentName(workDir.getAbsolutePath()))
|
||||||
val descriptor = createProjectDescriptor(BuildLoggingManager(logger))
|
val descriptor = createProjectDescriptor(BuildLoggingManager(logger))
|
||||||
try {
|
try {
|
||||||
doBuild(descriptor, scope)!!.assertSuccessful()
|
val buildResult = doBuild(descriptor, scope)!!
|
||||||
return logger.log
|
if (!buildResult.isSuccessful()) {
|
||||||
|
return logger.log + "COMPILATION FAILED\n" + buildResult.getMessages(BuildMessage.Kind.ERROR).joinToString("\n") + "\n"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return logger.log
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
descriptor.release()
|
descriptor.release()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compilationErrorThenFixed")
|
||||||
|
public void testCompilationErrorThenFixed() throws Exception {
|
||||||
|
doTest("jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixed/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantsUnchanged")
|
@TestMetadata("constantsUnchanged")
|
||||||
public void testConstantsUnchanged() throws Exception {
|
public void testConstantsUnchanged() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
Cleaning output files:
|
||||||
|
out/production/module/_DefaultPackage-usage-*.class
|
||||||
|
out/production/module/_DefaultPackage.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/usage.kt
|
||||||
|
End of files
|
||||||
|
COMPILATION FAILED
|
||||||
|
Kotlin:ERROR:Expecting an expression
|
||||||
|
|
||||||
|
|
||||||
|
Compiling files:
|
||||||
|
src/usage.kt
|
||||||
|
End of files
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fun f() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
f(
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user