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
@@ -27,6 +27,7 @@ public interface KotlinModuleDescriptionBuilder {
String outputDir,
DependencyProvider dependencyProvider,
List<File> sourceFiles,
List<File> javaSourceRoots,
boolean tests,
Set<File> directoriesToFilterOut
);
@@ -56,6 +56,7 @@ public class KotlinModuleScriptBuilderFactory implements KotlinModuleDescription
String outputDir,
DependencyProvider dependencyProvider,
List<File> sourceFiles,
List<File> javaSourceRoots,
boolean tests,
final Set<File> directoriesToFilterOut
) {
@@ -74,7 +75,7 @@ public class KotlinModuleScriptBuilderFactory implements KotlinModuleDescription
script.append(" sources += \"" + toSystemIndependentName(sourceFile.getPath()) + "\"\n");
}
dependencyProvider.processClassPath(new DependencyProcessor() {
DependencyProcessor processor = new DependencyProcessor() {
@Override
public void processClassPathSection(@NotNull String sectionDescription, @NotNull Collection<File> files) {
script.append(" // " + sectionDescription + "\n");
@@ -97,7 +98,13 @@ public class KotlinModuleScriptBuilderFactory implements KotlinModuleDescription
script.append(" annotationsPath += \"").append(toSystemIndependentName(file.getPath())).append("\"\n");
}
}
});
};
if (!javaSourceRoots.isEmpty()) {
processor.processClassPathSection("Java source roots", javaSourceRoots);
}
dependencyProvider.processClassPath(processor);
script.append(" }\n");
return this;
@@ -60,6 +60,7 @@ public class KotlinModuleXmlBuilderFactory implements KotlinModuleDescriptionBui
String outputDir,
DependencyProvider dependencyProvider,
List<File> sourceFiles,
List<File> javaSourceRoots,
boolean tests,
final Set<File> directoriesToFilterOut
) {
@@ -82,7 +83,7 @@ public class KotlinModuleXmlBuilderFactory implements KotlinModuleDescriptionBui
p.println("<", SOURCES, " ", PATH, "=\"", getEscapedPath(sourceFile), "\"/>");
}
dependencyProvider.processClassPath(new DependencyProcessor() {
DependencyProcessor processor = new DependencyProcessor() {
@Override
public void processClassPathSection(@NotNull String sectionDescription, @NotNull Collection<File> files) {
p.println("<!-- ", sectionDescription, " -->");
@@ -110,10 +111,16 @@ public class KotlinModuleXmlBuilderFactory implements KotlinModuleDescriptionBui
public void processAnnotationRoots(@NotNull List<File> files) {
p.println("<!-- External annotations -->");
for (File file : files) {
p.println("<", EXTERNAL_ANNOTATIONS, " ", PATH, "= \"", getEscapedPath(file), "\"/>");
p.println("<", EXTERNAL_ANNOTATIONS, " ", PATH, "=\"", getEscapedPath(file), "\"/>");
}
}
});
};
if (!javaSourceRoots.isEmpty()) {
processor.processClassPathSection("Java source roots", javaSourceRoots);
}
dependencyProvider.processClassPath(processor);
closeTag(p, MODULE);
return this;