reworked kotlin compiler dist
This commit is contained in:
@@ -1,173 +0,0 @@
|
||||
{toc:style=disc|indent=20px}
|
||||
h1. Ant
|
||||
|
||||
|
||||
h2. Defining {{*<kotlinc>*}} task using local Kotlin setup
|
||||
|
||||
One way to define Ant's {{*<kotlinc>*}} task is by using your local Kotlin setup and {{*KOTLIN_HOME*}} environment variable:
|
||||
|
||||
{code:xml}
|
||||
<property environment="env"/>
|
||||
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml">
|
||||
<classpath>
|
||||
<fileset dir = "${env.KOTLIN_HOME}/lib" includes = "*.jar"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
{code}
|
||||
|
||||
|
||||
Alternatively, you can copy all jar files from Kotlin distribution to Ant's {{"lib"}} folder.
|
||||
|
||||
|
||||
h2. Defining {{*<kotlinc>*}} task using Ivy
|
||||
|
||||
Another way to define Ant's {{*<kotlinc>*}} task is by using Ivy:
|
||||
|
||||
{{"ivyconf.xml"}}:
|
||||
|
||||
{code:xml}
|
||||
<ivysettings>
|
||||
<property name='ivy.checksums' value=''/>
|
||||
<caches defaultCache="${user.home}/.ivy/cache"/>
|
||||
<settings defaultResolver="sonatype-repo"/>
|
||||
<statuses>
|
||||
<status name='integration' integration='true'/>
|
||||
</statuses>
|
||||
<resolvers>
|
||||
<url name="sonatype-repo" m2compatible="true">
|
||||
<artifact pattern="https://oss.sonatype.org/content/repositories/central/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
|
||||
</url>
|
||||
<url name='jetbrains-repo' alwaysCheckExactRevision='yes' checkmodified='true'>
|
||||
<ivy pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/teamcity-ivy.xml'/>
|
||||
<artifact pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/[artifact](.[ext])'/>
|
||||
</url>
|
||||
</resolvers>
|
||||
<modules>
|
||||
<module organisation='org' name='bt343' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
<module organisation='org' name='bt344' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
</modules>
|
||||
</ivysettings>
|
||||
{code}
|
||||
|
||||
{{"ivy.xml"}}:
|
||||
|
||||
{code:xml}
|
||||
<ivy-module version="1.3">
|
||||
<info organisation="com.jetbrains" module="kotlin"/>
|
||||
<dependencies>
|
||||
<!-- Kotlin build: http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt344 -->
|
||||
<!-- http://teamcity.jetbrains.com/guestAuth/repository/download/bt344/latest.lastSuccessful/teamcity-ivy.xml -->
|
||||
<dependency org="org" name="bt344" rev="latest.lastSuccessful">
|
||||
<include ext="jar" matcher="exactOrRegexp"/>
|
||||
</dependency>
|
||||
<!-- IDEA build: http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt343 -->
|
||||
<!-- http://teamcity.jetbrains.com/guestAuth/repository/download/bt343/latest.lastSuccessful/teamcity-ivy.xml -->
|
||||
<dependency org="org" name="bt343" rev="latest.lastSuccessful">
|
||||
<include name="core/.*" ext="jar" matcher="exactOrRegexp"/>
|
||||
</dependency>
|
||||
<dependency org="asm" name="asm-util" rev="3.3.1"/>
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
{code}
|
||||
|
||||
{{"build.xml"}}:
|
||||
|
||||
{code:xml}
|
||||
<!-- Copy Ivy jar and all its dependencies to Ant's "lib": http://www.apache.org/dist/ant/ivy/2.2.0/apache-ivy-2.2.0-bin-with-deps.zip -->
|
||||
<taskdef uri="antlib:org.apache.ivy.ant" resource="org/apache/ivy/ant/antlib.xml"/>
|
||||
<ivy:configure file="${basedir}/ivyconf.xml"/>
|
||||
<ivy:resolve file="${basedir}/ivy.xml"/>
|
||||
<ivy:cachepath pathid="kotlin.classpath" organisation="org" revision="latest.lastSuccessful"/>
|
||||
|
||||
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml">
|
||||
<classpath>
|
||||
<path refid="kotlin.classpath"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
{code}
|
||||
|
||||
h2. {{*<kotlinc>*}} attributes
|
||||
|
||||
|
||||
|| {align:center}Name{align} || {align:center}Description{align} || {align:center}Required{align} || {align:center}Default Value{align} ||
|
||||
| {align:center}{{*src*}}{align} | Kotlin source file or directory to compile | {{"src"}} or {{"module"}} needs to be specified | |
|
||||
| {align:center}{{*module*}}{align} | Kotlin [module|http://confluence.jetbrains.net/display/Kotlin/Modules+and+Compilation] to compile | {{"src"}} or {{"module"}} needs to be specified | |
|
||||
| {align:center}{{*output*}}{align} | Destination directory | If {{"src"}} is used - {{"output"}} or {{"jar"}} needs to be specified | |
|
||||
| {align:center}{{*jar*}}{align} | Destination jar file | If {{"src"}} is used - {{"output"}} or {{"jar"}} needs to be specified
|
||||
If {{"module"}} is used - only {{"jar"}} can be specified or it can be omitted | {align:center}{{"moduleName.jar"}}{align} |
|
||||
| {align:center}{{*classpath*}}{align} | Compilation class path | {align:center}{{false}}{align} | |
|
||||
| {align:center}{{*classpathref*}}{align} | Compilation class path reference | {align:center}{{false}}{align} | |
|
||||
| {align:center}{{*stdlib*}}{align} | Path to {{"kotlin-runtime.jar"}} | {align:center}{{false}}{align} | {align:center}{{""}}{align} |
|
||||
| {align:center}{{*includeRuntime*}}{align} | If {{"jar"}} is used - whether Kotlin runtime library is included | {align:center}{{false}}{align} | {align:center}{{true}}{align} |
|
||||
|
||||
|
||||
{{<kotlinc>}} accepts a nested {{<classpath>}} element, similarly to [{{<javac>}}|http://evgeny-goldin.org/javadoc/ant/Tasks/javac.html].
|
||||
|
||||
|
||||
h2. Examples
|
||||
|
||||
|
||||
{code:xml}
|
||||
<kotlinc src = "test/longer-examples/Bottles.kt" output = "dist"/>
|
||||
<kotlinc src = "test/longer-examples" output = "dist"/>
|
||||
|
||||
<kotlinc src = "test/longer-examples/Bottles.kt" jar = "dist.jar"/>
|
||||
<kotlinc src = "test/longer-examples" jar = "dist.jar"/>
|
||||
|
||||
<kotlinc module = "test/modules/smoke/Smoke.kts" jar = "dist.jar"/>
|
||||
<kotlinc module = "test/modules/smoke/Smoke.kts"/> => "smoke.jar"
|
||||
{code}
|
||||
|
||||
{{"Smoke.kts"}}:
|
||||
|
||||
{code}
|
||||
import kotlin.modules.*
|
||||
|
||||
fun project() {
|
||||
module("smoke") {
|
||||
sources += "Smoke.kt"
|
||||
}
|
||||
}
|
||||
{code}
|
||||
{{"Smoke.kt"}}:
|
||||
|
||||
{code}
|
||||
package Smoke
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
print("${args[0]}|${args[1]}|${args[2]}")
|
||||
}
|
||||
{code}
|
||||
|
||||
|
||||
h3. Classpath examples
|
||||
|
||||
|
||||
{code:xml}
|
||||
<path id="junit-jar">
|
||||
<fileset file="lib/junit.jar"/>
|
||||
</path>
|
||||
|
||||
<kotlinc src = "src/unit-tests" jar = "tests.jar" classpath = "lib/junit.jar"/>
|
||||
|
||||
<kotlinc src = "src/unit-tests" jar = "tests.jar" classpathref = "junit-jar"/>
|
||||
|
||||
<kotlinc src = "src/unit-tests" jar = "tests.jar">
|
||||
<classpath>
|
||||
<path refid="junit-jar"/>
|
||||
</classpath>
|
||||
</kotlinc>
|
||||
|
||||
<kotlinc src = "src/unit-tests" jar = "tests.jar">
|
||||
<classpath>
|
||||
<fileset file="lib/junit.jar"/>
|
||||
</classpath>
|
||||
</kotlinc>
|
||||
{code}
|
||||
|
||||
|
||||
h1. Maven
|
||||
|
||||
See [{{"kotlin-maven-plugin"}}|http://evgeny-goldin.com/wiki/Kotlin-maven-plugin].
|
||||
|
||||
h1. Gradle
|
||||
@@ -4,13 +4,31 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/core/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/ant/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="cli" />
|
||||
<orderEntry type="library" name="intellij-core" level="project" />
|
||||
<orderEntry type="module" module-name="frontend.java" />
|
||||
<orderEntry type="module" module-name="runtime" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../dependencies/ant.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../ideaSDK/lib/annotations.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -1,503 +0,0 @@
|
||||
<project name="build-tools" default="buildToolsJar" xmlns:ivy="antlib:org.apache.ivy.ant">
|
||||
|
||||
<property name="tests-dir" location="${output}/ant-test/build-tools-test"/>
|
||||
<property name="tests-jar" location="${tests-dir}/out.jar"/>
|
||||
<property name="junit-jar" location="${basedir}/libraries/lib/junit-4.9.jar"/>
|
||||
<property name="failonerror" value="true"/> <!-- Whether invoking compiled classes should file on error -->
|
||||
<property name="use-ivy" value="false"/> <!-- Whether Ivy should be used to define "kotlin.classpath" and <kotlinc> task -->
|
||||
<!-- Override with "-Duse-ivy=true" -->
|
||||
|
||||
|
||||
<!-- http://ant-contrib.sourceforge.net/tasks/tasks/index.html -->
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
|
||||
|
||||
<path id="junit-jar">
|
||||
<fileset file="${junit-jar}"/>
|
||||
</path>
|
||||
|
||||
|
||||
<!-- Verifies file or directory specified exists -->
|
||||
<macrodef name="verify-exists">
|
||||
<attribute name="file"/>
|
||||
<attribute name="type" default="dir"/>
|
||||
<sequential>
|
||||
<if>
|
||||
<available file="@{file}" type="@{type}"/>
|
||||
<then>
|
||||
<echo>[@{file}] of type [@{type}] exists</echo>
|
||||
</then>
|
||||
<else>
|
||||
<fail message="[@{file}] of type [@{type}] is not found!"/>
|
||||
</else>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Defines "kotlin.classpath" using ${kotlin-home} -->
|
||||
<macrodef name="kotlin-home-setup">
|
||||
<sequential>
|
||||
<if>
|
||||
<and>
|
||||
<available file="${kotlin-home}/lib/kotlin-build-tools.jar" type="file"/>
|
||||
<available file="${kotlin-home}/lib/kotlin-compiler.jar" type="file"/>
|
||||
<available file="${kotlin-home}/lib/kotlin-runtime.jar" type="file"/>
|
||||
</and>
|
||||
<then>
|
||||
<echo>[${kotlin-home}/lib] jars found, defining "kotlin.classpath"</echo>
|
||||
<path id="kotlin.classpath">
|
||||
<fileset dir = "${kotlin-home}/lib" includes = "*.jar"/>
|
||||
</path>
|
||||
</then>
|
||||
<else>
|
||||
<!-- Creating and unpacking the distribution archive to make sure it's Ok -->
|
||||
<echo>[${kotlin-home}/lib] jars *not* found, creating distribution zip</echo>
|
||||
|
||||
<antcall target = "zip"/>
|
||||
<verify-exists file="${output}/${output.name}.zip" type="file"/>
|
||||
|
||||
<!-- Sometimes deleting "dist/kotlinc/lib/alt/kotlin-jdk-headers.jar" fails -->
|
||||
<delete dir = "${kotlin-home}" failonerror="false"/>
|
||||
<mkdir dir = "${kotlin-home}"/>
|
||||
<unzip src = "${output}/${output.name}.zip" dest="${output}"/>
|
||||
|
||||
<verify-exists file="${kotlin-home}/lib"/>
|
||||
<verify-exists file="${kotlin-home}/lib/kotlin-build-tools.jar" type="file"/>
|
||||
<verify-exists file="${kotlin-home}/lib/kotlin-compiler.jar" type="file"/>
|
||||
<verify-exists file="${kotlin-home}/lib/kotlin-runtime.jar" type="file"/>
|
||||
|
||||
<kotlin-home-setup/>
|
||||
</else>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Defines "kotlin.classpath" and <kotlinc> task -->
|
||||
<macrodef name="define-kotlinc">
|
||||
<sequential>
|
||||
<if>
|
||||
<istrue value="${use-ivy}"/>
|
||||
<then>
|
||||
<!-- Defining "kotlin.classpath" with Ivy -->
|
||||
<taskdef uri="antlib:org.apache.ivy.ant" resource="org/apache/ivy/ant/antlib.xml"/>
|
||||
<ivy:configure file="${basedir}/build-tools/ivyconf.xml"/>
|
||||
<ivy:resolve file="${basedir}/build-tools/ivy.xml"/>
|
||||
<ivy:cachepath pathid="kotlin.classpath" organisation="org" revision="latest.lastSuccessful"/>
|
||||
</then>
|
||||
<else>
|
||||
<!-- Defining "kotlin.classpath" with ${kotlin-home} -->
|
||||
<kotlin-home-setup/>
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml">
|
||||
<classpath>
|
||||
<path refid="kotlin.classpath"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- Deletes all previously compiled files -->
|
||||
<macrodef name="cleanup">
|
||||
<sequential>
|
||||
<delete dir = "${tests-dir}" failonerror="true"/>
|
||||
<delete file = "${tests-jar}" failonerror="true"/>
|
||||
<mkdir dir = "${tests-dir}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs <kotlinc> create a *.class files in directory -->
|
||||
<macrodef name="kotlinc-dir">
|
||||
<attribute name="src"/>
|
||||
<attribute name="stdlib" default=""/>
|
||||
|
||||
<sequential>
|
||||
<cleanup/>
|
||||
<kotlinc src = "@{src}" output = "${tests-dir}" stdlib = "@{stdlib}" classpathref="junit-jar"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs <kotlinc> to create a *.class files in a jar -->
|
||||
<macrodef name="kotlinc-jar">
|
||||
<attribute name="src" default=""/>
|
||||
<attribute name="module" default=""/>
|
||||
<attribute name="includeRuntime" default="true"/>
|
||||
<attribute name="stdlib" default=""/>
|
||||
<attribute name="jar" default="${tests-jar}"/>
|
||||
<sequential>
|
||||
|
||||
<cleanup/>
|
||||
|
||||
<if>
|
||||
<equals arg1="@{module}" arg2=""/>
|
||||
<then>
|
||||
<kotlinc src = "@{src}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}">
|
||||
<classpath>
|
||||
<path refid="junit-jar"/>
|
||||
</classpath>
|
||||
</kotlinc>
|
||||
</then>
|
||||
<elseif>
|
||||
<equals arg1="@{jar}" arg2=""/>
|
||||
<then>
|
||||
<kotlinc module = "@{module}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}">
|
||||
<classpath>
|
||||
<fileset file="${junit-jar}"/>
|
||||
</classpath>
|
||||
</kotlinc>
|
||||
</then>
|
||||
</elseif>
|
||||
<else>
|
||||
<kotlinc module = "@{module}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}" classpath="${junit-jar}"/>
|
||||
</else>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs <java> for compiled classes and verifies the output correctness -->
|
||||
<macrodef name="run-java">
|
||||
<attribute name="out"/>
|
||||
<attribute name="classname" default="namespace"/>
|
||||
<attribute name="args" default=""/>
|
||||
<attribute name="equals" default="true"/> <!-- Whether strict equality of output to @{out} required -->
|
||||
<attribute name="run-jar" default="false"/> <!-- Whether to run compiled classes or a jar file -->
|
||||
<attribute name="jar" default="${tests-jar}"/> <!-- Jar to use for classpath if "run-jar" is "true" -->
|
||||
<sequential>
|
||||
<var name = "java-out" unset = "true"/>
|
||||
|
||||
<if>
|
||||
<istrue value="@{run-jar}"/>
|
||||
<then>
|
||||
<echo>Running [@{classname}], classpath = "@{jar}"</echo>
|
||||
<java outputproperty = "java-out"
|
||||
classname = "@{classname}"
|
||||
failonerror = "${failonerror}">
|
||||
<classpath>
|
||||
<pathelement path = "@{jar}"/>
|
||||
</classpath>
|
||||
<arg line = "@{args}"/>
|
||||
</java>
|
||||
</then>
|
||||
<else>
|
||||
<echo>Running [@{classname}], classpath = "${tests-dir}"</echo>
|
||||
<java outputproperty = "java-out"
|
||||
classname = "@{classname}"
|
||||
failonerror = "${failonerror}">
|
||||
<classpath>
|
||||
<pathelement path = "${tests-dir}"/>
|
||||
<path refid = "kotlin.classpath"/>
|
||||
</classpath>
|
||||
<arg line = "@{args}"/>
|
||||
</java>
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<if>
|
||||
<or>
|
||||
<equals arg1="${java-out}" arg2="@{out}"/>
|
||||
<and>
|
||||
<isfalse value="@{equals}"/>
|
||||
<contains string="${java-out}" substring="@{out}"/>
|
||||
</and>
|
||||
</or>
|
||||
<then>
|
||||
<echo>${java-out}</echo>
|
||||
</then>
|
||||
<elseif>
|
||||
<istrue value="${failonerror}"/>
|
||||
<then>
|
||||
<fail message="Test failed: '${java-out}' (received) != '@{out}' (expected), equals = [@{equals}]"/>
|
||||
</then>
|
||||
</elseif>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Compiles "Hello.kt" as a single file and a folder, runs <java> and verifies the output -->
|
||||
<macrodef name="hello-test">
|
||||
<attribute name="root"/>
|
||||
<attribute name="args" default=""/>
|
||||
<attribute name="out"/>
|
||||
<sequential>
|
||||
<kotlinc-dir src = "@{root}/Hello.kt"/>
|
||||
<run-java args = "@{args}" out = "@{out}"/>
|
||||
|
||||
<kotlinc-dir src = "@{root}"/>
|
||||
<run-java args = "@{args}" out = "@{out}"/>
|
||||
|
||||
<kotlinc-jar src = "@{root}/Hello.kt"/>
|
||||
<run-java args = "@{args}" out = "@{out}" run-jar="true"/>
|
||||
|
||||
<kotlinc-jar src = "@{root}"/>
|
||||
<run-java args = "@{args}" out = "@{out}" run-jar="true"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs all Hello tests -->
|
||||
<macrodef name="hello-tests">
|
||||
<sequential>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/1" out="Hello, world!"/>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/2" args="Kotlin-Developer" out="Hello, Kotlin-Developer!"/>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/3" args="Mickey-Mouse" out="Hello, Mickey-Mouse!"/>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/4" args="IT" out="Ciao!"/>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/4" args="FR" out="Salut!"/>
|
||||
<hello-test root="${basedir}/build-tools/test/hello/5" args="Donald-Duck" out="Hello, Donald-Duck!"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Compiles, runs and verifies the output of web demo longer examples -->
|
||||
<macrodef name="longer-examples-tests">
|
||||
<sequential>
|
||||
<kotlinc-dir src = "${basedir}/build-tools/test/longer-examples"/>
|
||||
|
||||
<run-java classname = "bottles.namespace" equals="false" out="12 bottles of beer on the wall, 12 bottles of beer."/>
|
||||
<run-java classname = "life.namespace" equals="false" out="*** ** ** ***"/>
|
||||
<!--<run-java classname = "maze.namespace" equals="false" out="O ~OOOOOOOOOOOOOO"/>-->
|
||||
<!--<run-java classname = "html.namespace" equals="false" out="<a href="http://jetbrains.com/kotlin">"/>-->
|
||||
|
||||
<kotlinc-jar src = "${basedir}/build-tools/test/longer-examples"/>
|
||||
|
||||
<run-java classname = "bottles.namespace" equals="false" run-jar="true" out="12 bottles of beer on the wall, 12 bottles of beer."/>
|
||||
<run-java classname = "life.namespace" equals="false" run-jar="true" out="*** ** ** ***"/>
|
||||
<!--<run-java classname = "maze.namespace" equals="false" run-jar="true" out="O ~OOOOOOOOOOOOOO"/>-->
|
||||
<!--<run-java classname = "html.namespace" equals="false" run-jar="true" out="<a href="http://jetbrains.com/kotlin">"/>-->
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Compiles and runs a Kotlin module -->
|
||||
<macrodef name="module-tests">
|
||||
<sequential>
|
||||
<!-- Module => Explicit Jar -->
|
||||
<kotlinc-jar module="${basedir}/build-tools/test/modules/smoke/Smoke.kts"/>
|
||||
<run-java classname = "Smoke.namespace" run-jar = "true" args = "1 2 3" out = "1|2|3"/>
|
||||
|
||||
<!-- Module => Default Jar -->
|
||||
<kotlinc-jar module="${basedir}/build-tools/test/modules/smoke/Smoke.kts" jar=""/>
|
||||
<move file="${basedir}/build-tools/test/modules/smoke/smoke.jar" todir="${tests-dir}"/>
|
||||
<run-java classname = "Smoke.namespace" run-jar = "true" args = "1 2 3" out = "1|2|3" jar="${tests-dir}/smoke.jar"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs JUnit single test or batch tests -->
|
||||
<macrodef name="run-junit">
|
||||
<attribute name="classpath"/>
|
||||
<attribute name="test" default=""/>
|
||||
<sequential>
|
||||
|
||||
<path id="junit-classpath">
|
||||
<path refid="junit-jar"/>
|
||||
<path refid="kotlin.classpath"/>
|
||||
<pathelement location="@{classpath}"/>
|
||||
</path>
|
||||
|
||||
<if>
|
||||
<equals arg1="@{test}" arg2=""/>
|
||||
<then>
|
||||
<!-- Batch tests -->
|
||||
<if>
|
||||
<matches string="@{classpath}" pattern="\.jar$"/>
|
||||
<then>
|
||||
<!-- Batch tests from a jar -->
|
||||
<echo>Running JUnit: classpath = "@{classpath}" (Jar)</echo>
|
||||
<junit haltonfailure="true">
|
||||
<classpath>
|
||||
<path refid="junit-classpath"/>
|
||||
</classpath>
|
||||
<formatter type="plain" usefile="false"/>
|
||||
<batchtest>
|
||||
<zipfileset src="@{classpath}" includes="**/*Test.class" excludes="**/BuiltTest.class"/>
|
||||
</batchtest>
|
||||
</junit>
|
||||
</then>
|
||||
<else>
|
||||
<!-- Batch tests from a dir -->
|
||||
<echo>Running JUnit: classpath = "@{classpath}" (Dir)</echo>
|
||||
<junit haltonfailure="true">
|
||||
<classpath>
|
||||
<path refid="junit-classpath"/>
|
||||
</classpath>
|
||||
<formatter type="plain" usefile="false"/>
|
||||
<batchtest>
|
||||
<fileset dir="@{classpath}" includes="**/*Test.class" excludes="**/BuiltTest.class"/>
|
||||
</batchtest>
|
||||
</junit>
|
||||
</else>
|
||||
</if>
|
||||
</then>
|
||||
<else>
|
||||
<!-- Single test -->
|
||||
<echo>Running JUnit: test = "@{test}", classpath = "@{classpath}"</echo>
|
||||
<junit haltonfailure="true">
|
||||
<classpath>
|
||||
<path refid="junit-classpath"/>
|
||||
</classpath>
|
||||
<formatter type="plain" usefile="false"/>
|
||||
<test name="@{test}"/>
|
||||
</junit>
|
||||
</else>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Runs all JUnit tests, first each test separately and then all of them in a batch mode -->
|
||||
<macrodef name="testlib-junit-tests">
|
||||
<attribute name="classpath"/>
|
||||
<sequential>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.CollectionTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.IoTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.ListTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.MapTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.OldStdlibTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.SetTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.collections.StandardCollectionTest"/>
|
||||
<run-junit classpath="@{classpath}" test="test.stdlib.issues.StdLibIssuesTest"/>
|
||||
<run-junit classpath="@{classpath}" test="testString.StringTest"/>
|
||||
|
||||
<run-junit classpath="@{classpath}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Compiles "testlib" Kotlin tests (dir/module => dir/jar) and runs all JUnit tests resulted -->
|
||||
<macrodef name="testlib-tests">
|
||||
<sequential>
|
||||
<!-- Dir => Dir -->
|
||||
<kotlinc-dir src = "${basedir}/libraries/stdlib/test"/>
|
||||
<testlib-junit-tests classpath = "${tests-dir}"/>
|
||||
|
||||
<!-- Dir => Jar -->
|
||||
<kotlinc-jar src = "${basedir}/libraries/stdlib/test"/>
|
||||
<testlib-junit-tests classpath = "${tests-jar}"/>
|
||||
|
||||
<!-- Module => Explicit Jar -->
|
||||
<kotlinc-jar module = "${basedir}/libraries/stdlib/testModule.kt"/>
|
||||
<testlib-junit-tests classpath = "${tests-jar}"/>
|
||||
|
||||
<!-- Module => Default Jar -->
|
||||
<kotlinc-jar module = "${basedir}/libraries/stdlib/testModule.kt" jar=""/>
|
||||
<move file="${basedir}/libraries/testlib/testlib.jar" todir="${tests-dir}"/>
|
||||
<testlib-junit-tests classpath = "${tests-dir}/testlib.jar"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Verifies build fails if <kotlinc> fails -->
|
||||
<macrodef name="compilation-fail-test">
|
||||
<sequential>
|
||||
<var name="failed" value="false"/>
|
||||
<trycatch property="error-message" reference="bar">
|
||||
<try>
|
||||
<!-- Should fail -->
|
||||
<kotlinc-dir src = "${basedir}/build-tools/test/compilation-fail"/>
|
||||
</try>
|
||||
<catch>
|
||||
<var name="failed" value="true"/>
|
||||
<echo>"ERROR:" was expected here</echo>
|
||||
</catch>
|
||||
</trycatch>
|
||||
<if>
|
||||
<isfalse value="${failed}"/>
|
||||
<then>
|
||||
<fail message="kotlinc-dir: compilation should have failed!"/>
|
||||
</then>
|
||||
</if>
|
||||
|
||||
<var name="failed" value="false"/>
|
||||
<trycatch property="error-message" reference="bar">
|
||||
<try>
|
||||
<!-- Should fail -->
|
||||
<kotlinc-jar src = "${basedir}/build-tools/test/compilation-fail"/>
|
||||
</try>
|
||||
<catch>
|
||||
<var name="failed" value="true"/>
|
||||
<echo>"ERROR:" was expected here</echo>
|
||||
</catch>
|
||||
</trycatch>
|
||||
<if>
|
||||
<isfalse value="${failed}"/>
|
||||
<then>
|
||||
<fail message="kotlinc-jar: compilation should have failed!"/>
|
||||
</then>
|
||||
</if>
|
||||
|
||||
<var name="failed" value="false"/>
|
||||
<trycatch property="error-message" reference="bar">
|
||||
<try>
|
||||
<!-- Should fail -->
|
||||
<kotlinc-jar module = "${basedir}/build-tools/test/compilation-fail/Smoke.kts"/>
|
||||
</try>
|
||||
<catch>
|
||||
<var name="failed" value="true"/>
|
||||
<echo>"ERROR:" was expected here</echo>
|
||||
</catch>
|
||||
</trycatch>
|
||||
<if>
|
||||
<isfalse value="${failed}"/>
|
||||
<then>
|
||||
<fail message="kotlinc-jar: compilation should have failed!"/>
|
||||
</then>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Creates build tools distribution jar -->
|
||||
<target name="buildToolsJar" depends="compile">
|
||||
<mkdir dir ="${output}/classes/buildTools"/>
|
||||
<javac destdir="${output}/classes/buildTools" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
|
||||
<src>
|
||||
<dirset dir="${basedir}/build-tools">
|
||||
<include name="core/src"/>
|
||||
<include name="ant/src"/>
|
||||
<include name="maven/src"/>
|
||||
<include name="gradle/src"/>
|
||||
</dirset>
|
||||
<dirset dir="${basedir}/js">
|
||||
<include name="js.translator/src"/>
|
||||
</dirset>
|
||||
<!--
|
||||
<dirset dir="${basedir}/j2k">
|
||||
<include name="src"/>
|
||||
</dirset>
|
||||
-->
|
||||
</src>
|
||||
<compilerarg value="-Xlint:all"/>
|
||||
<classpath>
|
||||
<path refid = "classpath.kotlin"/>
|
||||
<fileset dir = "${ant.home}/lib" includes="*.jar"/>
|
||||
<fileset dir = "${basedir}/js/js.translator/lib" includes="*.jar"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
<jar destfile="${kotlin-home}/lib/kotlin-build-tools.jar">
|
||||
<fileset dir = "${output}/classes/buildTools"/>
|
||||
<fileset dir = "${basedir}/build-tools/ant/src" includes="**/*.xml"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- Tests build tools distribution jar -->
|
||||
<target name="buildToolsTest">
|
||||
<define-kotlinc/>
|
||||
<hello-tests/>
|
||||
<longer-examples-tests/>
|
||||
<module-tests/>
|
||||
<!--<testlib-tests/>-->
|
||||
<compilation-fail-test/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,20 +0,0 @@
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuring Ant to work with TeamCity Ivy repo: http://goo.gl/foaTg -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
|
||||
<ivy-module version="1.3">
|
||||
<info organisation="com.jetbrains" module="kotlin"/>
|
||||
<dependencies>
|
||||
<!-- Kotlin build: http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt344 -->
|
||||
<!-- http://teamcity.jetbrains.com/guestAuth/repository/download/bt344/latest.lastSuccessful/teamcity-ivy.xml -->
|
||||
<dependency org="org" name="bt344" rev="latest.lastSuccessful">
|
||||
<include ext="jar" matcher="exactOrRegexp"/>
|
||||
</dependency>
|
||||
<!-- IDEA build: http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt343 -->
|
||||
<!-- http://teamcity.jetbrains.com/guestAuth/repository/download/bt343/latest.lastSuccessful/teamcity-ivy.xml -->
|
||||
<dependency org="org" name="bt343" rev="latest.lastSuccessful">
|
||||
<include name="core/.*" ext="jar" matcher="exactOrRegexp"/>
|
||||
</dependency>
|
||||
<dependency org="asm" name="asm-util" rev="3.3.1"/>
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
@@ -1,25 +0,0 @@
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuring Ant to work with TeamCity Ivy repo: http://goo.gl/foaTg -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
|
||||
<ivysettings>
|
||||
<property name='ivy.checksums' value=''/>
|
||||
<caches defaultCache="${user.home}/.ivy/cache"/>
|
||||
<settings defaultResolver="sonatype-repo"/>
|
||||
<statuses>
|
||||
<status name='integration' integration='true'/>
|
||||
</statuses>
|
||||
<resolvers>
|
||||
<url name="sonatype-repo" m2compatible="true">
|
||||
<artifact pattern="https://oss.sonatype.org/content/repositories/central/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
|
||||
</url>
|
||||
<url name='jetbrains-repo' alwaysCheckExactRevision='yes' checkmodified='true'>
|
||||
<ivy pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/teamcity-ivy.xml'/>
|
||||
<artifact pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/[artifact](.[ext])'/>
|
||||
</url>
|
||||
</resolvers>
|
||||
<modules>
|
||||
<module organisation='org' name='bt343' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
<module organisation='org' name='bt344' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
</modules>
|
||||
</ivysettings>
|
||||
Binary file not shown.
Reference in New Issue
Block a user