diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java index 4b989bd2bbf..2cf1c40ff46 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -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 { @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)); diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompilerArguments.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompilerArguments.java index adbe38d3005..964dfa5ee29 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompilerArguments.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompilerArguments.java @@ -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; } diff --git a/compiler/testData/cli/help.out b/compiler/testData/cli/help.out index d917c1fb853..68e88a4e834 100644 --- a/compiler/testData/cli/help.out +++ b/compiler/testData/cli/help.out @@ -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 diff --git a/compiler/testData/cli/wrongArgument.out b/compiler/testData/cli/wrongArgument.out index 4f4c71db1bc..370e7161fcf 100644 --- a/compiler/testData/cli/wrongArgument.out +++ b/compiler/testData/cli/wrongArgument.out @@ -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 diff --git a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java index 12c438999e9..60fcaa9cdd7 100644 --- a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java @@ -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")); } } diff --git a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/Message.java b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/Message.java index a522645b1f9..d1896c260d7 100644 --- a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/Message.java +++ b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/Message.java @@ -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 diff --git a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/HtmlVisitorTest.kt b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/HtmlVisitorTest.kt index 448fb98752d..f1c60d2ea3e 100644 --- a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/HtmlVisitorTest.kt +++ b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/HtmlVisitorTest.kt @@ -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()) diff --git a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocSampleTest.kt b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocSampleTest.kt index 1b8b9b48521..c545012ae34 100644 --- a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocSampleTest.kt +++ b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocSampleTest.kt @@ -38,6 +38,7 @@ class KDocSampleTest { val compiler = KDocCompiler() val args = KDocArguments() + args.kotlinHome = "../../../dist/kotlinc" args.setSourceDirs(arrayList("src/test/sample")) diff --git a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocTest.kt b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocTest.kt index a7f7c17036b..2ca33c38cd9 100644 --- a/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocTest.kt +++ b/libraries/tools/kdoc/src/test/kotlin/test/kotlin/kdoc/KDocTest.kt @@ -25,6 +25,7 @@ class KDocTest { val args = KDocArguments() //args.setModule(moduleName) + args.kotlinHome = "../../../dist/kotlinc" val sourceDirs = ArrayList() sourceDirs.add("../../stdlib/src") sourceDirs.add("../../kunit/src/main/kotlin") diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index df654dbcac3..fbf969cd934 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -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 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() {