Refactor cli: all the jvm stuff goes under org.jetbrains.jet.cli.jvm, common stuff under org.jetbrains.jet.cli.common

This commit is contained in:
pTalanov
2012-04-25 20:19:15 +04:00
parent b1b9446f13
commit d0d5b147f2
67 changed files with 113 additions and 4056 deletions
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.jetbrains.jet.cli.CompilerArguments;
import org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments;
/**
* Converts Kotlin to JavaScript code
@@ -36,7 +36,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo {
private String outFile;
@Override
protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException {
protected void configureCompilerArguments(K2JVMCompilerArguments arguments) throws MojoExecutionException {
super.configureCompilerArguments(arguments);
K2JSCompilerPlugin plugin = new K2JSCompilerPlugin();
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.maven;
import com.google.common.io.Files;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.compiler.CompilerPlugin;
import org.jetbrains.jet.compiler.CompilerPluginContext;
import org.jetbrains.jet.cli.common.CompilerPlugin;
import org.jetbrains.jet.cli.common.CompilerPluginContext;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.k2js.config.Config;
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.jetbrains.jet.cli.CompilerArguments;
import org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments;
/**
* Compiles kotlin sources
@@ -29,7 +29,7 @@ import org.jetbrains.jet.cli.CompilerArguments;
*/
public class KotlinCompileMojo extends KotlinCompileMojoBase {
@Override
protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException {
protected void configureCompilerArguments(K2JVMCompilerArguments arguments) throws MojoExecutionException {
configureBaseCompilerArguments(getLog(), arguments, module, sources, classpath, output);
}
}
@@ -23,8 +23,10 @@ import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.jetbrains.jet.cli.CompilerArguments;
import org.jetbrains.jet.cli.KotlinCompiler;
import org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import org.jetbrains.jet.cli.common.ExitCode.*;
import org.jetbrains.jet.cli.common.ExitCode;
import java.io.File;
import java.io.IOException;
@@ -104,15 +106,15 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final CompilerArguments arguments = createCompilerArguments();
final K2JVMCompilerArguments arguments = createCompilerArguments();
configureCompilerArguments(arguments);
final KotlinCompiler compiler = createCompiler();
final K2JVMCompiler compiler = createCompiler();
printCompilerArgumentsIfDebugEnabled(arguments, compiler);
final KotlinCompiler.ExitCode exitCode = compiler.exec(System.err, arguments);
final ExitCode exitCode = compiler.exec(System.err, arguments);
switch (exitCode) {
case COMPILATION_ERROR:
@@ -123,7 +125,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
}
}
private void printCompilerArgumentsIfDebugEnabled(CompilerArguments arguments, KotlinCompiler compiler) {
private void printCompilerArgumentsIfDebugEnabled(K2JVMCompilerArguments arguments, K2JVMCompiler compiler) {
if (getLog().isDebugEnabled()) {
getLog().debug("Invoking compiler " + compiler + " with arguments:");
try {
@@ -142,24 +144,24 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
}
}
protected KotlinCompiler createCompiler() {
return new KotlinCompiler();
protected K2JVMCompiler createCompiler() {
return new K2JVMCompiler();
}
/**
* Derived classes can create custom compiler argument implementations
* such as for KDoc
*/
protected CompilerArguments createCompilerArguments() {
return new CompilerArguments();
protected K2JVMCompilerArguments createCompilerArguments() {
return new K2JVMCompilerArguments();
}
/**
* Derived classes can register custom plugins or configurations
*/
protected abstract void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException;
protected abstract void configureCompilerArguments(K2JVMCompilerArguments arguments) throws MojoExecutionException;
protected void configureBaseCompilerArguments(Log log, CompilerArguments arguments, String module,
protected void configureBaseCompilerArguments(Log log, K2JVMCompilerArguments arguments, String module,
List<String> sources, List<String> classpath, String output) throws MojoExecutionException {
// don't include runtime, it should be in maven dependencies
arguments.mode = "stdlib";
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.jetbrains.jet.cli.CompilerArguments;
import org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments;
/**
* Compiles Kotlin test sources
@@ -47,7 +47,7 @@ public class KotlinTestCompileMojo extends KotlinCompileMojoBase {
}
@Override
protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException {
protected void configureCompilerArguments(K2JVMCompilerArguments arguments) throws MojoExecutionException {
configureBaseCompilerArguments(
getLog(), arguments,
testModule, testSources, testClasspath, testOutput);