Introduce -Xcommon-sources and pass it correctly from build tool plugins

#KT-25196 In Progress

Original commit: 0f003802fe
This commit is contained in:
Alexander Udalov
2018-07-27 14:15:12 +02:00
parent bf4565259b
commit 9c21dae5e2
4 changed files with 26 additions and 18 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.jps.build package org.jetbrains.kotlin.jps.build
import com.intellij.testFramework.UsefulTestCase import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.containers.HashMap
import com.intellij.util.containers.StringInterner import com.intellij.util.containers.StringInterner
import org.jetbrains.kotlin.TestWithWorkingDir import org.jetbrains.kotlin.TestWithWorkingDir
import org.jetbrains.kotlin.build.JvmSourceRoot import org.jetbrains.kotlin.build.JvmSourceRoot
@@ -78,13 +77,14 @@ abstract class AbstractJvmLookupTrackerTest : AbstractLookupTrackerTest() {
override fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any? { override fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any? {
val moduleFile = makeModuleFile( val moduleFile = makeModuleFile(
name = "test", name = "test",
isTest = true, isTest = true,
outputDir = outDir, outputDir = outDir,
sourcesToCompile = filesToCompile.toList(), sourcesToCompile = filesToCompile.toList(),
javaSourceRoots = listOf(JvmSourceRoot(srcDir, null)), commonSources = emptyList(),
classpath = listOf(outDir, ForTestCompileRuntime.runtimeJarForTests()).filter { it.exists() }, javaSourceRoots = listOf(JvmSourceRoot(srcDir, null)),
friendDirs = emptyList() classpath = listOf(outDir, ForTestCompileRuntime.runtimeJarForTests()).filter { it.exists() },
friendDirs = emptyList()
) )
val args = K2JVMCompilerArguments().apply { val args = K2JVMCompilerArguments().apply {
@@ -41,16 +41,17 @@ class ClasspathOrderTest : TestCaseWithTmpdir() {
fun testClasspathOrderForModuleScriptBuild() { fun testClasspathOrderForModuleScriptBuild() {
val xmlContent = KotlinModuleXmlBuilder().addModule( val xmlContent = KotlinModuleXmlBuilder().addModule(
"name", "name",
File(tmpdir, "output").absolutePath, File(tmpdir, "output").absolutePath,
listOf(sourceDir), listOf(sourceDir),
listOf(JvmSourceRoot(sourceDir)), listOf(JvmSourceRoot(sourceDir)),
listOf(PathUtil.kotlinPathsForDistDirectory.stdlibPath), listOf(PathUtil.kotlinPathsForDistDirectory.stdlibPath),
null, emptyList(),
JavaModuleBuildTargetType.PRODUCTION.typeId, null,
JavaModuleBuildTargetType.PRODUCTION.isTests, JavaModuleBuildTargetType.PRODUCTION.typeId,
setOf(), JavaModuleBuildTargetType.PRODUCTION.isTests,
emptyList() setOf(),
emptyList()
).asText().toString() ).asText().toString()
val xml = File(tmpdir, "module.xml") val xml = File(tmpdir, "module.xml")
@@ -33,6 +33,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
Arrays.asList(new File("s1"), new File("s2")), Arrays.asList(new File("s1"), new File("s2")),
Collections.singletonList(new JvmSourceRoot(new File("java"), null)), Collections.singletonList(new JvmSourceRoot(new File("java"), null)),
Arrays.asList(new File("cp1"), new File("cp2")), Arrays.asList(new File("cp1"), new File("cp2")),
Collections.emptyList(),
null, null,
JavaModuleBuildTargetType.PRODUCTION.getTypeId(), JavaModuleBuildTargetType.PRODUCTION.getTypeId(),
JavaModuleBuildTargetType.PRODUCTION.isTests(), JavaModuleBuildTargetType.PRODUCTION.isTests(),
@@ -49,6 +50,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
Arrays.asList(new File("s1"), new File("s2")), Arrays.asList(new File("s1"), new File("s2")),
Collections.emptyList(), Collections.emptyList(),
Arrays.asList(new File("cp1"), new File("cp2")), Arrays.asList(new File("cp1"), new File("cp2")),
Collections.emptyList(),
null, null,
JavaModuleBuildTargetType.PRODUCTION.getTypeId(), JavaModuleBuildTargetType.PRODUCTION.getTypeId(),
JavaModuleBuildTargetType.PRODUCTION.isTests(), JavaModuleBuildTargetType.PRODUCTION.isTests(),
@@ -66,6 +68,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
Arrays.asList(new File("s1"), new File("s2")), Arrays.asList(new File("s1"), new File("s2")),
Collections.emptyList(), Collections.emptyList(),
Arrays.asList(new File("cp1"), new File("cp2")), Arrays.asList(new File("cp1"), new File("cp2")),
Collections.emptyList(),
null, null,
JavaModuleBuildTargetType.PRODUCTION.getTypeId(), JavaModuleBuildTargetType.PRODUCTION.getTypeId(),
JavaModuleBuildTargetType.PRODUCTION.isTests(), JavaModuleBuildTargetType.PRODUCTION.isTests(),
@@ -78,6 +81,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
Arrays.asList(new File("s12"), new File("s22")), Arrays.asList(new File("s12"), new File("s22")),
Collections.emptyList(), Collections.emptyList(),
Arrays.asList(new File("cp12"), new File("cp22")), Arrays.asList(new File("cp12"), new File("cp22")),
Collections.emptyList(),
null, null,
JavaModuleBuildTargetType.TEST.getTypeId(), JavaModuleBuildTargetType.TEST.getTypeId(),
JavaModuleBuildTargetType.TEST.isTests(), JavaModuleBuildTargetType.TEST.isTests(),
@@ -95,6 +99,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
Collections.emptyList(), Collections.emptyList(),
Collections.emptyList(), Collections.emptyList(),
Collections.emptyList(), Collections.emptyList(),
Collections.emptyList(),
new File("/path/to/modular/jdk"), new File("/path/to/modular/jdk"),
JavaModuleBuildTargetType.PRODUCTION.getTypeId(), JavaModuleBuildTargetType.PRODUCTION.getTypeId(),
JavaModuleBuildTargetType.PRODUCTION.isTests(), JavaModuleBuildTargetType.PRODUCTION.isTests(),
@@ -150,6 +150,7 @@ class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildT
val friendDirs = target.friendOutputDirs val friendDirs = target.friendOutputDirs
val moduleSources = collectSourcesToCompile(target, dirtyFilesHolder) val moduleSources = collectSourcesToCompile(target, dirtyFilesHolder)
val commonSources = emptyList<File>() // TODO: pass common sources here
val hasDirtyOrRemovedSources = checkShouldCompileAndLog(target, dirtyFilesHolder, moduleSources) val hasDirtyOrRemovedSources = checkShouldCompileAndLog(target, dirtyFilesHolder, moduleSources)
if (hasDirtyOrRemovedSources) hasDirtySources = true if (hasDirtyOrRemovedSources) hasDirtySources = true
@@ -160,6 +161,7 @@ class KotlinJvmModuleBuildTarget(compileContext: CompileContext, jpsModuleBuildT
moduleSources, moduleSources,
target.findSourceRoots(context), target.findSourceRoots(context),
target.findClassPathRoots(), target.findClassPathRoots(),
commonSources,
target.findModularJdkRoot(), target.findModularJdkRoot(),
kotlinModuleId.type, kotlinModuleId.type,
isTests, isTests,