Report error if <withKotlin> is run in fork mode

Otherwise the error message is confusing, see #KT-9292
This commit is contained in:
Alexander Udalov
2017-05-17 14:23:45 +03:00
parent 671aed252d
commit d1c9d0328a
5 changed files with 42 additions and 0 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.ant
import org.apache.tools.ant.BuildException
import org.apache.tools.ant.MagicNames
import org.apache.tools.ant.Project.MSG_ERR
import org.apache.tools.ant.Project.MSG_WARN
import org.apache.tools.ant.taskdefs.compilers.Javac13
import org.apache.tools.ant.taskdefs.condition.AntVersion
@@ -44,6 +45,11 @@ class KotlinCompilerAdapter : Javac13() {
@Throws(BuildException::class)
override fun execute(): Boolean {
if (javac.isForkedJavac) {
javac.log("<withKotlin> task does not yet support the fork mode", MSG_ERR)
return false
}
val javac = javac
checkAntVersion()
@@ -0,0 +1 @@
public class A {}
@@ -0,0 +1,16 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[mkdir] Created dir: [Temp]/classes
[javac] Compiling 1 source file to [Temp]/classes
ERR:
[javac] <withKotlin> task does not yet support the fork mode
BUILD FAILED
[TestData]/build.xml:6: Compile failed; see the compiler error output for details.
Total time: [time]
Return code: 1
@@ -0,0 +1,13 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<mkdir dir="${temp}/classes"/>
<javac fork="yes" memorymaximumsize="1G" srcdir="${test.data}" destdir="${temp}/classes" includeantruntime="false">
<withKotlin/>
</javac>
<jar destfile="${temp}/hello.jar">
<fileset dir="${temp}/classes"/>
</jar>
</target>
</project>
@@ -150,6 +150,12 @@ public class AntTaskTestGenerated extends AbstractAntTaskTest {
doTest(fileName);
}
@TestMetadata("withKotlinFork")
public void testWithKotlinFork() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/withKotlinFork/");
doTest(fileName);
}
@TestMetadata("withKotlinNoJavaSources")
public void testWithKotlinNoJavaSources() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/withKotlinNoJavaSources/");