From d1c9d0328aa3741e91d7d115ff4e784ae8b24590 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 17 May 2017 14:23:45 +0300 Subject: [PATCH] Report error if is run in fork mode Otherwise the error message is confusing, see #KT-9292 --- .../kotlin/ant/KotlinCompilerAdapter.kt | 6 ++++++ .../integration/ant/jvm/withKotlinFork/A.java | 1 + .../ant/jvm/withKotlinFork/build.log.expected | 16 ++++++++++++++++ .../integration/ant/jvm/withKotlinFork/build.xml | 13 +++++++++++++ .../kotlin/integration/AntTaskTestGenerated.java | 6 ++++++ 5 files changed, 42 insertions(+) create mode 100644 compiler/testData/integration/ant/jvm/withKotlinFork/A.java create mode 100644 compiler/testData/integration/ant/jvm/withKotlinFork/build.log.expected create mode 100644 compiler/testData/integration/ant/jvm/withKotlinFork/build.xml diff --git a/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt b/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt index ccfc0bc4c30..aa6b3e0faeb 100644 --- a/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt +++ b/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt @@ -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(" task does not yet support the fork mode", MSG_ERR) + return false + } + val javac = javac checkAntVersion() diff --git a/compiler/testData/integration/ant/jvm/withKotlinFork/A.java b/compiler/testData/integration/ant/jvm/withKotlinFork/A.java new file mode 100644 index 00000000000..9f4b93d8469 --- /dev/null +++ b/compiler/testData/integration/ant/jvm/withKotlinFork/A.java @@ -0,0 +1 @@ +public class A {} diff --git a/compiler/testData/integration/ant/jvm/withKotlinFork/build.log.expected b/compiler/testData/integration/ant/jvm/withKotlinFork/build.log.expected new file mode 100644 index 00000000000..9010c49387d --- /dev/null +++ b/compiler/testData/integration/ant/jvm/withKotlinFork/build.log.expected @@ -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] 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 diff --git a/compiler/testData/integration/ant/jvm/withKotlinFork/build.xml b/compiler/testData/integration/ant/jvm/withKotlinFork/build.xml new file mode 100644 index 00000000000..02571853d0a --- /dev/null +++ b/compiler/testData/integration/ant/jvm/withKotlinFork/build.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java index 0f8334349e8..a3d28f41344 100644 --- a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java @@ -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/");