Skip to end of metadata
Go to start of metadata

Ant

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:

Alternatively, you can copy all jar files from Kotlin distribution to Ant's "lib" folder.

<kotlinc> attributes

Name
Description
Required
Default Value
src
Kotlin source file or directory to compile "src" or "module" needs to be specified  
module
Kotlin module to compile "src" or "module" needs to be specified  
output
Destination directory If "src" is used - "output" or "jar" needs to be specified  
jar
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
"moduleName.jar"
classpath
Compilation class path
false
 
classpathref
Compilation class path reference
false
 
stdlib
Path to "kotlin-runtime.jar"
false
""
includeRuntime
If "jar" is used - whether Kotlin runtime library is included
false
true

<kotlinc> accepts a nested <classpath> element, similarly to <javac>.

Examples

"Smoke.kts":

"Smoke.kt":

Classpath examples

Maven

"kotlin-maven-plugin" compiles Kotlin sources and modules.
Note: only Maven 3 is supported for now.

The old "kotlin-maven-plugin" is no longer supported.

Repositories

Kotlin maven artifacts are published on http://repository.jetbrains.com.

Add references to it in your pom or settings file:

Versions

Define Kotlin version in kotlin.version. Possible values are:

  • X.Y-SNAPSHOT - snapshot versions for X.Y release, updated with every successful build on our continuous integration server.
    Highly unstable, recommended for testing new compiler features.
    Currently, all builds are published as 0.1-SNAPSHOT.
  • X.Y.Z - release or milestone version X.Y.Z, updated manually, stable.

Here's the table of versions corresponding to milestone codes:

Milestone Version
M1 0.1.2090

Dependencies

Kotlin has an extensive standard library, use it in your program:

Compile Kotlin sources

Specify source directories in <build> tag:

Reference kotlin-maven-plugin to compile sources:

Compile mixed Kotlin/Java sources

To compile mixed code applications Kotlin compiler should be invoked before Java compiler.
In maven terms that means kotlin-maven-plugin should be run before maven-compiler-plugin.

It could be done by moving Kotlin compilation to previous phase, process-sources (feel free to suggest a better solution if you have one):

Example

Download a simple hello world application here.

Gradle

Coming soon.

Griffon

See "griffon-kotlin-plugin".

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.