diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollector.java b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollector.java deleted file mode 100644 index a05fe540e47..00000000000 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollector.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.compilerRunner; - -import java.io.File; -import java.util.Collection; - -public interface OutputItemsCollector { - void add(Collection sourceFiles, File outputFile); -} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollectorImpl.java b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollectorImpl.java deleted file mode 100644 index b2b40cd1811..00000000000 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/OutputItemsCollectorImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.compilerRunner; - -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -public class OutputItemsCollectorImpl implements OutputItemsCollector { - private final List outputs = ContainerUtil.newArrayList(); - - @Override - public void add(Collection sourceFiles, File outputFile) { - outputs.add(new SimpleOutputItem(sourceFiles, outputFile)); - } - - @NotNull - public List getOutputs() { - return outputs; - } -} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/SimpleOutputItem.java b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/SimpleOutputItem.java deleted file mode 100644 index ed9c716f7cb..00000000000 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/SimpleOutputItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.compilerRunner; - -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.Collection; - -public class SimpleOutputItem { - private final Collection sourceFiles; - private final File outputFile; - - public SimpleOutputItem(@NotNull Collection sourceFiles, @NotNull File outputFile) { - this.sourceFiles = sourceFiles; - this.outputFile = outputFile; - } - - @NotNull - public Collection getSourceFiles() { - return sourceFiles; - } - - @NotNull - public File getOutputFile() { - return outputFile; - } - - @Override - public String toString() { - return sourceFiles + " -> " + outputFile; - } -} diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JvmSourceRoot.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JvmSourceRoot.kt deleted file mode 100644 index 6dba446f049..00000000000 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/JvmSourceRoot.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.jps.build - -import java.io.File - -data class JvmSourceRoot(val file: File, val packagePrefix: String? = null) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.java b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.java index af6e1488181..f6afa1e7e14 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.java +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.java @@ -33,6 +33,7 @@ import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.ModuleBuildTarget; import org.jetbrains.jps.incremental.ProjectBuildException; import org.jetbrains.jps.model.java.JpsJavaExtensionService; +import org.jetbrains.kotlin.build.JvmSourceRoot; import org.jetbrains.kotlin.config.IncrementalCompilation; import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder; @@ -89,7 +90,8 @@ public class KotlinBuilderModuleScriptGenerator { moduleSources, findSourceRoots(context, target), findClassPathRoots(target), - (JavaModuleBuildTargetType) targetType, + ((JavaModuleBuildTargetType) targetType).getTypeId(), + ((JavaModuleBuildTargetType) targetType).isTests(), // this excludes the output directories from the class path, to be removed for true incremental compilation outputDirs, friendDirs diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt deleted file mode 100644 index 41f90832c4f..00000000000 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/modules/KotlinModuleXmlBuilder.kt +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.modules - -import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName -import com.intellij.openapi.util.text.StringUtil.escapeXml -import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType -import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser.* -import org.jetbrains.kotlin.config.IncrementalCompilation -import org.jetbrains.kotlin.jps.build.JvmSourceRoot -import org.jetbrains.kotlin.utils.Printer -import java.io.File - -class KotlinModuleXmlBuilder { - private val xml = StringBuilder() - private val p = Printer(xml) - private var done = false - - init { - openTag(p, MODULES) - } - - fun addModule( - moduleName: String, - outputDir: String, - sourceFiles: List, - javaSourceRoots: List, - classpathRoots: Collection, - targetType: JavaModuleBuildTargetType, - directoriesToFilterOut: Set, - friendDirs: List): KotlinModuleXmlBuilder { - assert(!done) { "Already done" } - - if (targetType.isTests) { - p.println("") - } - else { - p.println("") - } - - p.println("<", MODULE, " ", - NAME, "=\"", escapeXml(moduleName), "\" ", - TYPE, "=\"", escapeXml(targetType.typeId), "\" ", - OUTPUT_DIR, "=\"", getEscapedPath(File(outputDir)), "\">") - p.pushIndent() - - for (friendDir in friendDirs) { - p.println("<", FRIEND_DIR, " ", PATH, "=\"", getEscapedPath(friendDir), "\"/>") - } - - for (sourceFile in sourceFiles) { - p.println("<", SOURCES, " ", PATH, "=\"", getEscapedPath(sourceFile), "\"/>") - } - - processJavaSourceRoots(javaSourceRoots) - processClasspath(classpathRoots, directoriesToFilterOut) - - closeTag(p, MODULE) - return this - } - - private fun processClasspath( - files: Collection, - directoriesToFilterOut: Set) { - p.println("") - for (file in files) { - val isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.isEnabled() - if (isOutput) { - // For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies - // appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was - // removed in the sources, it may still be there in binaries. Thus, we delete these entries from the classpath. - p.println("") - p.println("") - } - } - } - - private fun processJavaSourceRoots(roots: List) { - p.println("") - for (root in roots) { - p.print("<") - p.printWithNoIndent(JAVA_SOURCE_ROOTS, " ", PATH, "=\"", getEscapedPath(root.file), "\"") - - if (root.packagePrefix != null) { - p.printWithNoIndent(" ", JAVA_SOURCE_PACKAGE_PREFIX, "=\"", root.packagePrefix, "\"") - } - - p.printWithNoIndent("/>") - p.println() - } - } - - fun asText(): CharSequence { - if (!done) { - closeTag(p, MODULES) - done = true - } - return xml - } - - private fun openTag(p: Printer, tag: String) { - p.println("<$tag>") - p.pushIndent() - } - - private fun closeTag(p: Printer, tag: String) { - p.popIndent() - p.println("") - } - - private fun getEscapedPath(sourceFile: File): String { - return escapeXml(toSystemIndependentName(sourceFile.path)) - } -} diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt index 40f75a9b648..a3c1581b6b6 100644 --- a/jps/jps-plugin/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jvm/compiler/ClasspathOrderTest.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.jvm.compiler import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType -import org.jetbrains.kotlin.jps.build.JvmSourceRoot +import org.jetbrains.kotlin.build.JvmSourceRoot import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.MockLibraryUtil @@ -46,7 +46,8 @@ class ClasspathOrderTest : TestCaseWithTmpdir() { listOf(sourceDir), listOf(JvmSourceRoot(sourceDir)), listOf(PathUtil.getKotlinPathsForDistDirectory().runtimePath), - JavaModuleBuildTargetType.PRODUCTION, + JavaModuleBuildTargetType.PRODUCTION.typeId, + JavaModuleBuildTargetType.PRODUCTION.isTests, setOf(), emptyList() ).asText().toString() diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java b/jps/jps-plugin/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java index a30b6c775ad..b8fedb9f6fd 100644 --- a/jps/jps-plugin/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/modules/KotlinModuleXmlGeneratorTest.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.modules; import junit.framework.TestCase; import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType; -import org.jetbrains.kotlin.jps.build.JvmSourceRoot; +import org.jetbrains.kotlin.build.JvmSourceRoot; import org.jetbrains.kotlin.test.KotlinTestUtils; import java.io.File; @@ -33,7 +33,8 @@ public class KotlinModuleXmlGeneratorTest extends TestCase { Arrays.asList(new File("s1"), new File("s2")), Collections.singletonList(new JvmSourceRoot(new File("java"), null)), Arrays.asList(new File("cp1"), new File("cp2")), - JavaModuleBuildTargetType.PRODUCTION, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), Collections.emptySet(), Collections.emptyList() ).asText().toString(); @@ -47,7 +48,8 @@ public class KotlinModuleXmlGeneratorTest extends TestCase { Arrays.asList(new File("s1"), new File("s2")), Collections.emptyList(), Arrays.asList(new File("cp1"), new File("cp2")), - JavaModuleBuildTargetType.PRODUCTION, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), Collections.singleton(new File("cp1")), Collections.emptyList() ).asText().toString(); @@ -62,7 +64,8 @@ public class KotlinModuleXmlGeneratorTest extends TestCase { Arrays.asList(new File("s1"), new File("s2")), Collections.emptyList(), Arrays.asList(new File("cp1"), new File("cp2")), - JavaModuleBuildTargetType.PRODUCTION, + JavaModuleBuildTargetType.PRODUCTION.getTypeId(), + JavaModuleBuildTargetType.PRODUCTION.isTests(), Collections.singleton(new File("cp1")), Collections.emptyList() ); @@ -72,7 +75,8 @@ public class KotlinModuleXmlGeneratorTest extends TestCase { Arrays.asList(new File("s12"), new File("s22")), Collections.emptyList(), Arrays.asList(new File("cp12"), new File("cp22")), - JavaModuleBuildTargetType.TEST, + JavaModuleBuildTargetType.TEST.getTypeId(), + JavaModuleBuildTargetType.TEST.isTests(), Collections.singleton(new File("cp12")), Collections.emptyList() );