Ant task: warn when Ant version < 1.8.2
This commit is contained in:
@@ -19,8 +19,10 @@ package org.jetbrains.kotlin.ant;
|
|||||||
import kotlin.KotlinPackage;
|
import kotlin.KotlinPackage;
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.MagicNames;
|
||||||
import org.apache.tools.ant.taskdefs.Javac;
|
import org.apache.tools.ant.taskdefs.Javac;
|
||||||
import org.apache.tools.ant.taskdefs.compilers.Javac13;
|
import org.apache.tools.ant.taskdefs.compilers.Javac13;
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.AntVersion;
|
||||||
import org.apache.tools.ant.types.Path;
|
import org.apache.tools.ant.types.Path;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ import java.io.File;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.apache.tools.ant.Project.MSG_WARN;
|
||||||
|
|
||||||
public class KotlinCompilerAdapter extends Javac13 {
|
public class KotlinCompilerAdapter extends Javac13 {
|
||||||
private static final List<String> KOTLIN_EXTENSIONS = Arrays.asList("kt", "kts");
|
private static final List<String> KOTLIN_EXTENSIONS = Arrays.asList("kt", "kts");
|
||||||
|
|
||||||
@@ -55,6 +59,8 @@ public class KotlinCompilerAdapter extends Javac13 {
|
|||||||
public boolean execute() throws BuildException {
|
public boolean execute() throws BuildException {
|
||||||
Javac javac = getJavac();
|
Javac javac = getJavac();
|
||||||
|
|
||||||
|
checkAntVersion();
|
||||||
|
|
||||||
Kotlin2JvmTask kotlinc = new Kotlin2JvmTask();
|
Kotlin2JvmTask kotlinc = new Kotlin2JvmTask();
|
||||||
kotlinc.setFailOnError(javac.getFailonerror());
|
kotlinc.setFailOnError(javac.getFailonerror());
|
||||||
kotlinc.setOutput(javac.getDestdir());
|
kotlinc.setOutput(javac.getDestdir());
|
||||||
@@ -84,6 +90,17 @@ public class KotlinCompilerAdapter extends Javac13 {
|
|||||||
return compileList.length == 0 || super.execute();
|
return compileList.length == 0 || super.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAntVersion() {
|
||||||
|
AntVersion checkVersion = new AntVersion();
|
||||||
|
checkVersion.setAtLeast("1.8.2");
|
||||||
|
if (!checkVersion.eval()) {
|
||||||
|
getJavac().log("<withKotlin> task requires Ant of version at least 1.8.2 to operate reliably. " +
|
||||||
|
"Please upgrade or, as a workaround, make sure you have at least one Java source and " +
|
||||||
|
"the output directory is clean before running this task. " +
|
||||||
|
"You have: " + getProject().getProperty(MagicNames.ANT_VERSION), MSG_WARN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static File[] filterOutKotlinSources(@NotNull File[] files) {
|
private static File[] filterOutKotlinSources(@NotNull File[] files) {
|
||||||
List<File> nonKotlinSources = KotlinPackage.filterNot(files, new Function1<File, Boolean>() {
|
List<File> nonKotlinSources = KotlinPackage.filterNot(files, new Function1<File, Boolean>() {
|
||||||
|
|||||||
Reference in New Issue
Block a user