Using Ant

Using Ant

Getting the Ant Tasks

Kotlin provides three tasks for Ant:

  • kotlinc: Kotlin compiler targeting the JVM
  • kotlin2js: Kotlin compiler targeting JavaScript
  • withKotlin: Task to compile Kotlin files when using the standard javac Ant task

These tasks are defined in the kotlin-ant.jar library which is located in the lib folder for the Kotlin Compiler

Targeting JVM with Kotlin-only source

When the project consists of exclusively Kotlin source code, the easiest way to compile the project is to use the kotlinc task

<project name="Ant Task Test" default="build">
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/