minor change to allow CompilerPlugins to be registered programatically
This commit is contained in:
@@ -18,11 +18,17 @@
|
|||||||
package org.jetbrains.jet.cli;
|
package org.jetbrains.jet.cli;
|
||||||
|
|
||||||
import com.sampullara.cli.Argument;
|
import com.sampullara.cli.Argument;
|
||||||
|
import org.jetbrains.jet.compiler.CompilerPlugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command line arguments for the {@link KotlinCompiler}
|
* Command line arguments for the {@link KotlinCompiler}
|
||||||
*/
|
*/
|
||||||
public class CompilerArguments {
|
public class CompilerArguments {
|
||||||
|
private List<CompilerPlugin> compilerPlugins = new ArrayList<CompilerPlugin>();
|
||||||
|
|
||||||
@Argument(value = "output", description = "output directory")
|
@Argument(value = "output", description = "output directory")
|
||||||
public String outputDir;
|
public String outputDir;
|
||||||
|
|
||||||
@@ -150,4 +156,15 @@ public class CompilerArguments {
|
|||||||
public void setTags(boolean tags) {
|
public void setTags(boolean tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CompilerPlugin> getCompilerPlugins() {
|
||||||
|
return compilerPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the compiler plugins to be used when working with the {@link KotlinCompiler}
|
||||||
|
*/
|
||||||
|
public void setCompilerPlugins(List<CompilerPlugin> compilerPlugins) {
|
||||||
|
this.compilerPlugins = compilerPlugins;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ package org.jetbrains.jet.cli;
|
|||||||
import com.sampullara.cli.Args;
|
import com.sampullara.cli.Args;
|
||||||
import org.jetbrains.jet.compiler.CompileEnvironment;
|
import org.jetbrains.jet.compiler.CompileEnvironment;
|
||||||
import org.jetbrains.jet.compiler.CompileEnvironmentException;
|
import org.jetbrains.jet.compiler.CompileEnvironmentException;
|
||||||
|
import org.jetbrains.jet.compiler.CompilerPlugin;
|
||||||
import org.jetbrains.jet.compiler.MessageRenderer;
|
import org.jetbrains.jet.compiler.MessageRenderer;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.cli.KotlinCompiler.ExitCode.*;
|
import static org.jetbrains.jet.cli.KotlinCompiler.ExitCode.*;
|
||||||
|
|
||||||
@@ -167,6 +169,12 @@ public class KotlinCompiler {
|
|||||||
KDocLoader.install(arguments.docOutputDir, environment.getMyEnvironment());
|
KDocLoader.install(arguments.docOutputDir, environment.getMyEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// install any compiler plugins
|
||||||
|
List<CompilerPlugin> plugins = arguments.getCompilerPlugins();
|
||||||
|
if (plugins != null) {
|
||||||
|
environment.getMyEnvironment().getCompilerPlugins().addAll(plugins);
|
||||||
|
}
|
||||||
|
|
||||||
if (arguments.stdlib != null) {
|
if (arguments.stdlib != null) {
|
||||||
environment.setStdlib(arguments.stdlib);
|
environment.setStdlib(arguments.stdlib);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user