Modules.xml: add Java sources right after Kotlin sources

Java sources should appear before classpath dependencies because they should
have higher priority if the same symbol is located in the module source and in
the classpath. This is so because by default module source has the highest
priority in IDEA except the JDK. Ideally this will be handled later by full
support of modules in the compiler

Original commit: fa2116040e
This commit is contained in:
Alexander Udalov
2015-01-22 16:40:01 +03:00
parent 2be92c8bed
commit e98c929be6
@@ -89,8 +89,9 @@ public class KotlinBuilderModuleScriptGenerator {
builder.addModule(
target.getId(),
outputDir.getAbsolutePath(),
getKotlinModuleDependencies(context, target),
getKotlinModuleDependencies(target),
moduleSources,
findSourceRoots(context, target),
target.isTests(),
// this excludes the output directories from the class path, to be removed for true incremental compilation
outputDirs
@@ -115,12 +116,11 @@ public class KotlinBuilderModuleScriptGenerator {
return outputDir;
}
private static DependencyProvider getKotlinModuleDependencies(final CompileContext context, final ModuleBuildTarget target) {
private static DependencyProvider getKotlinModuleDependencies(final ModuleBuildTarget target) {
return new DependencyProvider() {
@Override
public void processClassPath(@NotNull DependencyProcessor processor) {
processor.processClassPathSection("Classpath", findClassPathRoots(target));
processor.processClassPathSection("Java Source Roots", findSourceRoots(context, target));
processor.processAnnotationRoots(findAnnotationRoots(target));
}
};
@@ -132,9 +132,9 @@ public class KotlinBuilderModuleScriptGenerator {
}
@NotNull
private static Collection<File> findSourceRoots(@NotNull CompileContext context, @NotNull ModuleBuildTarget target) {
private static List<File> findSourceRoots(@NotNull CompileContext context, @NotNull ModuleBuildTarget target) {
List<JavaSourceRootDescriptor> roots = context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context);
Collection<File> result = ContainerUtil.newArrayList();
List<File> result = ContainerUtil.newArrayList();
for (JavaSourceRootDescriptor root : roots) {
File file = root.getRootFile();
if (file.exists()) {