enabled multiple source directories in the KotlinCompiler (we should refactor later to remove src - wanted to minimise breaking things first though :)
This commit is contained in:
@@ -29,6 +29,17 @@ import java.util.List;
|
|||||||
public class CompilerArguments {
|
public class CompilerArguments {
|
||||||
private List<CompilerPlugin> compilerPlugins = new ArrayList<CompilerPlugin>();
|
private List<CompilerPlugin> compilerPlugins = new ArrayList<CompilerPlugin>();
|
||||||
|
|
||||||
|
// TODO ideally we'd unify this with 'src' to just having a single field that supports multiple files/dirs
|
||||||
|
private List<String> sourceDirs;
|
||||||
|
|
||||||
|
public List<String> getSourceDirs() {
|
||||||
|
return sourceDirs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceDirs(List<String> sourceDirs) {
|
||||||
|
this.sourceDirs = sourceDirs;
|
||||||
|
}
|
||||||
|
|
||||||
@Argument(value = "output", description = "output directory")
|
@Argument(value = "output", description = "output directory")
|
||||||
public String outputDir;
|
public String outputDir;
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,12 @@ public class KotlinCompiler {
|
|||||||
noErrors = environment.compileModuleScript(arguments.module, arguments.jar, arguments.outputDir, arguments.includeRuntime);
|
noErrors = environment.compileModuleScript(arguments.module, arguments.jar, arguments.outputDir, arguments.includeRuntime);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
noErrors = environment.compileBunchOfSources(arguments.src, arguments.jar, arguments.outputDir, arguments.includeRuntime);
|
// TODO ideally we'd unify to just having a single field that supports multiple files/dirs
|
||||||
|
if (arguments.getSourceDirs() != null) {
|
||||||
|
noErrors = environment.compileBunchOfSourceDirectories(arguments.getSourceDirs(), arguments.jar, arguments.outputDir, arguments.includeRuntime);
|
||||||
|
} else {
|
||||||
|
noErrors = environment.compileBunchOfSources(arguments.src, arguments.jar, arguments.outputDir, arguments.includeRuntime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return noErrors ? OK : COMPILATION_ERROR;
|
return noErrors ? OK : COMPILATION_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,6 +405,21 @@ public class CompileEnvironment {
|
|||||||
|
|
||||||
session.addSources(sourceFileOrDir);
|
session.addSources(sourceFileOrDir);
|
||||||
|
|
||||||
|
return compileBunchOfSources(jar, outputDir, includeRuntime, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean compileBunchOfSourceDirectories(List<String> sources, String jar, String outputDir, boolean includeRuntime) {
|
||||||
|
CompileSession session = newCompileSession();
|
||||||
|
session.setStubs(mode != CompilerSpecialMode.REGULAR);
|
||||||
|
|
||||||
|
for (String source : sources) {
|
||||||
|
session.addSources(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compileBunchOfSources(jar, outputDir, includeRuntime, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean compileBunchOfSources(String jar, String outputDir, boolean includeRuntime, CompileSession session) {
|
||||||
FqName mainClass = null;
|
FqName mainClass = null;
|
||||||
for (JetFile file : session.getSourceFiles()) {
|
for (JetFile file : session.getSourceFiles()) {
|
||||||
if (JetMainDetector.hasMain(file.getDeclarations())) {
|
if (JetMainDetector.hasMain(file.getDeclarations())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user