Ant task - nested <classpath> support
This commit is contained in:
+33
-3
@@ -1,5 +1,5 @@
|
|||||||
{toc:style=disc|indent=20px}
|
{toc:style=disc|indent=20px}
|
||||||
h1. Ant
|
h1. Ant - <kotlinc> task
|
||||||
|
|
||||||
To define an Ant's {{*<kotlinc>*}} task you need to define a {{*KOTLIN_HOME*}} environment variable and reference it in your Ant build:
|
To define an Ant's {{*<kotlinc>*}} task you need to define a {{*KOTLIN_HOME*}} environment variable and reference it in your Ant build:
|
||||||
|
|
||||||
@@ -23,12 +23,16 @@ h2. {{*<kotlinc>*}} attributes
|
|||||||
| {align:center}{{*src*}}{align} | Kotlin source file or directory to compile | {{"src"}} or {{"module"}} needs to be specified | |
|
| {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}{{*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}{{*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
|
| {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}{{*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} |
|
| {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
|
h2. Examples
|
||||||
|
|
||||||
|
|
||||||
@@ -63,3 +67,29 @@ fun main(args: Array<String>) {
|
|||||||
print("${args[0]}|${args[1]}|${args[2]}")
|
print("${args[0]}|${args[1]}|${args[2]}")
|
||||||
}
|
}
|
||||||
{code}
|
{code}
|
||||||
|
|
||||||
|
|
||||||
|
h3. Classpath examples
|
||||||
|
|
||||||
|
|
||||||
|
{code}
|
||||||
|
<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}
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ public class BytecodeCompilerTask extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the nested {@code <classpath>} to be used for this compilation.
|
||||||
|
*
|
||||||
|
* @param classpath an Ant Path object containing the compilation classpath.
|
||||||
|
*/
|
||||||
|
public void addConfiguredClasspath( Path classpath ) {
|
||||||
|
setClasspath( classpath );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
|
|||||||
+15
-5
@@ -4,9 +4,11 @@
|
|||||||
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
||||||
<property name="tests-jar" location="${tests-dir}/out.jar"/>
|
<property name="tests-jar" location="${tests-dir}/out.jar"/>
|
||||||
<property name="bootstrap-dir" location="${basedir}/bootstrap.compiler"/>
|
<property name="bootstrap-dir" location="${basedir}/bootstrap.compiler"/>
|
||||||
|
<property name="junit-jar" location="${basedir}/testlib/lib/junit-4.9.jar"/>
|
||||||
<property name="failonerror" value="true"/> <!-- Whether invoking compiled classes should file on error -->
|
<property name="failonerror" value="true"/> <!-- Whether invoking compiled classes should file on error -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- http://ant-contrib.sourceforge.net/tasks/tasks/index.html -->
|
||||||
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
||||||
@@ -15,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<path id="junit-jar">
|
<path id="junit-jar">
|
||||||
<fileset file="${basedir}/testlib/lib/junit-4.9.jar"/>
|
<fileset file="${junit-jar}"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@
|
|||||||
|
|
||||||
<if>
|
<if>
|
||||||
<not>
|
<not>
|
||||||
<available file="${kotlin-home}" type="dir"/>
|
<available file="${kotlin-home}/lib" type="dir"/>
|
||||||
</not>
|
</not>
|
||||||
<then>
|
<then>
|
||||||
<mkdir dir = "${kotlin-home}"/>
|
<mkdir dir = "${kotlin-home}"/>
|
||||||
@@ -103,16 +105,24 @@
|
|||||||
<if>
|
<if>
|
||||||
<equals arg1="@{module}" arg2=""/>
|
<equals arg1="@{module}" arg2=""/>
|
||||||
<then>
|
<then>
|
||||||
<kotlinc src = "@{src}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}" classpathref="junit-jar"/>
|
<kotlinc src = "@{src}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}">
|
||||||
|
<classpath>
|
||||||
|
<path refid="junit-jar"/>
|
||||||
|
</classpath>
|
||||||
|
</kotlinc>
|
||||||
</then>
|
</then>
|
||||||
<elseif>
|
<elseif>
|
||||||
<equals arg1="@{jar}" arg2=""/>
|
<equals arg1="@{jar}" arg2=""/>
|
||||||
<then>
|
<then>
|
||||||
<kotlinc module = "@{module}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}" classpathref="junit-jar"/>
|
<kotlinc module = "@{module}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}">
|
||||||
|
<classpath>
|
||||||
|
<fileset file="${junit-jar}"/>
|
||||||
|
</classpath>
|
||||||
|
</kotlinc>
|
||||||
</then>
|
</then>
|
||||||
</elseif>
|
</elseif>
|
||||||
<else>
|
<else>
|
||||||
<kotlinc module = "@{module}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}" classpathref="junit-jar"/>
|
<kotlinc module = "@{module}" jar = "@{jar}" includeRuntime = "@{includeRuntime}" stdlib = "@{stdlib}" classpath="${junit-jar}"/>
|
||||||
</else>
|
</else>
|
||||||
</if>
|
</if>
|
||||||
</sequential>
|
</sequential>
|
||||||
|
|||||||
Reference in New Issue
Block a user