diff --git a/annotations/org/apache/tools/ant/types/annotations.xml b/annotations/org/apache/tools/ant/types/annotations.xml
index 7d0d1cbb5db..b5a4488bf1b 100644
--- a/annotations/org/apache/tools/ant/types/annotations.xml
+++ b/annotations/org/apache/tools/ant/types/annotations.xml
@@ -1,5 +1,8 @@
+ -
+
+
-
-
\ No newline at end of file
+
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java
deleted file mode 100644
index 723c8f24aae..00000000000
--- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java
+++ /dev/null
@@ -1,151 +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.buildtools.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-import org.jetbrains.jet.buildtools.core.BytecodeCompiler;
-import org.jetbrains.jet.buildtools.core.Util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.jetbrains.jet.buildtools.core.Util.getPath;
-
-
-/**
- * Kotlin bytecode compiler Ant task.
- *
- * See
- * http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
- * http://evgeny-goldin.org/javadoc/ant/develop.html
- * http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
- */
-public class BytecodeCompilerTask extends Task {
- private File output;
- private File stdlib;
- private Path src;
- private Path externalAnnotations;
- private Path compileClasspath;
- private boolean includeRuntime = true;
- private final List additionalArguments = new ArrayList();
-
- public void setOutput(File output) {
- this.output = output;
- }
-
- public void setStdlib(File stdlib) {
- this.stdlib = stdlib;
- }
-
- public void setSrc(Path src) {
- this.src = src;
- }
-
- public Path createSrc() {
- if (src == null) {
- src = new Path(getProject());
- }
- return src.createPath();
- }
-
- public void setExternalAnnotations(Path externalAnnotations) {
- this.externalAnnotations = externalAnnotations;
- }
-
- public Path createExternalAnnotations() {
- if (externalAnnotations == null) {
- externalAnnotations = new Path(getProject());
- }
- return externalAnnotations.createPath();
- }
-
- public void setIncludeRuntime(boolean includeRuntime) {
- this.includeRuntime = includeRuntime;
- }
-
- public Commandline.Argument createCompilerArg() {
- Commandline.Argument argument = new Commandline.Argument();
- additionalArguments.add(argument);
- return argument;
- }
-
- /**
- * Set the classpath to be used for this compilation.
- *
- * @param classpath an Ant Path object containing the compilation classpath.
- */
- public void setClasspath(Path classpath) {
- if (this.compileClasspath == null) {
- this.compileClasspath = classpath;
- }
- else {
- this.compileClasspath.append(classpath);
- }
- }
-
- /**
- * Adds a reference to a classpath defined elsewhere.
- *
- * @param ref a reference to a classpath.
- */
- public void setClasspathRef(Reference ref) {
- if (this.compileClasspath == null) {
- this.compileClasspath = new Path(getProject());
- }
- this.compileClasspath.createPath().setRefid(ref);
- }
-
- /**
- * Set the nested {@code } to be used for this compilation.
- *
- * @param classpath an Ant Path object containing the compilation classpath.
- */
- public void addConfiguredClasspath(Path classpath) {
- setClasspath(classpath);
- }
-
- @Override
- public void execute() {
- String stdlibPath = stdlib != null ? getPath(stdlib) : null;
- String[] classpath = compileClasspath != null ? compileClasspath.list() : null;
- String[] externalAnnotationsPath = externalAnnotations != null ? externalAnnotations.list() : null;
-
- List args = new ArrayList();
- for (Commandline.Argument argument : additionalArguments) {
- args.addAll(Arrays.asList(argument.getParts()));
- }
-
- if (src == null) {
- throw new BuildException("\"src\" should be specified");
- }
- if (output == null) {
- throw new BuildException("\"output\" should be specified");
- }
-
- String[] source = Util.getPaths(src.list());
- String destination = getPath(output);
-
- log(String.format("Compiling [%s] => [%s]", Arrays.toString(source), destination));
- BytecodeCompiler.compileSources(source, destination, includeRuntime, stdlibPath, classpath, externalAnnotationsPath, args);
- }
-}
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsCompilerTask.kt b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsTask.kt
similarity index 59%
rename from build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsCompilerTask.kt
rename to build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsTask.kt
index 4801456d017..c19ac8710f5 100644
--- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsCompilerTask.kt
+++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JsTask.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 JetBrains s.r.o.
+ * Copyright 2010-2014 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.
@@ -16,10 +16,7 @@
package org.jetbrains.jet.buildtools.ant
-import org.apache.tools.ant.Task
import org.apache.tools.ant.types.Path
-import org.apache.tools.ant.types.Reference
-import org.jetbrains.jet.buildtools.core.Util
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
import org.jetbrains.jet.cli.js.K2JSCompiler
@@ -32,9 +29,10 @@ import org.jetbrains.jet.config.Services
* Kotlin JavaScript compiler Ant task.
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
*/
-public class Kotlin2JsCompilerTask : Task() {
- public var src: Path? = null
- public var output: File? = null
+public class Kotlin2JsTask : KotlinCompilerBaseTask() {
+ override val arguments = K2JSCompilerArguments()
+ override val compiler = K2JSCompiler()
+
public var library: Path? = null
public var outputPrefix: File? = null
public var outputPostfix: File? = null
@@ -46,21 +44,6 @@ public class Kotlin2JsCompilerTask : Task() {
*/
public var main: String? = null
- public fun createSrc(): Path {
- val srcPath = src
- if (srcPath == null) {
- val t = Path(getProject())
- src = t
- return t
- }
-
- return srcPath.createPath()
- }
-
- public fun setSrcRef(ref: Reference) {
- createSrc().setRefid(ref)
- }
-
public fun createLibrary(): Path {
val libraryPath = library
if (libraryPath == null) {
@@ -72,28 +55,13 @@ public class Kotlin2JsCompilerTask : Task() {
return libraryPath.createPath()
}
- override fun execute(): Unit {
- val arguments = K2JSCompilerArguments()
-
- val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
- arguments.freeArgs = Util.getPaths(sourcePaths.list()).toList()
-
- val outputFile = output ?: throw BuildException("\"output\" should be specified")
- arguments.outputFile = outputFile.canonicalPath
+ override fun fillSpecificArguments() {
+ arguments.outputFile = getPath(output!!)
arguments.outputPrefix = outputPrefix?.canonicalPath
arguments.outputPostfix = outputPostfix?.canonicalPath
arguments.main = main
arguments.sourceMap = sourceMap
-
- log("Compiling ${arguments.freeArgs} => [${arguments.outputFile}]");
-
- val compiler = K2JSCompiler()
- val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, Services.EMPTY, arguments)
-
- if (exitCode != ExitCode.OK) {
- throw BuildException("Compilation finished with exit code $exitCode")
- }
}
}
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JvmTask.kt b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JvmTask.kt
new file mode 100644
index 00000000000..dbe9ac4c735
--- /dev/null
+++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/Kotlin2JvmTask.kt
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2010-2014 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.buildtools.ant
+
+import org.apache.tools.ant.types.Path
+import org.apache.tools.ant.types.Reference
+
+import java.io.File
+import java.io.File.pathSeparator
+
+import org.jetbrains.jet.cli.jvm.K2JVMCompiler
+import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
+import com.intellij.openapi.util.io.FileUtilRt
+
+
+/**
+ * Kotlin bytecode compiler Ant task.
+ *
+ * See
+ * http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
+ * http://evgeny-goldin.org/javadoc/ant/develop.html
+ * http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
+ */
+public class Kotlin2JvmTask : KotlinCompilerBaseTask() {
+ override val arguments = K2JVMCompilerArguments()
+ override val compiler = K2JVMCompiler()
+
+ public var noStdlib: Boolean = false
+ public var externalAnnotations: Path? = null
+ public var includeRuntime: Boolean = true
+
+ private var compileClasspath: Path? = null
+
+ public fun createExternalAnnotations(): Path {
+ if (externalAnnotations == null) {
+ externalAnnotations = Path(getProject())
+ }
+ return externalAnnotations!!.createPath()
+ }
+
+ /**
+ * Set the classpath to be used for this compilation.
+ *
+ * @param classpath an Ant Path object containing the compilation classpath.
+ */
+ public fun setClasspath(classpath: Path) {
+ if (this.compileClasspath == null) {
+ this.compileClasspath = classpath
+ }
+ else {
+ this.compileClasspath!!.append(classpath)
+ }
+ }
+
+ /**
+ * Adds a reference to a classpath defined elsewhere.
+ *
+ * @param ref a reference to a classpath.
+ */
+ public fun setClasspathRef(ref: Reference) {
+ if (this.compileClasspath == null) {
+ this.compileClasspath = Path(getProject())
+ }
+ this.compileClasspath!!.createPath().setRefid(ref)
+ }
+
+ /**
+ * Set the nested {@code } to be used for this compilation.
+ *
+ * @param classpath an Ant Path object containing the compilation classpath.
+ */
+ public fun addConfiguredClasspath(classpath: Path) {
+ setClasspath(classpath)
+ }
+
+ override fun fillSpecificArguments() {
+ arguments.destination = getPath(output!!)
+
+ val classpath = arrayListOf()
+ compileClasspath?.let { classpath.addAll(it.list()) }
+ arguments.freeArgs?.forEach {
+ val file = File(it)
+ if (file.isDirectory() || file.extension != "kt") {
+ classpath.add(it)
+ }
+ }
+
+ arguments.classpath = classpath.join(pathSeparator)
+
+ arguments.annotations = externalAnnotations?.list()?.join(pathSeparator)
+ arguments.noStdlib = noStdlib
+ arguments.includeRuntime = includeRuntime
+ }
+}
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerAdapter.java b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerAdapter.java
index 39dd6463d78..ed6458a39a0 100644
--- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerAdapter.java
+++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerAdapter.java
@@ -40,7 +40,7 @@ public class KotlinCompilerAdapter extends DefaultCompilerAdapter {
public boolean execute() throws BuildException {
Javac javac = getJavac();
- BytecodeCompilerTask kotlinTask = new BytecodeCompilerTask();
+ Kotlin2JvmTask kotlinTask = new Kotlin2JvmTask();
kotlinTask.setOutput(javac.getDestdir());
kotlinTask.setClasspath(javac.getClasspath());
kotlinTask.setSrc(javac.getSrcdir());
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerBaseTask.kt b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerBaseTask.kt
new file mode 100644
index 00000000000..c3ccf4a7739
--- /dev/null
+++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/KotlinCompilerBaseTask.kt
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2010-2014 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.buildtools.ant
+
+import org.apache.tools.ant.Task
+import org.apache.tools.ant.types.Path
+import org.apache.tools.ant.types.Reference
+import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
+import java.io.File
+import org.apache.tools.ant.BuildException
+import org.jetbrains.jet.cli.common.ExitCode
+import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
+import org.jetbrains.jet.cli.common.CLICompiler
+import org.apache.tools.ant.types.Commandline
+import com.sampullara.cli.Args
+import java.io.IOException
+import org.jetbrains.jet.config
+
+/**
+ * {@code file.getCanonicalPath()} convenience wrapper.
+ *
+ * @param file - file to get its canonical path.
+ * @return file's canonical path
+ */
+fun getPath(file: File): String {
+ try {
+ return file.getCanonicalPath()
+ }
+ catch (e: IOException) {
+ throw RuntimeException("Failed to resolve canonical file of [$file]: $e", e)
+ }
+}
+
+/**
+ * Base class for Kotlin compiler Ant tasks.
+ * http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
+ */
+public abstract class KotlinCompilerBaseTask : Task() {
+ protected abstract val arguments: T
+ protected abstract val compiler: CLICompiler
+
+ public var src: Path? = null
+ public var output: File? = null
+
+ public val additionalArguments: MutableList = arrayListOf()
+
+ public fun createSrc(): Path {
+ val srcPath = src
+ if (srcPath == null) {
+ val t = Path(getProject())
+ src = t
+ return t
+ }
+
+ return srcPath.createPath()
+ }
+
+ public fun setSrcRef(ref: Reference) {
+ createSrc().setRefid(ref)
+ }
+
+ public fun createCompilerArg(): Commandline.Argument {
+ val argument = Commandline.Argument()
+ additionalArguments.add(argument)
+ return argument
+ }
+
+ abstract fun fillSpecificArguments()
+
+ private fun fillArguments() {
+ val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
+ arguments.freeArgs = sourcePaths.list().map { getPath(File(it)) }
+
+ output ?: throw BuildException("\"output\" should be specified")
+
+ val args = additionalArguments.flatMap { it.getParts()!!.toList() }
+ try {
+ Args.parse(arguments, args.copyToArray())
+ }
+ catch (e: IllegalArgumentException) {
+ throw BuildException(e.getMessage())
+ }
+
+ fillSpecificArguments()
+ }
+
+ final override fun execute(): Unit {
+ fillArguments()
+
+ val outputPath = getPath(output!!)
+
+ log("Compiling ${arguments.freeArgs} => [${outputPath}]");
+
+ val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, config.Services.EMPTY, arguments)
+
+ if (exitCode != ExitCode.OK) {
+ throw BuildException("Compilation finished with exit code $exitCode")
+ }
+ }
+}
diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/antlib.xml b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/antlib.xml
index 99b545c88d6..8af55eaf980 100644
--- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/antlib.xml
+++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/antlib.xml
@@ -5,10 +5,10 @@
+ classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JvmTask"/>
+ classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsTask"/>
diff --git a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java
deleted file mode 100644
index 2acaf470116..00000000000
--- a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java
+++ /dev/null
@@ -1,177 +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.buildtools.core;
-
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.io.FileUtilRt;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.Function;
-import com.sampullara.cli.Args;
-import org.apache.tools.ant.BuildException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
-import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
-import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
-import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
-import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
-import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
-import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
-import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
-import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
-import org.jetbrains.jet.config.CompilerConfiguration;
-import org.jetbrains.jet.utils.KotlinPaths;
-import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
-import org.jetbrains.jet.utils.PathUtil;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
-import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
-
-public class BytecodeCompiler {
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- @NotNull
- private static CompilerConfiguration createConfiguration(
- @Nullable String stdlib,
- @Nullable String[] classpath,
- @Nullable String[] externalAnnotationsPath,
- @NotNull String[] sourceRoots,
- @NotNull List args
- ) {
- KotlinPaths paths = getKotlinPathsForAntTask();
- CompilerConfiguration configuration = new CompilerConfiguration();
- configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
-
- configuration.addAll(CLASSPATH_KEY, PathUtil.getJdkClassesRoots());
- if ((stdlib != null) && (stdlib.trim().length() > 0)) {
- configuration.add(CLASSPATH_KEY, new File(stdlib));
- }
- else {
- File path = paths.getRuntimePath();
- if (path.exists()) {
- configuration.add(CLASSPATH_KEY, path);
- }
- }
- if ((classpath != null) && (classpath.length > 0)) {
- for (String path : classpath) {
- configuration.add(CLASSPATH_KEY, new File(path));
- }
- }
- if ((externalAnnotationsPath != null) && (externalAnnotationsPath.length > 0)) {
- for (String path : externalAnnotationsPath) {
- configuration.add(ANNOTATIONS_PATH_KEY, new File(path));
- }
- }
- File jdkAnnotationsPath = paths.getJdkAnnotationsPath();
- if (jdkAnnotationsPath.exists()) {
- configuration.add(ANNOTATIONS_PATH_KEY, jdkAnnotationsPath);
- }
-
- CompileEnvironmentUtil.addSourceFilesCheckingForDuplicates(configuration, Arrays.asList(sourceRoots));
- for (String sourceRoot : sourceRoots) {
- File file = new File(sourceRoot);
- if (!file.isFile() || !"kt".equals(FileUtilRt.getExtension(file.getName()))) {
- configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, file);
- }
- }
-
- // TODO: use K2JVMCompiler directly, don't duplicate this code here
- K2JVMCompilerArguments arguments = new K2JVMCompilerArguments();
- try {
- Args.parse(arguments, ArrayUtil.toStringArray(args));
- }
- catch (IllegalArgumentException e) {
- throw new BuildException(e.getMessage());
- }
-
- K2JVMCompiler.putAdvancedOptions(configuration, arguments);
-
- return configuration;
- }
-
- private static String errorMessage(@NotNull String[] source, boolean exceptionThrown) {
- return String.format("Compilation of the following source roots failed:" + LINE_SEPARATOR +
- getAbsolutePaths(source) +
- (exceptionThrown ? "" : LINE_SEPARATOR + "see \"ERROR:\" messages above for more details."));
- }
-
- private static String getAbsolutePaths(String[] source) {
- return StringUtil.join(
- source,
- new Function() {
- @Override
- public String fun(String s) {
- return " * " + new File(s).getAbsolutePath();
- }
- },
- LINE_SEPARATOR
- );
- }
-
- /**
- * {@code KotlinToJVMBytecodeCompiler#compileBunchOfSources} wrapper.
- * @param src compilation source (directory or file)
- * @param destination compilation destination (directory or jar)
- * @param includeRuntime whether Kotlin runtime library is included in destination jar
- * @param stdlib "kotlin-runtime.jar" path
- * @param args additional command line arguments to Kotlin compiler
- */
- public static void compileSources(
- @NotNull String[] src,
- @NotNull String destination,
- boolean includeRuntime,
- @Nullable String stdlib,
- @Nullable String[] classpath,
- @Nullable String[] externalAnnotationsPath,
- @NotNull List args
- ) {
- try {
- JetCoreEnvironment environment = JetCoreEnvironment.createForProduction(
- Disposer.newDisposable(),
- createConfiguration(stdlib, classpath, externalAnnotationsPath, src, args)
- );
-
- // TODO: use K2JVMCompiler directly, don't duplicate this code here
- boolean isJar = destination.endsWith(".jar");
- File jar = isJar ? new File(destination) : null;
- File outputDir = isJar ? null : new File(destination);
-
- boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, includeRuntime);
- if (!success) {
- throw new CompileEnvironmentException(errorMessage(src, false));
- }
- }
- catch (BuildException e) {
- throw e;
- }
- catch (CompileEnvironmentException e) {
- throw e;
- }
- catch (Exception e) {
- throw new CompileEnvironmentException(errorMessage(src, true), e);
- }
- }
-
- private static KotlinPaths getKotlinPathsForAntTask() {
- return new KotlinPathsFromHomeDir(PathUtil.getJarPathForClass(BytecodeCompiler.class).getParentFile().getParentFile());
- }
-}
diff --git a/build-tools/core/src/org/jetbrains/jet/buildtools/core/Util.java b/build-tools/core/src/org/jetbrains/jet/buildtools/core/Util.java
deleted file mode 100644
index 2eb86c342ae..00000000000
--- a/build-tools/core/src/org/jetbrains/jet/buildtools/core/Util.java
+++ /dev/null
@@ -1,53 +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.buildtools.core;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.io.IOException;
-
-public final class Util {
- private Util() {
- }
-
- /**
- * {@code file.getCanonicalPath()} convenience wrapper.
- *
- * @param f file to get its canonical path.
- * @return file's canonical path
- */
- @NotNull
- public static String getPath(@NotNull File f) {
- try {
- return f.getCanonicalPath();
- }
- catch (IOException e) {
- throw new RuntimeException(String.format("Failed to resolve canonical file of [%s]: %s", f, e), e);
- }
- }
-
- @NotNull
- public static String[] getPaths(String[] paths) {
- String[] result = new String[paths.length];
- for (int i = 0; i < paths.length; i++) {
- String path = paths[i];
- result[i] = getPath(new File(path));
- }
- return result;
- }
-}
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 696ca5d25f2..156a30a441b 100644
--- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java
+++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java
@@ -168,7 +168,7 @@ public class K2JVMCompiler extends CLICompiler {
}
}
- public static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
+ private static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline);
diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/AntTaskJsTest.java b/compiler/integration-tests/src/org/jetbrains/kotlin/AntTaskJsTest.java
index b000d33277b..fe39293c8ad 100644
--- a/compiler/integration-tests/src/org/jetbrains/kotlin/AntTaskJsTest.java
+++ b/compiler/integration-tests/src/org/jetbrains/kotlin/AntTaskJsTest.java
@@ -97,6 +97,12 @@ public class AntTaskJsTest extends AntTaskBaseTest {
doJsAntTest();
}
+ @Test
+ public void additionalArguments() throws Exception {
+ doJsAntTest();
+ }
+
+
@Test
public void noSrcParam() throws Exception {
doAntTest(FAILED);
diff --git a/compiler/integration-tests/testData/ant/js/additionalArguments/build.log.expected b/compiler/integration-tests/testData/ant/js/additionalArguments/build.log.expected
new file mode 100644
index 00000000000..dcf3f910d90
--- /dev/null
+++ b/compiler/integration-tests/testData/ant/js/additionalArguments/build.log.expected
@@ -0,0 +1,10 @@
+OUT:
+Buildfile: [TestData]/build.xml
+
+build:
+[kotlin2js] Compiling [[TestData]/hello.kt] => [[Temp]/out.js]
+
+BUILD SUCCESSFUL
+Total time: [time]
+
+Return code: 0
diff --git a/compiler/integration-tests/testData/ant/js/additionalArguments/build.xml b/compiler/integration-tests/testData/ant/js/additionalArguments/build.xml
new file mode 100644
index 00000000000..92c46ef3e30
--- /dev/null
+++ b/compiler/integration-tests/testData/ant/js/additionalArguments/build.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/compiler/integration-tests/testData/ant/js/additionalArguments/hello.kt b/compiler/integration-tests/testData/ant/js/additionalArguments/hello.kt
new file mode 100644
index 00000000000..7f2fc04541b
--- /dev/null
+++ b/compiler/integration-tests/testData/ant/js/additionalArguments/hello.kt
@@ -0,0 +1,13 @@
+package foo
+
+inline fun foo(f: () -> Unit) = f()
+
+var ok = "Fail"
+
+fun main(args : Array) {
+ foo {
+ ok = "OK"
+ }
+}
+
+fun box(): String = ok
\ No newline at end of file
diff --git a/compiler/integration-tests/testData/ant/jvm/additionalArguments/build.log.expected b/compiler/integration-tests/testData/ant/jvm/additionalArguments/build.log.expected
index 34c09a5fcbf..bdd3291fcb4 100644
--- a/compiler/integration-tests/testData/ant/jvm/additionalArguments/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/additionalArguments/build.log.expected
@@ -2,7 +2,7 @@ OUT:
Buildfile: [TestData]/build.xml
build:
- [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
+ [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
BUILD SUCCESSFUL
Total time: [time]
diff --git a/compiler/integration-tests/testData/ant/jvm/externalAnnotations/build.log.expected b/compiler/integration-tests/testData/ant/jvm/externalAnnotations/build.log.expected
index a49d8d0e5d7..1ee5576831e 100644
--- a/compiler/integration-tests/testData/ant/jvm/externalAnnotations/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/externalAnnotations/build.log.expected
@@ -4,7 +4,7 @@ Buildfile: [TestData]/build.xml
build:
[mkdir] Created dir: [Temp]/classes
[javac] Compiling 1 source file to [Temp]/classes
- [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes]
+ [javac] Compiling [[TestData]/root1] => [[Temp]/classes]
[javac] Running javac...
[jar] Building jar: [Temp]/hello.jar
diff --git a/compiler/integration-tests/testData/ant/jvm/helloWorld/build.log.expected b/compiler/integration-tests/testData/ant/jvm/helloWorld/build.log.expected
index 34c09a5fcbf..bdd3291fcb4 100644
--- a/compiler/integration-tests/testData/ant/jvm/helloWorld/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/helloWorld/build.log.expected
@@ -2,7 +2,7 @@ OUT:
Buildfile: [TestData]/build.xml
build:
- [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
+ [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
BUILD SUCCESSFUL
Total time: [time]
diff --git a/compiler/integration-tests/testData/ant/jvm/javacCompiler/build.log.expected b/compiler/integration-tests/testData/ant/jvm/javacCompiler/build.log.expected
index a49d8d0e5d7..1ee5576831e 100644
--- a/compiler/integration-tests/testData/ant/jvm/javacCompiler/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/javacCompiler/build.log.expected
@@ -4,7 +4,7 @@ Buildfile: [TestData]/build.xml
build:
[mkdir] Created dir: [Temp]/classes
[javac] Compiling 1 source file to [Temp]/classes
- [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes]
+ [javac] Compiling [[TestData]/root1] => [[Temp]/classes]
[javac] Running javac...
[jar] Building jar: [Temp]/hello.jar
diff --git a/compiler/integration-tests/testData/ant/jvm/jvmClasspath/build.log.expected b/compiler/integration-tests/testData/ant/jvm/jvmClasspath/build.log.expected
index ff68326aa0b..96877f22514 100644
--- a/compiler/integration-tests/testData/ant/jvm/jvmClasspath/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/jvmClasspath/build.log.expected
@@ -2,7 +2,7 @@ OUT:
Buildfile: [TestData]/build.xml
build:
- [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
+ [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
[kotlinc] WARNING: [TestData]/hello.kt: (15, 9) Variable 'result' is never used
BUILD SUCCESSFUL
diff --git a/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.log.expected b/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.log.expected
index 62250d3a0ad..ab5952486d8 100644
--- a/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.log.expected
@@ -3,7 +3,7 @@ Buildfile: [TestData]/build.xml
build:
[mkdir] Created dir: [Temp]/classes
- [kotlinc] Compiling [[[TestData]/root1]] => [[Temp]/classes]
+ [kotlinc] Compiling [[TestData]/root1] => [[Temp]/classes]
[javac] Compiling 1 source file to [Temp]/classes
[jar] Building jar: [Temp]/hello.jar
diff --git a/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.xml b/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.xml
index 73359810bf0..6241cdb30d0 100644
--- a/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.xml
+++ b/compiler/integration-tests/testData/ant/jvm/kotlinCompiler/build.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/compiler/integration-tests/testData/ant/jvm/manySourceRoots/build.log.expected b/compiler/integration-tests/testData/ant/jvm/manySourceRoots/build.log.expected
index 7dcbaeb2979..b54473ee360 100644
--- a/compiler/integration-tests/testData/ant/jvm/manySourceRoots/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/manySourceRoots/build.log.expected
@@ -2,7 +2,7 @@ OUT:
Buildfile: [TestData]/build.xml
build:
- [kotlinc] Compiling [[[TestData]/root1, [TestData]/root2]] => [[Temp]/hello.jar]
+ [kotlinc] Compiling [[TestData]/root1, [TestData]/root2] => [[Temp]/hello.jar]
BUILD SUCCESSFUL
Total time: [time]
diff --git a/compiler/integration-tests/testData/ant/jvm/wrongArguments/build.log.expected b/compiler/integration-tests/testData/ant/jvm/wrongArguments/build.log.expected
index 68ea6c0dcea..c3fabbb7cd1 100644
--- a/compiler/integration-tests/testData/ant/jvm/wrongArguments/build.log.expected
+++ b/compiler/integration-tests/testData/ant/jvm/wrongArguments/build.log.expected
@@ -2,7 +2,6 @@ OUT:
Buildfile: [TestData]/build.xml
build:
- [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
ERR: