Ant task - nested <classpath> support
This commit is contained in:
+33
-3
@@ -1,5 +1,5 @@
|
||||
{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:
|
||||
|
||||
@@ -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}{{*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}{{*jar*}}{align} | Destination jar file | If {{"src"}} is used - {{"output"}} or {{"jar"}} needs to be specified | |
|
||||
| {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
|
||||
|
||||
|
||||
@@ -63,3 +67,29 @@ fun main(args: Array<String>) {
|
||||
print("${args[0]}|${args[1]}|${args[2]}")
|
||||
}
|
||||
{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
|
||||
public void execute() {
|
||||
|
||||
|
||||
+15
-5
@@ -4,9 +4,11 @@
|
||||
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
||||
<property name="tests-jar" location="${tests-dir}/out.jar"/>
|
||||
<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 -->
|
||||
|
||||
|
||||
<!-- 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"/>
|
||||
@@ -15,7 +17,7 @@
|
||||
|
||||
|
||||
<path id="junit-jar">
|
||||
<fileset file="${basedir}/testlib/lib/junit-4.9.jar"/>
|
||||
<fileset file="${junit-jar}"/>
|
||||
</path>
|
||||
|
||||
|
||||
@@ -25,7 +27,7 @@
|
||||
|
||||
<if>
|
||||
<not>
|
||||
<available file="${kotlin-home}" type="dir"/>
|
||||
<available file="${kotlin-home}/lib" type="dir"/>
|
||||
</not>
|
||||
<then>
|
||||
<mkdir dir = "${kotlin-home}"/>
|
||||
@@ -103,16 +105,24 @@
|
||||
<if>
|
||||
<equals arg1="@{module}" arg2=""/>
|
||||
<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>
|
||||
<elseif>
|
||||
<equals arg1="@{jar}" arg2=""/>
|
||||
<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>
|
||||
</elseif>
|
||||
<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>
|
||||
</if>
|
||||
</sequential>
|
||||
|
||||
Reference in New Issue
Block a user