mill-kotlin icon indicating copy to clipboard operation
mill-kotlin copied to clipboard

Kotlin compiler support for Mill Build Tool

= mill-kotlin - Kotlin compiler support for mill :version: 0.3.0 :mill-platform: 0.11 :kotlinVersion: 1.9.21 :projectHome: https://github.com/lefou/mill-kotlin :min-mill-version: 0.7.0

ifdef::env-github[] image:https://github.com/lefou/mill-kotlin/workflows/.github/workflows/build.yml/badge.svg["Build Status (GitHub Actions)", link="https://github.com/lefou/mill-kotlin/actions"] image:https://codecov.io/gh/lefou/mill-kotlin/branch/main/graph/badge.svg[Test Coverage (Codecov.io), link="https://codecov.io/gh/lefou/mill-kotlin"] endif::[]

Documentation for mill-kotlin, a mill plugin to support the https://kotlinlang.org/[Kotlin language and compiler].

== Quickstart

Mill version {min-mill-version} or newer is required.

[source,scala,subs="attributes,verbatim"]

// Load the plugin from Maven Central via ivy/coursier import $ivy.de.tototec::de.tobiasroeser.mill.kotlin_mill{mill-platform}:{version}

import mill._ import mill.scalalib._ import mill.define._

import de.tobiasroeser.mill.kotlin._

object main extends KotlinModule {

// Select the Kotlin version def kotlinVersion = T{ "{kotlinVersion}" }

// Set additional Kotlin compiler options, e.g. the language level and annotation processor // Run mill main.kotlincHelp to get a list of supported options def kotlincOptions = super.kotlincOptions() ++ Seq("-verbose")

}

== Configuration

To target the JVM (kotlin-jvm), our module needs to extend de.tobiasroeser.mill.kotlin.KotlinModule which itself extends mill.scalalib.JavaModule.

For convenience, you may derive your unit test projects from de.tobiasroeser.mill.kotlin.KotlinModule.Tests (or KotlinModuleTests) trait.

The module trait de.tobiasroeser.mill.kotlin.KotlinModule has the following configuration options (over those from mill.scalalib.JavaModule).

def kotlinVersion: T[String]:: The Kotlin version to be used (for API and Language level settings).

def kotlinCompilerVersion: T[String]:: The version of the Kotlin compiler to be used. Default is derived from kotlinVersion.

def compile: T[CompilationResult]:: Compiles all the sources to JVM class files.

def kotlincOptions: T[Seq[String]]:: Additional Kotlin compiler options to be use by compile.

def ivyDeps: T[Agg[Dep]]:: The compile and runtime dependencies.

def kotlincHelp(args: String*): Command[Unit]:: Runs the Kotlin compiler with the -help argument to show you the built-in cmdline help. You might want to add additional arguments like -X to see extra help.

def kotlinCompilerIvyDeps: T[Agg[Dep]]:: The Ivy/Coursier dependencies resembling the Kotlin compiler. Default is derived from kotlinCompilerVersion.

def kotlinCompilerClasspath: T[Seq[PathRef]]:: The Java classpath resembling the Kotlin compiler. Default is derived from kotlinCompilerIvyDeps.

trait Tests extends TestModule with KotlinTestModule:: A test sub-module linked to its parent module best suited for unit-tests.

Mixed Kotlin/Java projects are also supported. Java compilation is based on mills mill.scalalib.JavaModule and Java options are configured via javacOptions.

== Version Compatibility Matrix

Mill is still in active development, and has no stable API yet. Hence, not all mill-kotlin versions work with every mill version.

The following table shows a matrix of compatible mill and mill-kotlin versions.

.Version Compatibility Matrix [options="header"] |=== | mill-kotlin | mill | 0.3.0 | 0.7.0 - 0.11.x | 0.2.4 | 0.7.0 - 0.11.x | 0.2.3 | 0.7.0 - 0.11.x | 0.2.2 | 0.6.0 - 0.10.x | 0.2.1 | 0.6.0 - 0.9.x | 0.2.0 | 0.6.0 - 0.9.x | 0.1.1 | 0.6.0 - 0.9.6 | 0.1.0 | 0.6.0 - 0.8.0 | 0.0.3 | 0.6.0 - 0.6.1 | 0.0.2 | 0.5.7 | 0.0.1 | 0.5.7 |===

To ensure some basic compatibility, there are some integration tests in place. Newer mill versions may work as well.

If you need support for other versions, please create an {projectHome}/issues[issue].

== Download

You can download binary releases from https://search.maven.org/artifact/de.tototec/de.tobiasroeser.mill.kotlin_mill{mill-platform}_2.13[Maven Central].

