Rebuild module on plugin classpaths change

Add another one reason for rebuild: if pluginClasspaths was changed or even its jar content, module will be marked for rebuild

Merge-request: KT-MR-5839
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
Aleksei.Cherepanov
2022-04-18 11:06:15 +00:00
committed by Space
parent 281e381223
commit e0029b14ee
8 changed files with 133 additions and 17 deletions
@@ -45,9 +45,11 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.KotlinFacetSettings
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTestBase.LibraryDependency.*
import org.jetbrains.kotlin.jps.incremental.CacheAttributesDiff
import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension
import org.jetbrains.kotlin.jps.model.kotlinCommonCompilerArguments
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
@@ -952,6 +954,38 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() {
buildAllModules().assertSuccessful()
}
@WorkingDir("KotlinProject")
fun testModuleRebuildOnPluginClasspathsChange() {
initProject(JVM_MOCK_RUNTIME)
myProject.modules.forEach {
val facet = KotlinFacetSettings()
facet.useProjectSettings = false
facet.compilerArguments = K2JVMCompilerArguments()
facet.compilerArguments?.pluginClasspaths = arrayOf(PathUtil.kotlinPathsForDistDirectory.lombokPluginJarPath.path)
it.container.setChild(
JpsKotlinFacetModuleExtension.KIND,
JpsKotlinFacetModuleExtension(facet)
)
}
buildAllModules().assertSuccessful()
myProject.modules.forEach {
val facet = KotlinFacetSettings()
facet.useProjectSettings = false
facet.compilerArguments = K2JVMCompilerArguments()
facet.compilerArguments?.pluginClasspaths = arrayOf(
PathUtil.kotlinPathsForDistDirectory.lombokPluginJarPath.path,
PathUtil.kotlinPathsForDistDirectory.allOpenPluginJarPath.path
)
it.container.setChild(
JpsKotlinFacetModuleExtension.KIND,
JpsKotlinFacetModuleExtension(facet)
)
}
checkWhen(emptyArray(), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt"))
}
private fun BuildResult.checkErrors() {
val actualErrors = getMessages(BuildMessage.Kind.ERROR)
.map { it as CompilerMessage }
@@ -21,9 +21,7 @@ import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.incremental.ChangesCollector
import org.jetbrains.kotlin.incremental.ExpectActualTrackerImpl
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
@@ -339,7 +337,8 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo> intern
val prevBuildMetaInfo =
try {
buildMetaInfoFactory.deserializeFromString(Files.newInputStream(file).bufferedReader().use { it.readText() }) ?: return false
buildMetaInfoFactory.deserializeFromString(Files.newInputStream(file).bufferedReader().use { it.readText() })
?: return false
} catch (e: Exception) {
KotlinBuilder.LOG.error("Could not deserialize build meta info", e)
return false
@@ -355,7 +354,10 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo> intern
// If EAP->Non-EAP build with IC, then rebuild all kotlin
"Last build was compiled with EAP-plugin"
}
else -> null
else -> PluginClasspathsComparator(
prevBuildMetaInfo.pluginClasspaths,
buildMetaInfo.pluginClasspaths
).describeDifferencesOrNull()
}
if (reasonToRebuild != null) {