minor refactoring to allow plugins to be added to the BytecodeCompiler
This commit is contained in:
@@ -18,6 +18,10 @@ package org.jetbrains.jet.buildtools.core;
|
||||
|
||||
import org.jetbrains.jet.compiler.CompileEnvironment;
|
||||
import org.jetbrains.jet.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,6 +29,7 @@ import org.jetbrains.jet.compiler.CompileEnvironmentException;
|
||||
*/
|
||||
public class BytecodeCompiler {
|
||||
|
||||
private List<CompilerPlugin> compilerPlugins = new ArrayList<CompilerPlugin>();
|
||||
|
||||
public BytecodeCompiler () {
|
||||
}
|
||||
@@ -49,6 +54,9 @@ public class BytecodeCompiler {
|
||||
env.addToClasspath( classpath );
|
||||
}
|
||||
|
||||
// lets register any compiler plugins
|
||||
env.getMyEnvironment().getCompilerPlugins().addAll(getCompilerPlugins());
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
@@ -108,4 +116,12 @@ public class BytecodeCompiler {
|
||||
public void moduleToJar ( String module, String jar, boolean includeRuntime, String stdlib, String[] classpath ) {
|
||||
env( stdlib, classpath ).compileModuleScript( module, jar, null, includeRuntime );
|
||||
}
|
||||
|
||||
public List<CompilerPlugin> getCompilerPlugins() {
|
||||
return compilerPlugins;
|
||||
}
|
||||
|
||||
public void setCompilerPlugins(List<CompilerPlugin> compilerPlugins) {
|
||||
this.compilerPlugins = compilerPlugins;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,18 @@ public class KDocLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the KDoc compiler plugin if it can be created
|
||||
*/
|
||||
public static boolean install(String docOutputDir, JetCoreEnvironment environment) {
|
||||
KDocLoader loader = new KDocLoader(docOutputDir);
|
||||
CompilerPlugin processor = loader.createCompilerPlugin();
|
||||
if (processor != null) {
|
||||
environment.getCompilerPlugins().add(processor);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +132,7 @@ public class KotlinCompiler {
|
||||
environment.setStubs(arguments.stubs);
|
||||
|
||||
if (arguments.docOutputDir != null) {
|
||||
KDocLoader factory = new KDocLoader(arguments.docOutputDir);
|
||||
CompilerPlugin processor = factory.createCompilerPlugin();
|
||||
if (processor != null) {
|
||||
environment.getMyEnvironment().getCompilerPlugins().add(processor);
|
||||
}
|
||||
KDocLoader.install(arguments.docOutputDir, environment.getMyEnvironment());
|
||||
}
|
||||
|
||||
if (arguments.stdlib != null) {
|
||||
|
||||
Reference in New Issue
Block a user