[Gradle] Disable usePreciseJavaTracking flag for K2

Historically flag was enabled for Gradle projects, but we don't have fir-based JavaTracker for the K2 compiler for now, so we need to use a fallback strategy.
Note: it was disabled for tests with K2
Note2: after adding a fir-based java classes tracker this value should be set to true (KT-57147)

#KT-56886 Fixed

Merge-request: KT-MR-9053
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
Aleksei.Cherepanov
2023-03-09 13:41:25 +00:00
committed by Space Team
parent d7880eb12c
commit 6471624d0c
14 changed files with 188 additions and 2 deletions
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.daemon.report.CompileServicesFacadeMessageCollector
@@ -608,13 +609,17 @@ abstract class CompileServiceImplBase(
}
val projectRoot = incrementalCompilationOptions.modulesInfo.projectRoot
val useK2 = k2jvmArgs.useK2 || LanguageVersion.fromVersionString(k2jvmArgs.languageVersion)?.usesK2 == true
// TODO: This should be reverted after implementing of fir-based java tracker (KT-57147).
// See org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunnerKt.makeIncrementally
val usePreciseJavaTracking = if (useK2) false else incrementalCompilationOptions.usePreciseJavaTracking
val compiler = IncrementalJvmCompilerRunner(
workingDir,
reporter,
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
outputDirs = incrementalCompilationOptions.outputFiles,
usePreciseJavaTracking = incrementalCompilationOptions.usePreciseJavaTracking,
usePreciseJavaTracking = usePreciseJavaTracking,
modulesApiHistory = modulesApiHistory,
kotlinSourceFilesExtensions = allKotlinExtensions,
classpathChanges = incrementalCompilationOptions.classpathChanges,
@@ -104,7 +104,7 @@ fun makeIncrementally(
cachesDir,
buildReporter,
// Use precise setting in case of non-Gradle build
usePreciseJavaTracking = !useK2, // TODO: add fir-based java classes tracker when available and set this to true
usePreciseJavaTracking = !useK2, // TODO: add fir-based java classes tracker when available and set this to true (KT-57147)
buildHistoryFile = buildHistoryFile,
outputDirs = null,
modulesApiHistory = EmptyModulesApiHistory,
@@ -1408,6 +1408,11 @@ public class IncrementalFirICLightTreeJvmCompilerRunnerTestGenerated extends Abs
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/rawErrorTypeDuringSerialization/");
}
@TestMetadata("removeAnnotation")
public void testRemoveAnnotation() throws Exception {
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation/");
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1681,6 +1686,19 @@ public class IncrementalFirICLightTreeJvmCompilerRunnerTestGenerated extends Abs
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class RemoveAnnotation extends AbstractIncrementalFirICLightTreeJvmCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInRemoveAnnotation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true);
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1408,6 +1408,11 @@ public class IncrementalFirJvmCompilerRunnerTestGenerated extends AbstractIncrem
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/rawErrorTypeDuringSerialization/");
}
@TestMetadata("removeAnnotation")
public void testRemoveAnnotation() throws Exception {
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation/");
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1681,6 +1686,19 @@ public class IncrementalFirJvmCompilerRunnerTestGenerated extends AbstractIncrem
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class RemoveAnnotation extends AbstractIncrementalFirJvmCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInRemoveAnnotation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true);
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1408,6 +1408,11 @@ public class IncrementalFirLightTreeJvmCompilerRunnerTestGenerated extends Abstr
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/rawErrorTypeDuringSerialization/");
}
@TestMetadata("removeAnnotation")
public void testRemoveAnnotation() throws Exception {
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation/");
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1681,6 +1686,19 @@ public class IncrementalFirLightTreeJvmCompilerRunnerTestGenerated extends Abstr
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class RemoveAnnotation extends AbstractIncrementalFirLightTreeJvmCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInRemoveAnnotation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true);
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1408,6 +1408,11 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/rawErrorTypeDuringSerialization/");
}
@TestMetadata("removeAnnotation")
public void testRemoveAnnotation() throws Exception {
runTest("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation/");
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/changeFieldType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1681,6 +1686,19 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class RemoveAnnotation extends AbstractIncrementalJvmCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInRemoveAnnotation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/removeAnnotation"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, true);
}
}
@TestMetadata("jps/jps-plugin/testData/incremental/withJava/javaUsedInKotlin/samConversions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)