Ant buildtools: added base class for Kotlin compiler ant tasks.

As side effect:
 - used cli compiler in both ant tasks.
 - got the ability to use custom args in JS ant task too.
This commit is contained in:
Zalim Bashorov
2014-08-16 19:34:40 +04:00
parent dc97cdb51c
commit d986b0e565
23 changed files with 283 additions and 434 deletions
@@ -1,5 +1,8 @@
<root>
<item name='org.apache.tools.ant.types.Path java.lang.String[] list()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='org.apache.tools.ant.types.Path org.apache.tools.ant.types.Path createPath()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
</root>
@@ -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.
* <p/>
* 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<Commandline.Argument> additionalArguments = new ArrayList<Commandline.Argument>();
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 <classpath>} 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<String> args = new ArrayList<String>();
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);
}
}
@@ -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<K2JSCompilerArguments>() {
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")
}
}
}
@@ -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.
* <p/>
* 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<K2JVMCompilerArguments>() {
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 <classpath>} 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<String>()
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
}
}
@@ -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());
@@ -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<T : CommonCompilerArguments> : Task() {
protected abstract val arguments: T
protected abstract val compiler: CLICompiler<T>
public var src: Path? = null
public var output: File? = null
public val additionalArguments: MutableList<Commandline.Argument> = 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")
}
}
}
@@ -5,10 +5,10 @@
<antlib>
<taskdef
name = "kotlinc"
classname = "org.jetbrains.jet.buildtools.ant.BytecodeCompilerTask"/>
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JvmTask"/>
<taskdef
name = "kotlin2js"
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsCompilerTask"/>
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsTask"/>
<typedef
name = "withKotlin"
classname = "org.jetbrains.jet.buildtools.ant.KotlinCompilerAdapter"/>
@@ -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<String> 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<String, String>() {
@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<String> 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());
}
}
@@ -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;
}
}
@@ -168,7 +168,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
}
}
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);
@@ -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);
@@ -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
@@ -0,0 +1,9 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlin2js src="${test.data}/hello.kt" output="${temp}/out.js">
<compilerarg value="-Xno-inline"/>
</kotlin2js>
</target>
</project>
@@ -0,0 +1,13 @@
package foo
inline fun foo(f: () -> Unit) = f()
var ok = "Fail"
fun main(args : Array<String>) {
foo {
ok = "OK"
}
}
fun box(): String = ok
@@ -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]
@@ -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
@@ -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]
@@ -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
@@ -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
@@ -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
@@ -5,7 +5,7 @@
<fileset dir="${kotlin.home}" includes="kotlin-runtime.jar"/>
</path>
<taskdef name = "kotlinc" classname = "org.jetbrains.jet.buildtools.ant.BytecodeCompilerTask"/>
<taskdef name = "kotlinc" classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JvmTask"/>
<target name="build">
<delete dir="${temp}/classes" failonerror="false"/>
@@ -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]
@@ -2,7 +2,6 @@ OUT:
Buildfile: [TestData]/build.xml
build:
[kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
ERR: