ant task fixes + first integration test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<project name="Kotlin" default="dist">
|
||||
|
||||
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
|
||||
<property name="shrink" value="false" />
|
||||
<property name="shrink" value="false"/>
|
||||
|
||||
<property name="output" value="${basedir}/dist"/>
|
||||
<property name="kotlin-home" value="${output}/kotlinc"/>
|
||||
@@ -155,11 +155,11 @@
|
||||
<delete file="${kotlin-home}/lib/kotlin-compiler.jar" failonerror="false"/>
|
||||
|
||||
<if>
|
||||
<isfalse value="${shrink}" />
|
||||
<isfalse value="${shrink}"/>
|
||||
|
||||
<then>
|
||||
<copy file="${output}/kotlin-compiler-jarjar.jar"
|
||||
tofile="${kotlin-home}/lib/kotlin-compiler.jar" />
|
||||
tofile="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||
</then>
|
||||
|
||||
<else>
|
||||
@@ -267,10 +267,20 @@
|
||||
</classpath>
|
||||
</javac>
|
||||
|
||||
<delete file="${kotlin-home}/lib/kotlin-ant.jar" failonerror="false" />
|
||||
<delete file="${kotlin-home}/lib/kotlin-ant.jar" failonerror="false"/>
|
||||
<jar destfile="${kotlin-home}/lib/kotlin-ant.jar">
|
||||
<fileset dir="${output}/classes/buildTools"/>
|
||||
<fileset dir="${basedir}/build-tools/ant/src" includes="**/*.xml"/>
|
||||
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="JetBrains"/>
|
||||
|
||||
<attribute name="Implementation-Vendor" value="JetBrains"/>
|
||||
<attribute name="Implementation-Title" value="Kotlin Compiler Ant Tasks"/>
|
||||
<attribute name="Implementation-Version" value="${build.number}"/>
|
||||
|
||||
<attribute name="Class-Path" value="kotlin-compiler.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
@@ -289,7 +299,7 @@
|
||||
<arg value="jdkHeaders"/>
|
||||
</java>
|
||||
|
||||
<delete file="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar" failonerror="false" />
|
||||
<delete file="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar" failonerror="false"/>
|
||||
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar">
|
||||
<fileset dir="${output}/classes/jdk-headers"/>
|
||||
</jar>
|
||||
@@ -317,7 +327,7 @@
|
||||
<arg value="${output}/classes/runtime"/>
|
||||
</java>
|
||||
|
||||
<delete file="${kotlin-home}/lib/kotlin-runtime.jar" failonerror="false" />
|
||||
<delete file="${kotlin-home}/lib/kotlin-runtime.jar" failonerror="false"/>
|
||||
<jar destfile="${kotlin-home}/lib/kotlin-runtime.jar">
|
||||
<fileset dir="${output}/classes/runtime"/>
|
||||
<fileset dir="${output}/classes/stdlib"/>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
OUT Buildfile: build.xml
|
||||
OUT
|
||||
OUT build:
|
||||
OUT [kotlinc] Compiling [[TestData]\hello.kt] => [[Temp]\hello.jar]
|
||||
OUT [kotlinc] LOGGING: For source: [TestData]\hello.kt
|
||||
OUT [kotlinc] LOGGING: Emitting: Hello/namespace.class
|
||||
OUT
|
||||
OUT BUILD SUCCESSFUL
|
||||
OUT Total time: 2 seconds
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<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">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
package Hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
System.out?.println("Hello!")
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
OUT Hello!
|
||||
Return code: 0
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.kotlin;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class AntTaskTest extends KotlinIntegrationTestBase {
|
||||
@Test
|
||||
public void antTaskJvm() throws Exception {
|
||||
final String jar = tempDir.getAbsolutePath() + File.separator + "hello.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runAnt("build.log", "build.xml"));
|
||||
runJava("hello.run", "-cp", jar, "Hello.namespace");
|
||||
}
|
||||
|
||||
private int runAnt(String logName, String scriptName) throws Exception {
|
||||
return runJava(logName, "-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
|
||||
"-Dkotlin.lib=" + getCompilerLib(),
|
||||
"-Dtest.data=" + testDataDir,
|
||||
"-Dtemp=" + tempDir,
|
||||
"-f", scriptName);
|
||||
}
|
||||
|
||||
private static String getAntHome() {
|
||||
return getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant";
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,15 @@ public abstract class KotlinIntegrationTestBase {
|
||||
public TestRule watchman = new TestWatcher() {
|
||||
@Override
|
||||
protected void starting(Description description) {
|
||||
tempDir = Files.createTempDir();
|
||||
try {
|
||||
tempDir = Files.createTempDir().getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
final File baseTestDataDir = new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data");
|
||||
final File baseTestDataDir =
|
||||
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data");
|
||||
testDataDir = new File(baseTestDataDir, description.getMethodName());
|
||||
}
|
||||
|
||||
@@ -111,7 +117,10 @@ public abstract class KotlinIntegrationTestBase {
|
||||
final File actualFile = new File(testDataDir, baseName + ".actual");
|
||||
final File expectedFile = new File(testDataDir, baseName + ".expected");
|
||||
|
||||
final String normalizedContent = StringUtil.replace(content, testDataDir.getAbsolutePath(), "[TestData]", true);
|
||||
final String normalizedContent =
|
||||
StringUtil.replace(
|
||||
StringUtil.replace(content, testDataDir.getAbsolutePath(), "[TestData]", true),
|
||||
tempDir.getAbsolutePath(), "[Temp]", true);
|
||||
|
||||
if (!expectedFile.isFile()) {
|
||||
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
<!-- ant 1.7.0 -->
|
||||
<get src="http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.0-bin.tar.gz"
|
||||
dest="dependencies/download/apache-ant-1.7.0-bin.tar.gz" usetimestamp="true" />
|
||||
|
||||
<delete file="dependencies/ant.jar" failonerror="false"/>
|
||||
<untar src="dependencies/download/apache-ant-1.7.0-bin.tar.gz" dest="dependencies" compression="gzip">
|
||||
<patternset>
|
||||
@@ -54,6 +55,11 @@
|
||||
</patternset>
|
||||
<mapper type="flatten"/>
|
||||
</untar>
|
||||
|
||||
<delete dir="dependencies/ant" failonerror="false"/>
|
||||
<untar src="dependencies/download/apache-ant-1.7.0-bin.tar.gz" dest="dependencies/ant" compression="gzip">
|
||||
<cutdirsmapper dirs="1"/>
|
||||
</untar>
|
||||
</target>
|
||||
|
||||
<macrodef name="execute_update">
|
||||
|
||||
Reference in New Issue
Block a user