Add prefix information for Java source root (KT-9167 in progress)
#KT-9167 In Progress
Original commit: c0739ef53c
This commit is contained in:
committed by
Nikolay Krasko
parent
bc29f06187
commit
048725c3f0
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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)
|
||||
+4
-3
@@ -127,13 +127,14 @@ public class KotlinBuilderModuleScriptGenerator {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<File> findSourceRoots(@NotNull CompileContext context, @NotNull ModuleBuildTarget target) {
|
||||
private static List<JvmSourceRoot> findSourceRoots(@NotNull CompileContext context, @NotNull ModuleBuildTarget target) {
|
||||
List<JavaSourceRootDescriptor> roots = context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context);
|
||||
List<File> result = ContainerUtil.newArrayList();
|
||||
List<JvmSourceRoot> result = ContainerUtil.newArrayList();
|
||||
for (JavaSourceRootDescriptor root : roots) {
|
||||
File file = root.getRootFile();
|
||||
String prefix = root.getPackagePrefix();
|
||||
if (file.exists()) {
|
||||
result.add(file);
|
||||
result.add(new JvmSourceRoot(file, prefix.isEmpty() ? null : prefix));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.modules;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation;
|
||||
import org.jetbrains.kotlin.jps.build.JvmSourceRoot;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,7 +44,7 @@ public class KotlinModuleXmlBuilder {
|
||||
String moduleName,
|
||||
String outputDir,
|
||||
List<File> sourceFiles,
|
||||
List<File> javaSourceRoots,
|
||||
List<JvmSourceRoot> javaSourceRoots,
|
||||
Collection<File> classpathRoots,
|
||||
JavaModuleBuildTargetType targetType,
|
||||
Set<File> directoriesToFilterOut
|
||||
@@ -100,10 +101,18 @@ public class KotlinModuleXmlBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private void processJavaSourceRoots(@NotNull List<File> files) {
|
||||
private void processJavaSourceRoots(@NotNull List<JvmSourceRoot> roots) {
|
||||
p.println("<!-- Java source roots -->");
|
||||
for (File file : files) {
|
||||
p.println("<", JAVA_SOURCE_ROOTS, " ", PATH, "=\"", getEscapedPath(file), "\"/>");
|
||||
for (JvmSourceRoot root : roots) {
|
||||
p.print("<");
|
||||
p.printWithNoIndent(JAVA_SOURCE_ROOTS, " ", PATH, "=\"", getEscapedPath(root.getFile()), "\"");
|
||||
|
||||
if (root.getPackagePrefix() != null) {
|
||||
p.printWithNoIndent(" ", JAVA_SOURCE_PACKAGE_PREFIX, "=\"", root.getPackagePrefix(), "\"");
|
||||
}
|
||||
|
||||
p.printWithNoIndent("/>");
|
||||
p.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +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.modules.KotlinModuleXmlBuilder
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||
@@ -43,7 +44,7 @@ public class ClasspathOrderTest : TestCaseWithTmpdir() {
|
||||
"name",
|
||||
File(tmpdir, "output").getAbsolutePath(),
|
||||
listOf(sourceDir),
|
||||
listOf(sourceDir),
|
||||
listOf(JvmSourceRoot(sourceDir)),
|
||||
listOf(PathUtil.getKotlinPathsForDistDirectory().getRuntimePath()),
|
||||
JavaModuleBuildTargetType.PRODUCTION,
|
||||
setOf()
|
||||
|
||||
@@ -18,6 +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.test.KotlinTestUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -30,7 +31,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
||||
"name",
|
||||
"output",
|
||||
Arrays.asList(new File("s1"), new File("s2")),
|
||||
Collections.singletonList(new File("java")),
|
||||
Collections.singletonList(new JvmSourceRoot(new File("java"), null)),
|
||||
Arrays.asList(new File("cp1"), new File("cp2")),
|
||||
JavaModuleBuildTargetType.PRODUCTION,
|
||||
Collections.<File>emptySet()
|
||||
@@ -43,7 +44,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
||||
"name",
|
||||
"output",
|
||||
Arrays.asList(new File("s1"), new File("s2")),
|
||||
Collections.<File>emptyList(),
|
||||
Collections.<JvmSourceRoot>emptyList(),
|
||||
Arrays.asList(new File("cp1"), new File("cp2")),
|
||||
JavaModuleBuildTargetType.PRODUCTION,
|
||||
Collections.singleton(new File("cp1"))
|
||||
@@ -57,7 +58,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
||||
"name",
|
||||
"output",
|
||||
Arrays.asList(new File("s1"), new File("s2")),
|
||||
Collections.<File>emptyList(),
|
||||
Collections.<JvmSourceRoot>emptyList(),
|
||||
Arrays.asList(new File("cp1"), new File("cp2")),
|
||||
JavaModuleBuildTargetType.PRODUCTION,
|
||||
Collections.singleton(new File("cp1"))
|
||||
@@ -66,7 +67,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
||||
"name2",
|
||||
"output2",
|
||||
Arrays.asList(new File("s12"), new File("s22")),
|
||||
Collections.<File>emptyList(),
|
||||
Collections.<JvmSourceRoot>emptyList(),
|
||||
Arrays.asList(new File("cp12"), new File("cp22")),
|
||||
JavaModuleBuildTargetType.TEST,
|
||||
Collections.singleton(new File("cp12"))
|
||||
|
||||
Reference in New Issue
Block a user