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:
+1
@@ -27,6 +27,7 @@ public interface KotlinModuleDescriptionBuilder {
|
||||
String outputDir,
|
||||
DependencyProvider dependencyProvider,
|
||||
List<File> sourceFiles,
|
||||
List<File> javaSourceRoots,
|
||||
boolean tests,
|
||||
Set<File> directoriesToFilterOut
|
||||
);
|
||||
|
||||
+9
-2
@@ -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;
|
||||
|
||||
+10
-3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user