Skip to content

Commit e2b8ad6

Browse files
author
Aleksei.Cherepanov
committed
[JPS] Properly register files to compile
JPS graph needs to know if Kotlin JPS tried to compile some files. Previously, we registered these files only iff compilation succeeded. Now we register them also in case when the compiler fails (cherry picked from commit 1f502fe)
1 parent af0c392 commit e2b8ad6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt

+14-3
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
447447

448448
cleanJsOutputs(context, kotlinChunk, incrementalCaches, kotlinDirtyFilesHolder)
449449

450-
if (LOG.isDebugEnabled) {
451-
LOG.debug("Compiling files: ${kotlinDirtyFilesHolder.allDirtyFiles}")
452-
}
450+
453451

454452
val start = System.nanoTime()
455453
val outputItemCollector = doCompileModuleChunk(
@@ -474,6 +472,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
474472
LOG.info("Compiled with errors")
475473
return ABORT
476474
} else {
475+
JavaBuilderUtil.registerSuccessfullyCompiled(context, kotlinDirtyFilesHolder.allDirtyFiles)
477476
LOG.info("Compiled successfully")
478477
}
479478

@@ -618,11 +617,23 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
618617
}
619618
}
620619

620+
registerFilesToCompile(dirtyFilesHolder, context)
621621
val isDoneSomething = representativeTarget.compileModuleChunk(commonArguments, dirtyFilesHolder, environment)
622622

623623
return if (isDoneSomething) environment.outputItemsCollector else null
624624
}
625625

626+
private fun registerFilesToCompile(
627+
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
628+
context: CompileContext,
629+
) {
630+
val allDirtyFiles = dirtyFilesHolder.allDirtyFiles
631+
if (LOG.isDebugEnabled) {
632+
LOG.debug("Compiling files: $allDirtyFiles")
633+
}
634+
JavaBuilderUtil.registerFilesToCompile(context, allDirtyFiles)
635+
}
636+
626637
private fun createCompileEnvironment(
627638
context: CompileContext,
628639
kotlinModuleBuilderTarget: KotlinModuleBuildTarget<*>,

jps/jps-plugin/src/org/jetbrains/kotlin/jps/targets/KotlinJvmModuleBuildTarget.kt

-4
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,6 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
418418
}
419419
}
420420
// important: in jps-dependency-graph you can't register additional dependencies after [callback.associate].
421-
422-
val allCompiled = dirtyFilesHolder.allDirtyFiles
423-
JavaBuilderUtil.registerFilesToCompile(localContext, allCompiled)
424-
JavaBuilderUtil.registerSuccessfullyCompiled(localContext, allCompiled)
425421
}
426422

427423
private fun processInlineConstTracker(inlineConstTracker: InlineConstTrackerImpl, sourceFile: File, output: GeneratedJvmClass, callback: Backend) {

0 commit comments

Comments
 (0)