0
votes

<target name="build">
    <delete dir="classes" failonerror="false"/>
    <mkdir dir="classes"/>
    <javac destdir="classes" includeAntRuntime="false" srcdir="src">
        <withKotlin/>
    </javac>
    <jar destfile="hello.jar">
        <fileset dir="classes"/>
    </jar>
</target>

Kotlin Website

I am working on integrating Kotlin with my existing Java project (ivy and ant). Currently we use ivy.xml for dependency management and ant for build scripts.

  1. If I used IVY, does it make specifying classpath="${kotlin.lib}/kotlin-ant.jar" redundant ?

  2. I get an error org/jetbrains/kotlin/ant/antlib.xml not found in classpath. How to resolve it ?

  3. How to add kotlin-ant.jar & and all its dependencies using using Ivy ?

1

1 Answers

0
votes

If Ivy is used, then no need for specifying classpath="${kotlin.lib}/kotlin-ant.jar"

Regarding 2 & 3.

Create configurations for the Kotlin Dependencies in the ivy.xml

<configurations>
    <conf name="kotlin" description="Kotlin Tasks"/>
</configurations>

<dependencies>
    <dependency org="xxxxx" name="kotlin-ant" rev="xxxxx" conf="kotlin->default"/>
</dependencies>

In Build.xml, update the configuration.

<target name="resolve">
    <ivy:resolve />
    <ivy:cachepath pathid="kotlin.classpath" conf="kotlin"/>
</target>

<target name="build" depends="resolve">
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpathref="kotlin.classpath"/>
 <kotlinc .....
    </kotlinc>
</target>