diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java index 9bdbef0ade1..129348a6203 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java @@ -16,13 +16,13 @@ package org.jetbrains.jet.cli.common.arguments; +import com.intellij.util.SmartList; import com.sampullara.cli.Argument; +import java.util.List; import static org.jetbrains.jet.cli.common.arguments.CommonArgumentConstants.SUPPRESS_WARNINGS; -public abstract class CommonCompilerArguments extends CompilerArguments { - public static final CommonCompilerArguments DUMMY = new DummyImpl(); - +public abstract class CommonCompilerArguments { @Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag") public boolean tags; @Argument(value = "verbose", description = "Enable verbose logging output") @@ -31,54 +31,17 @@ public abstract class CommonCompilerArguments extends CompilerArguments { public boolean version; @Argument(value = "help", alias = "h", description = "Show help") public boolean help; - @Argument(value = "suppress", description = "Suppress compiler messages by severity (warnings)") + @Argument(value = "suppress", description = "Suppress compiler messages by severity (" + SUPPRESS_WARNINGS + ")") public String suppress; @Argument(value = "printArgs", description = "Print commandline arguments") public boolean printArgs; - @Override - public boolean isHelp() { - return help; - } + public List freeArgs = new SmartList(); - public void setHelp(boolean help) { - this.help = help; - } - - @Override - public boolean isTags() { - return tags; - } - - @Override - public boolean isVersion() { - return version; - } - - @Override - public boolean isVerbose() { - return verbose; - } - - @Override - public boolean isPrintArgs() { - return printArgs; - } - - public void setTags(boolean tags) { - this.tags = tags; - } - - @Override public boolean suppressAllWarnings() { return SUPPRESS_WARNINGS.equalsIgnoreCase(suppress); } // Used only for serialize and deserialize settings. Don't use in other places! - public static final class DummyImpl extends CommonCompilerArguments { - @Override - public String getSrc() { - return null; - } - } + public static final class DummyImpl extends CommonCompilerArguments {} } diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CompilerArguments.java deleted file mode 100644 index 69870668c3c..00000000000 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CompilerArguments.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.cli.common.arguments; - -import com.intellij.util.SmartList; - -import java.util.List; - -public abstract class CompilerArguments { - public List freeArgs = new SmartList(); - - public abstract boolean isHelp(); - public abstract boolean isTags(); - public abstract boolean isVersion(); - public abstract boolean isVerbose(); - public abstract boolean isPrintArgs(); - - public abstract String getSrc(); - - public abstract boolean suppressAllWarnings(); -} diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java index b251305761e..b5c3e8b0471 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java @@ -45,9 +45,4 @@ public class K2JSCompilerArguments extends CommonCompilerArguments { @Argument(value = "main", description = "Whether a main function should be called; either '" + CALL + "' or '" + NO_CALL + "', default '" + CALL + "' (main function will be auto detected)") public String main; - - @Override - public String getSrc() { - throw new IllegalStateException(); - } } diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java index c02fc370525..cb3a88e0f83 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java @@ -19,24 +19,11 @@ package org.jetbrains.jet.cli.common.arguments; import com.sampullara.cli.Argument; -import java.util.List; - /** * Command line arguments for the {@link K2JVMCompiler} */ @SuppressWarnings("UnusedDeclaration") public class K2JVMCompilerArguments extends CommonCompilerArguments { - // TODO ideally we'd unify this with 'src' to just having a single field that supports multiple files/dirs - private List sourceDirs; - - public List getSourceDirs() { - return sourceDirs; - } - - public void setSourceDirs(List sourceDirs) { - this.sourceDirs = sourceDirs; - } - @Argument(value = "jar", description = "jar file name") public String jar; @@ -78,65 +65,4 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { @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; - } - - public void setClasspath(String classpath) { - this.classpath = classpath; - } - - public boolean isIncludeRuntime() { - return includeRuntime; - } - - public void setIncludeRuntime(boolean includeRuntime) { - this.includeRuntime = includeRuntime; - } - - public String getJar() { - return jar; - } - - public void setJar(String jar) { - this.jar = jar; - } - - public String getModule() { - return module; - } - - public void setModule(String module) { - this.module = module; - } - - public String getOutputDir() { - return outputDir; - } - - public void setOutputDir(String outputDir) { - this.outputDir = outputDir; - } - - @Override - public String getSrc() { - return src; - } - - public void setSrc(String src) { - this.src = src; - } - - public void setNoStdlib(boolean noStdlib) { - this.noStdlib = noStdlib; - } } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java index b4904c62817..1c6bcc40fc6 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java @@ -24,7 +24,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.sampullara.cli.Args; import com.sampullara.cli.ArgumentUtils; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.messages.*; import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException; import org.jetbrains.jet.config.CompilerConfiguration; @@ -34,7 +34,7 @@ import java.util.List; import static org.jetbrains.jet.cli.common.ExitCode.*; -public abstract class CLICompiler { +public abstract class CLICompiler { @NotNull private List compilerPlugins = Lists.newArrayList(); @@ -112,7 +112,7 @@ public abstract class CLICompiler { */ @NotNull public ExitCode exec(@NotNull PrintStream errStream, @NotNull A arguments) { - if (arguments.isHelp()) { + if (arguments.help) { usage(errStream); return OK; } @@ -123,7 +123,7 @@ public abstract class CLICompiler { printArgumentsIfNeeded(errStream, arguments, messageRenderer); printVersionIfNeeded(errStream, arguments, messageRenderer); - MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.isVerbose()); + MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose); if (arguments.suppressAllWarnings()) { collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING)); @@ -167,7 +167,7 @@ public abstract class CLICompiler { //TODO: can we make it private? @NotNull protected MessageRenderer getMessageRenderer(@NotNull A arguments) { - return arguments.isTags() ? MessageRenderer.TAGS : MessageRenderer.PLAIN; + return arguments.tags ? MessageRenderer.TAGS : MessageRenderer.PLAIN; } protected void printVersionIfNeeded( @@ -175,7 +175,7 @@ public abstract class CLICompiler { @NotNull A arguments, @NotNull MessageRenderer messageRenderer ) { - if (arguments.isVersion()) { + if (arguments.version) { String versionMessage = messageRenderer.render(CompilerMessageSeverity.INFO, "Kotlin Compiler version " + KotlinVersion.VERSION, CompilerMessageLocation.NO_LOCATION); @@ -188,7 +188,7 @@ public abstract class CLICompiler { @NotNull A arguments, @NotNull MessageRenderer messageRenderer ) { - if (arguments.isPrintArgs()) { + if (arguments.printArgs) { String freeArgs = StringUtil.join(arguments.freeArgs, ""); String argumentsAsString = ArgumentUtils.convertArgumentsToString(arguments, createArguments()); String printArgsMessage = messageRenderer.render(CompilerMessageSeverity.INFO, diff --git a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java index db7500831f2..d4cdfc63466 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java @@ -89,7 +89,7 @@ public class K2JSCompiler extends CLICompiler { List sourceFiles = sourceLoader.findSourceFiles(); environmentForJS.getSourceFiles().addAll(sourceFiles); - if (arguments.isVerbose()) { + if (arguments.verbose) { reportCompiledSourcesList(messageCollector, environmentForJS); } 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 8d3e548b5c9..5999c5db000 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -77,13 +77,11 @@ public class K2JVMCompiler extends CLICompiler { return INTERNAL_ERROR; } - List argumentsSourceDirs = arguments.getSourceDirs(); if (!arguments.script && arguments.module == null && arguments.src == null && - arguments.freeArgs.isEmpty() && - (argumentsSourceDirs == null || argumentsSourceDirs.size() == 0)) { - + arguments.freeArgs.isEmpty() + ) { ReplFromTerminal.run(rootDisposable, configuration); return ExitCode.OK; } @@ -93,21 +91,13 @@ public class K2JVMCompiler extends CLICompiler { configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs.get(0)); } else { - // TODO ideally we'd unify to just having a single field that supports multiple files/dirs - if (arguments.getSourceDirs() != null) { - for (String source : arguments.getSourceDirs()) { - configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, source); - } + if (arguments.src != null) { + List sourcePathsSplitByPathSeparator + = Arrays.asList(arguments.src.split(StringUtil.escapeToRegexp(File.pathSeparator))); + configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, sourcePathsSplitByPathSeparator); } - else { - if (arguments.src != null) { - List sourcePathsSplitByPathSeparator - = Arrays.asList(arguments.src.split(StringUtil.escapeToRegexp(File.pathSeparator))); - configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, sourcePathsSplitByPathSeparator); - } - for (String freeArg : arguments.freeArgs) { - configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, freeArg); - } + for (String freeArg : arguments.freeArgs) { + configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, freeArg); } } diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerUtil.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerUtil.java index 02fc3ae786d..9906ceaafdf 100644 --- a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerUtil.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerRunnerUtil.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.compiler.runner; import com.intellij.util.Function; import com.intellij.util.xmlb.XmlSerializer; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.messages.MessageCollector; import org.jetbrains.jet.preloading.ClassPreloadingUtils; import org.jetbrains.jet.utils.KotlinPaths; @@ -41,7 +41,7 @@ import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERRO public class CompilerRunnerUtil { private static final String STRING_ARRAY_CLASS_NAME = String[].class.getName(); - private static final String COMPILER_ARGUMENTS_CLASS_NAME = CompilerArguments.class.getName(); + private static final String COMPILER_ARGUMENTS_CLASS_NAME = CommonCompilerArguments.class.getName(); private static SoftReference ourClassLoaderRef = new SoftReference(null); public static List kompilerClasspath(KotlinPaths paths, MessageCollector messageCollector) { @@ -112,7 +112,7 @@ public class CompilerRunnerUtil { } public static Object invokeExecMethod( - String compilerClassName, CompilerArguments arguments, CompilerEnvironment environment, + String compilerClassName, CommonCompilerArguments arguments, CompilerEnvironment environment, MessageCollector messageCollector, PrintStream out, boolean usePreloader ) throws Exception { return invokeExecMethod(compilerClassName, COMPILER_ARGUMENTS_CLASS_NAME, arguments, environment, messageCollector, out, usePreloader); diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/configuration/KotlinCommonCompilerSettings.java b/idea/src/org/jetbrains/jet/plugin/compiler/configuration/KotlinCommonCompilerSettings.java index 30e0a89e8c8..28f2dd8b033 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/configuration/KotlinCommonCompilerSettings.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/configuration/KotlinCommonCompilerSettings.java @@ -36,7 +36,7 @@ public class KotlinCommonCompilerSettings extends BaseKotlinCompilerSettings ROLE = JpsElementChildRoleBase.create("Kotlin Compiler Settings"); @NotNull - public CommonCompilerArguments commonCompilerSettings = CommonCompilerArguments.DUMMY; + public CommonCompilerArguments commonCompilerSettings = new CommonCompilerArguments.DummyImpl(); @NotNull public K2JVMCompilerArguments k2JvmCompilerSettings = new K2JVMCompilerArguments(); @NotNull diff --git a/jps-plugin/src/org/jetbrains/jet/jps/model/KotlinCommonCompilerSettingsSerializer.java b/jps-plugin/src/org/jetbrains/jet/jps/model/KotlinCommonCompilerSettingsSerializer.java index 9a284e1ebad..4522c25792d 100644 --- a/jps-plugin/src/org/jetbrains/jet/jps/model/KotlinCommonCompilerSettingsSerializer.java +++ b/jps-plugin/src/org/jetbrains/jet/jps/model/KotlinCommonCompilerSettingsSerializer.java @@ -36,7 +36,7 @@ class KotlinCommonCompilerSettingsSerializer extends JpsProjectExtensionSerializ public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) { CommonCompilerArguments settings = XmlSerializer.deserialize(componentTag, CommonCompilerArguments.DummyImpl.class); if (settings == null) { - settings = CommonCompilerArguments.DUMMY; + settings = new CommonCompilerArguments.DummyImpl(); } JpsKotlinCompilerSettings.setCommonSettings(project, settings); diff --git a/libraries/tools/kdoc-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/doc/KDocMojo.java b/libraries/tools/kdoc-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/doc/KDocMojo.java index ab49aaebad3..5e8adbff854 100644 --- a/libraries/tools/kdoc-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/doc/KDocMojo.java +++ b/libraries/tools/kdoc-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/doc/KDocMojo.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.maven.doc; import org.apache.maven.plugin.MojoExecutionException; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.jvm.K2JVMCompiler; import org.jetbrains.kotlin.doc.KDocArguments; @@ -184,7 +184,7 @@ public class KDocMojo extends KotlinCompileMojoBase { } @Override - protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException { + protected void configureCompilerArguments(CommonCompilerArguments arguments) throws MojoExecutionException { if (arguments instanceof K2JVMCompilerArguments) { configureBaseCompilerArguments(getLog(), (K2JVMCompilerArguments) arguments, docModule, sources, classpath, output); } diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/highlighter2/Html2CompilerPlugin.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/highlighter2/Html2CompilerPlugin.kt index 12e5fb22db3..03545f445ad 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/highlighter2/Html2CompilerPlugin.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/highlighter2/Html2CompilerPlugin.kt @@ -27,9 +27,9 @@ class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet private val sourceDirs: List = compilerArguments - .getSourceDirs() + .src .orEmpty() - .requireNoNulls() + .split(File.pathSeparatorChar) .map { path -> File(path).getCanonicalFile()!! } private val sourceDirPaths: List = sourceDirs.map { d -> d.getPath()!! } diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/model/KModelCompilerPlugin.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/model/KModelCompilerPlugin.kt index 5959fb06d72..433d24723d8 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/model/KModelCompilerPlugin.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/model/KModelCompilerPlugin.kt @@ -17,7 +17,7 @@ abstract class KModelCompilerPlugin( public override fun processFiles(context: CompilerPluginContext) { val bindingContext = context.getContext() val sources = context.getFiles() - val sourceDirs: List = arguments.getSourceDirs().orEmpty().requireNoNulls().map { path -> File(path) } + val sourceDirs: List = arguments.src.orEmpty().split(File.pathSeparatorChar).map { path -> File(path) } val model = KModel(bindingContext, arguments.apply(), sourceDirs, sources.requireNoNulls()) processModel(model) 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 a2bd854e218..dde703d4ea7 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 @@ -22,8 +22,8 @@ class HtmlVisitorTest { val args = K2JVMCompilerArguments() args.kotlinHome = "../../../dist/kotlinc" - args.setSrc(srcDir.toString()) - args.setOutputDir(File(dir, "target/classes-htmldocs").toString()) + args.src = srcDir.toString() + args.outputDir = File(dir, "target/classes-htmldocs").toString() val compiler = K2JVMCompiler() compiler.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 c545012ae34..76e9d4737de 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 @@ -40,7 +40,7 @@ class KDocSampleTest { val args = KDocArguments() args.kotlinHome = "../../../dist/kotlinc" - args.setSourceDirs(arrayList("src/test/sample")) + args.src = "src/test/sample" val outputDir = File("target/apidocs-sample") outputDir.rmrf() 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 2ca33c38cd9..053ae915980 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 @@ -8,6 +8,7 @@ import org.jetbrains.kotlin.doc.KDocArguments import org.jetbrains.kotlin.doc.KDocCompiler import org.junit.Assert import org.junit.Test +import com.intellij.openapi.util.text.StringUtil /** */ @@ -24,16 +25,15 @@ class KDocTest { println("Generating library KDocs to $outDir") val args = KDocArguments() - //args.setModule(moduleName) + //args.module = moduleName args.kotlinHome = "../../../dist/kotlinc" - val sourceDirs = ArrayList() - sourceDirs.add("../../stdlib/src") - sourceDirs.add("../../kunit/src/main/kotlin") - sourceDirs.add("../../kotlin-jdbc/src/main/kotlin") - args.setSourceDirs(sourceDirs) - args.setOutputDir("target/classes-stdlib") - args.setNoStdlib(true) - args.setClasspath("../runtime/target/kotlin-runtime-0.1-SNAPSHOT.jar${File.pathSeparator}../../lib/junit-4.9.jar") + val sourceDirs = listOf("../../stdlib/src", + "../../kunit/src/main/kotlin", + "../../kotlin-jdbc/src/main/kotlin") + args.src = sourceDirs.makeString(File.pathSeparator) + args.outputDir = "target/classes-stdlib" + args.noStdlib = true + args.classpath = "../runtime/target/kotlin-runtime-0.1-SNAPSHOT.jar${File.pathSeparator}../../lib/junit-4.9.jar" val config = args.docConfig config.docOutputDir = outDir.toString() diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index be3510e09fa..6f5e17ce2bb 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -90,16 +90,16 @@ public open class KotlinCompile(): AbstractCompile() { return } - val customSources = args.getSourceDirs(); + val customSources = args.src; if (customSources == null || customSources.isEmpty()) { - args.setSourceDirs(sources.map { it.getAbsolutePath() }) + args.src = sources.map { it.getAbsolutePath() } .makeString(File.pathSeparator) } if (StringUtils.isEmpty(kotlinOptions.classpath)) { val existingClasspathEntries = getClasspath().filter(KSpec({ it != null && it.exists() })) val effectiveClassPath = (javaSrcRoots + existingClasspathEntries).makeString(File.pathSeparator) - args.setClasspath(effectiveClassPath) + args.classpath = effectiveClassPath } args.outputDir = if (StringUtils.isEmpty(kotlinOptions.outputDir)) { kotlinDestinationDir?.getPath() } else { kotlinOptions.outputDir } diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java index ac66b540302..b56d4b41faf 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java @@ -21,7 +21,7 @@ import com.google.common.io.InputSupplier; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.jetbrains.jet.cli.common.CLICompiler; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments; import org.jetbrains.jet.cli.js.K2JSCompiler; import com.intellij.openapi.util.io.FileUtil; @@ -150,7 +150,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo { } @Override - protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException { + protected void configureCompilerArguments(CommonCompilerArguments arguments) throws MojoExecutionException { super.configureCompilerArguments(arguments); if (arguments instanceof K2JSCompilerArguments) { @@ -168,7 +168,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo { } @Override - protected CompilerArguments createCompilerArguments() { + protected CommonCompilerArguments createCompilerArguments() { return new K2JSCompilerArguments(); } diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojo.java index 760d106fb0b..5c7abd3829d 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojo.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.maven; import org.apache.maven.plugin.MojoExecutionException; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; /** @@ -30,7 +30,7 @@ import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; */ public class KotlinCompileMojo extends KotlinCompileMojoBase { @Override - protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException { + protected void configureCompilerArguments(CommonCompilerArguments arguments) throws MojoExecutionException { if (arguments instanceof K2JVMCompilerArguments) { configureBaseCompilerArguments(getLog(), (K2JVMCompilerArguments) arguments, module, getSources(), classpath, output); } 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 8f4d97bcf46..07d07d68813 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 @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.maven; -import com.google.common.base.Joiner; import com.intellij.openapi.util.text.StringUtil; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; @@ -28,11 +27,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.ExitCode; import org.jetbrains.jet.cli.common.KotlinVersion; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; +import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation; import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity; import org.jetbrains.jet.cli.common.messages.MessageCollector; -import org.jetbrains.jet.cli.common.arguments.CompilerArguments; -import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.jvm.K2JVMCompiler; import java.io.File; @@ -172,7 +171,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } } - final CompilerArguments arguments = createCompilerArguments(); + final CommonCompilerArguments arguments = createCompilerArguments(); configureCompilerArguments(arguments); final CLICompiler compiler = createCompiler(); @@ -210,7 +209,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } } - private void printCompilerArgumentsIfDebugEnabled(CompilerArguments arguments, CLICompiler compiler) { + private void printCompilerArgumentsIfDebugEnabled(CommonCompilerArguments arguments, CLICompiler compiler) { if (getLog().isDebugEnabled()) { getLog().debug("Invoking compiler " + compiler + " with arguments:"); try { @@ -247,14 +246,14 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { * Derived classes can create custom compiler argument implementations * such as for KDoc */ - protected CompilerArguments createCompilerArguments() { + protected CommonCompilerArguments createCompilerArguments() { return new K2JVMCompilerArguments(); } /** * Derived classes can register custom plugins or configurations */ - protected abstract void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException; + protected abstract void configureCompilerArguments(CommonCompilerArguments arguments) throws MojoExecutionException; protected void configureBaseCompilerArguments(Log log, K2JVMCompilerArguments arguments, String module, List sources, List classpath, String output) throws MojoExecutionException { @@ -265,14 +264,14 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { if (module != null) { log.info("Compiling Kotlin module " + module); - arguments.setModule(module); + arguments.module = module; } else { if (sources.size() <= 0) throw new MojoExecutionException("No source roots to compile"); - arguments.setSourceDirs(sources); - log.info("Compiling Kotlin sources from " + arguments.getSourceDirs()); + arguments.src = join(sources, File.pathSeparator); + log.info("Compiling Kotlin sources from " + arguments.src); // TODO: Move it compiler classpathList.addAll(sources); @@ -285,13 +284,13 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } if (classpathList.size() > 0) { - final String classPathString = Joiner.on(File.pathSeparator).join(classpathList); + String classPathString = join(classpathList, File.pathSeparator); log.info("Classpath: " + classPathString); - arguments.setClasspath(classPathString); + arguments.classpath = classPathString; } log.info("Classes directory is " + output); - arguments.setOutputDir(output); + arguments.outputDir = output; arguments.noJdkAnnotations = true; arguments.annotations = getFullAnnotationsPath(log, annotationPaths); diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java index 6d13b88b68c..4abb354be9d 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java @@ -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.common.arguments.CompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import java.util.List; @@ -86,7 +86,7 @@ public class KotlinTestCompileMojo extends KotlinCompileMojoBase { } @Override - protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException { + protected void configureCompilerArguments(CommonCompilerArguments arguments) throws MojoExecutionException { if (arguments instanceof K2JVMCompilerArguments) { configureBaseCompilerArguments( getLog(), (K2JVMCompilerArguments) arguments,