Merge remote-tracking branch 'remotes/origin/remote-run/shalupov'
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.jet.cli.common.CLICompiler;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.common.messages.*;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CommandLineScriptUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
@@ -37,6 +38,7 @@ import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -57,7 +59,13 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
@Override
|
||||
@NotNull
|
||||
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
||||
KotlinPaths paths = PathUtil.getKotlinPathsForCompiler();
|
||||
KotlinPaths paths = arguments.kotlinHome != null
|
||||
? new KotlinPathsFromHomeDir(new File(arguments.kotlinHome))
|
||||
: PathUtil.getKotlinPathsForCompiler();
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.LOGGING,
|
||||
"Using Kotlin home directory " + paths.getHomePath(), CompilerMessageLocation.NO_LOCATION);
|
||||
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
configuration.addAll(JVMConfigurationKeys.CLASSPATH_KEY, getClasspath(paths, arguments));
|
||||
configuration.addAll(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, getAnnotationsPath(paths, arguments));
|
||||
|
||||
@@ -94,6 +94,17 @@ public class K2JVMCompilerArguments extends CompilerArguments {
|
||||
@Argument(value = "help", alias = "h", description = "show help")
|
||||
public boolean help;
|
||||
|
||||
@Argument(value = "kotlinHome", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
|
||||
public String kotlinHome;
|
||||
|
||||
public String getKotlinHome() {
|
||||
return kotlinHome;
|
||||
}
|
||||
|
||||
public void setKotlinHome(String kotlinHome) {
|
||||
this.kotlinHome = kotlinHome;
|
||||
}
|
||||
|
||||
public String getClasspath() {
|
||||
return classpath;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
|
||||
-verbose [flag] Enable verbose logging output
|
||||
-version [flag] Display compiler version
|
||||
-help (-h) [flag] show help
|
||||
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
OK
|
||||
|
||||
@@ -18,4 +18,5 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
|
||||
-verbose [flag] Enable verbose logging output
|
||||
-version [flag] Display compiler version
|
||||
-help (-h) [flag] show help
|
||||
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
INTERNAL_ERROR
|
||||
|
||||
@@ -70,6 +70,7 @@ public final class JetCompilerMessagingTest extends IDECompilerMessagingTest {
|
||||
checker.expect(Message.info().textStartsWith("Using kotlinHome="));
|
||||
checker.expect(Message.info().textStartsWith("Invoking in-process compiler"));
|
||||
checker.expect(Message.info().textStartsWith("Kotlin Compiler version"));
|
||||
checker.expect(Message.stats().textStartsWith("Using Kotlin home directory"));
|
||||
checker.expect(Message.stats().text("Configuring the compilation environment"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public final class Message {
|
||||
other.message.matches(textMatchesRegexp));
|
||||
return;
|
||||
}
|
||||
Assert.assertEquals(other.message, this.message);
|
||||
Assert.assertEquals(this.message, other.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ class HtmlVisitorTest {
|
||||
println("Generating source HTML to $outDir")
|
||||
|
||||
val args = K2JVMCompilerArguments()
|
||||
args.kotlinHome = "../../../dist/kotlinc"
|
||||
args.setSrc(srcDir.toString())
|
||||
args.setOutputDir(File(dir, "target/classes-htmldocs").toString())
|
||||
args.getCompilerPlugins().add(HtmlCompilerPlugin())
|
||||
|
||||
@@ -38,6 +38,7 @@ class KDocSampleTest {
|
||||
val compiler = KDocCompiler()
|
||||
|
||||
val args = KDocArguments()
|
||||
args.kotlinHome = "../../../dist/kotlinc"
|
||||
|
||||
args.setSourceDirs(arrayList("src/test/sample"))
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ class KDocTest {
|
||||
|
||||
val args = KDocArguments()
|
||||
//args.setModule(moduleName)
|
||||
args.kotlinHome = "../../../dist/kotlinc"
|
||||
val sourceDirs = ArrayList<String>()
|
||||
sourceDirs.add("../../stdlib/src")
|
||||
sourceDirs.add("../../kunit/src/main/kotlin")
|
||||
|
||||
+13
-23
@@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.internal.com.intellij.openapi.util.text.StringUtil.join;
|
||||
@@ -177,9 +178,19 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
||||
Field[] fields = arguments.getClass().getFields();
|
||||
for (Field f : fields) {
|
||||
Object value = f.get(arguments);
|
||||
if (value != null) {
|
||||
getLog().debug(f.getName() + "=" + value);
|
||||
|
||||
String valueString;
|
||||
if (value instanceof Object[]) {
|
||||
valueString = Arrays.deepToString((Object[]) value);
|
||||
}
|
||||
else if (value != null) {
|
||||
valueString = String.valueOf(value);
|
||||
}
|
||||
else {
|
||||
valueString = "(null)";
|
||||
}
|
||||
|
||||
getLog().debug(f.getName() + "=" + valueString);
|
||||
}
|
||||
getLog().debug("End of arguments");
|
||||
}
|
||||
@@ -234,12 +245,6 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
||||
log.debug("Removed target directory from compiler classpath (" + output + ")");
|
||||
}
|
||||
|
||||
// final String runtime = getRuntimeFromClassPath(classpath);
|
||||
// if (runtime != null) {
|
||||
// log.debug("Removed Kotlin runtime from compiler classpath (" + runtime + ")");
|
||||
// classpathList.remove(runtime);
|
||||
// }
|
||||
|
||||
if (classpathList.size() > 0) {
|
||||
final String classPathString = Joiner.on(File.pathSeparator).join(classpathList);
|
||||
log.info("Classpath: " + classPathString);
|
||||
@@ -274,21 +279,6 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
||||
}
|
||||
|
||||
|
||||
// TODO: Make a better runtime detection or get rid of it entirely
|
||||
private String getRuntimeFromClassPath(List<String> classpath) {
|
||||
for (String item : classpath) {
|
||||
final int lastSeparatorIndex = item.lastIndexOf(File.separator);
|
||||
|
||||
if (lastSeparatorIndex < 0)
|
||||
continue;
|
||||
|
||||
if (item.startsWith("kotlin-runtime-", lastSeparatorIndex + 1) && item.endsWith(".jar"))
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private File jdkAnnotationsPath;
|
||||
|
||||
protected File getJdkAnnotations() {
|
||||
|
||||
Reference in New Issue
Block a user