From 361d8536ac17aa300623a47923cba4df98dccf61 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 13 Nov 2017 13:22:56 +0100 Subject: [PATCH] Switch ant usages to regular dependency --- build.gradle.kts | 1 + compiler/build.gradle.kts | 12 ++++++++++-- .../integration/AbstractAntTaskTest.java | 18 ++++++++++++------ js/js.tests/build.gradle.kts | 13 +++++++++++++ update_dependencies.xml | 3 --- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2c085063e6e..8ec14e73ef1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -127,6 +127,7 @@ extra["versions.kotlinx-coroutines-core"] = "0.14.1" extra["versions.kotlinx-coroutines-jdk8"] = "0.14.1" extra["versions.json"] = "20160807" extra["versions.native-platform"] = "0.14" +extra["versions.ant-launcher"] = "1.8.0" val markdownVer = "4054 - Kotlin 1.0.2-dev-566".replace(" ", "%20") // fixed here, was last with "status:SUCCESS,tag:forKotlin" extra["markdownParserRepo"] = "https://teamcity.jetbrains.com/guestAuth/repository/download/IntelliJMarkdownParser_Build/$markdownVer/([artifact]_[ext]/)[artifact](.[ext])" diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 51aba27db13..abee1aca43b 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -41,6 +41,7 @@ val testDistProjects = listOf( ) val testJvm6ServerRuntime by configurations.creating +val antLauncherJar by configurations.creating dependencies { depDistProjects.forEach { @@ -62,16 +63,19 @@ dependencies { testRuntime(projectDist(":kotlin-reflect")) testRuntime(projectDist(":kotlin-daemon-client")) testRuntime(preloadedDeps("dx", subdir = "android-5.0/lib")) - testRuntime(files("${System.getProperty("java.home")}/../lib/tools.jar")) + testRuntime(files(toolsJar())) testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6")) + + antLauncherJar(commonDep("org.apache.ant", "ant")) + antLauncherJar(files(toolsJar())) } afterEvaluate { dependencies { testCompile(intellij { include("openapi.jar", "idea.jar", "util.jar", "asm-all.jar", "commons-httpclient-3.1-patched.jar") }) - testRuntime(intellijCoreJar()) testRuntime(intellij()) + testRuntime(intellijCoreJar()) } } @@ -88,6 +92,10 @@ projectTest { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir systemProperty("kotlin.test.script.classpath", the().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) + doFirst { + systemProperty("ant.classpath", antLauncherJar.asPath) + systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + } } fun Project.codegenTest(target: Int, jvm: Int, diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java index 91d261f58fc..edb51e95889 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java @@ -25,11 +25,20 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase { protected void doTest(String testFile) throws Exception { String testDataDir = new File(testFile).getAbsolutePath(); + String antClasspath = System.getProperty("ant.classpath"); + if (antClasspath == null) { + throw new RuntimeException("Unable to get a valid classpath from 'ant.classpath' property, please set it accordingly"); + } + + String antLauncherClass = System.getProperty("ant.launcher.class"); + if (antLauncherClass == null) { + throw new RuntimeException("Unable to get a valid class FQN from 'ant.launcher.class' property, please set it accordingly"); + } + runJava( testDataDir, "build.log", "-Xmx192m", - "-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar", "-Dkotlin.lib=" + KotlinIntegrationTestBase.getCompilerLib(), "-Dkotlin.runtime.jar=" + ForTestCompileRuntime.runtimeJarForTests().getAbsolutePath(), "-Dkotlin.reflect.jar=" + ForTestCompileRuntime.reflectJarForTests().getAbsolutePath(), @@ -39,6 +48,8 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase { "-Dkotlin.stdlib.jdk8.jar=" + new File("dist/kotlinc/lib/kotlin-stdlib-jdk8.jar").getAbsolutePath(), "-Dtest.data=" + testDataDir, "-Dtemp=" + tmpdir, + "-cp", antClasspath, + antLauncherClass, "-f", "build.xml" ); } @@ -49,9 +60,4 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase { return super.normalizeOutput(testDataDir, content) .replaceAll("Total time: .+\n", "Total time: [time]\n"); } - - @NotNull - private static String getAntHome() { - return KotlinIntegrationTestBase.getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant-1.8"; - } } diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 5731605ccb3..61bd536ba6a 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -14,6 +14,8 @@ apply { plugin("kotlin") } configureIntellijPlugin() +val antLauncherJar by configurations.creating + dependencies { testCompile(protobufFull()) testCompile(projectTests(":compiler:tests-common")) @@ -33,6 +35,9 @@ dependencies { testRuntime(projectDist(":kotlin-preloader")) // it's required for ant tests testRuntime(project(":compiler:backend-common")) testRuntime(commonDep("org.fusesource.jansi", "jansi")) + + antLauncherJar(commonDep("org.apache.ant", "ant")) + antLauncherJar(files(toolsJar())) } afterEvaluate { @@ -59,6 +64,10 @@ val testDistProjects = listOf( projectTest { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir + doFirst { + systemProperty("ant.classpath", antLauncherJar.asPath) + systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + } } testsJar {} @@ -67,6 +76,10 @@ projectTest("quickTest") { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir systemProperty("kotlin.js.skipMinificationTest", "true") + doFirst { + systemProperty("ant.classpath", antLauncherJar.asPath) + systemProperty("ant.launcher.class", "org.apache.tools.ant.Main") + } } val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt") diff --git a/update_dependencies.xml b/update_dependencies.xml index 3fe29a85b88..dfefcab0443 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -124,9 +124,6 @@ - - -