Please make sure to use the correct mill platform suffix matching your used mill version.

.Mill Platform suffix [options="header"] |=== | mill version | mill platform | suffix | example | 0.11.x | 0.11 | _mill0.11 | $ivy.`de.tototec::de.tobiasroeser.mill.kotlin::{version}```` | 0.10.x | 0.10 | `_mill0.10` | $ivy.de.tototec::de.tobiasroeser .mill.kotlin::{version}```` | 0.9.3 - | 0.9 | _mill0.9 | ```$ivy.de.tototec::de.tobiasroeser.mill.kotlin_mill0.9:{version} | 0.7.0 - 0.8.0 | 0.7 | `_mill0.7` | ```$ivy.`de.tototec::de.tobiasroeser.mill.kotlin_mill0.7:{version} |===

== License

This project is published under the terms of the https://www.apache.org/licenses/LICENSE-2.0[Apache License, version 2]

== Supporters

Thanks to https://iba-cg.de/[iba Consulting Gesellschaft mbH & Co KG] for the initial development support.

== About

Mill:: https://github.com/lihaoyi/mill[Mill] is a Scala-based open source build tool. In my opinion the best build tool for the JVM. It is fast, reliable and easy to understand.

Me:: +

I am https://github.com/lefou/[Tobias Roeser], a professional software developer who loves to create and use open source tools. I'm actively developing and maintaining mill as well as https://github.com/lefou?utf8=%E2%9C%93&tab=repositories&q=topic%3Amill&type=&language=[several mill plugins].

If you like my work, please star it on GitHub. You can also support me via https://github.com/sponsors/lefou[GitHub Sponsors].

Contributing:: If you found a bug or have a feature request, please open a {projectHome}/issues[new issue on GitHub]. I also accept {projectHome}/pulls[pull requests on GitHub].

== Changelog

=== 0.3.0 - 2023-11-29 :version: 0.3.0 :prev-version: 0.2.4 :github-milestone: 8

  • Introduced a shared worker cache to speed up compilation and reduce memory usage

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.2.4 - 2023-10-23 :version: 0.2.4 :prev-version: 0.2.3 :github-milestone: 7

  • Internal improvements and dependency updates

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.2.3 - 2023-06-12 :version: 0.2.3 :prev-version: 0.2.2 :github-milestone: 6

  • Added support for Mill 0.11.x
  • Various internal improvements and version updates

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.2.2 - 2022-01-16 :version: main :prev-version: 0.2.1 :github-milestone: 5

  • Support for newer Mill versions including 0.10.0

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.2.1 - 2022-01-16 :version: 0.2.1 :prev-version: 0.2.0 :github-milestone: 4

  • Improved integration test suite
  • Various dependency version updates

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.2.0 - 2021-01-17 :version: 0.2.0 :prev-version: 0.1.1 :github-milestone:

  • Overall fixes and improvements
  • Enhanced integration test setup to detect Kotlin version differences
  • Proper support for Kotlin 1.3 and 1.4
  • Limited support for older Kotlin 1.0, 1.1 and 1.2

These versions may work for you, but I haven't found a stable integration test setup that works reliable for all these Kotlin releases on different platforms and different Java versions. If you know what you're doing, all integration points are configurable, so these versions should work after same tweaking. Feedback and pull requests are highly appreciated.

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.1.1 - 2020-12-01 :version: 0.1.1 :prev-version: 0.1.0 :github-milestone: 3

  • Support for mill API 0.9.3
  • Introduced artifact suffix indicating the mill platform (e.g. mill0.9)

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.1.0 - 2020-06-30 :version: 0.1.0 :prev-version: 0.0.3 :github-milestone: 2

  • Cross publish for Mill APi 0.6 and 0.7, also Scala 2.12 and Scala 2.13.

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.0.3 - 2020-02-25 :version: 0.0.3 :prev-version: 0.0.2 :github-milestone:

  • Updated Mill API to 0.6.0

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.0.2 - 2020-02-25 :version: 0.0.2 :prev-version: 0.0.1 :github-milestone: 1

  • Fixed non-functional kotlincHelp target

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]

=== 0.0.1 - 2020-02-20 :version: 0.0.1 :prev-version: 6756a7323d020eabedf9a9cd70f54c61fe30472a :github-milestone:

  • Initial release

See ifeval::["{github-milestone}" != ""] https://github.com/lefou/mill-kotlin/milestone/{github-milestone}?closed=1[milstone {version}] and the endif::[] https://github.com/lefou/mill-kotlin/compare/{prev-version}...{version}[list of commits]