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
This commit is contained in:
Alexander Udalov
2015-01-22 16:40:01 +03:00
parent eb3588bd0a
commit fa2116040e
8 changed files with 47 additions and 22 deletions
@@ -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()) {