Thirdparty Plugins
The Plugins in this section are developed/maintained outside the mill git tree. This list is most likely not complete. If you’re missing an external plugin or developed one which is not listed here, please open a pull request and add that plugin with a short description.
For details about including plugins in your build.sc
read Using Mill Plugins.
Besides the documentation provided here, we urge you to consult the respective linked plugin documentation pages. The usage examples given here are most probably incomplete and sometimes outdated! |
Antlr
ANTLR parser generator support for mill.
Project home: https://github.com/ml86/mill-antlr
AspectJ
AspectJ compiler support for mill.
Project home: https://github.com/lefou/mill-aspectj
Quickstart
import mill._
import mill.scalalib._
import mill.define._
// Load the plugin from Maven Central via ivy/coursier
import $ivy.`de.tototec::de.tobiasroeser.mill.aspectj_mill0.9:0.3.1-12-89db01
import de.tobiasroeser.mill.aspectj._
object main extends AspectjModule {
// Select the AspectJ version
def aspectjVersion = "1.9.5"
// Set AspectJ options, e.g. the language level and annotation processor
// Run `mill main.ajcHelp` to get a list of supported options
def ajcOptions = Seq("-8", "-proc:none")
}
For documentation, please refer to the project home page.
Bash Completion
Limited bash completion support.
Project home: https://github.com/lefou/mill-bash-completion
DGraph
Show transitive dependencies of your build in your browser.
Project home: https://github.com/ajrnz/mill-dgraph
Ensime
Create an .ensime file for your build.
Project home: https://github.com/davoclavo/mill-ensime
Quickstart
import mill._
interp.repositories() =
interp.repositories() ++ Seq(coursier.MavenRepository("https://jitpack.io"))
@
import $ivy.`com.github.yyadavalli::mill-ensime:0.0.2`
You can then run the following to generate the .ensime file
mill fun.valycorp.mill.GenEnsime/ensimeConfig
Optionally, you can specify the ensime server version using the –server flag like
mill fun.valycorp.mill.GenEnsime/ensimeConfig --server "3.0.0-SNAPSHOT"
Git
A git version plugin for mill.
Project home: https://github.com/joan38/mill-git
build.sc:
import $ivy.`com.goyeau::mill-git:<latest version>`
import com.goyeau.mill.git.GitVersionedPublishModule
import mill.scalalib.JavaModule
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
object `jvm-project` extends JavaModule with GitVersionedPublishModule {
override def pomSettings = PomSettings(
description = "JVM Project",
organization = "com.goyeau",
url = "https://github.com/joan38/mill-git",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("joan38", "mill-git"),
developers = Seq(Developer("joan38", "Joan Goyeau", "https://github.com/joan38"))
)
}
> mill show jvm-project.publishVersion
[1/1] show
[2/2] com.goyeau.mill.git.GitVersionModule.version
"0.0.0-470-6d0b3d9"
Integration Testing Mill Plugins
Integration testing for mill plugins.
Project home: https://github.com/lefou/mill-integrationtest
Quickstart
We assume, you have a mill plugin named mill-demo
// build.sc
import mill._, mill.scalalib._
object demo extends ScalaModule with PublishModule {
// ...
}
Add a new test sub-project, e.g. itest
.
// build.sc
import $ivy.`de.tototec::de.tobiasroeser.mill.integrationtest_mill0.9:0.4.0`
import de.tobiasroeser.mill.integrationtest._
object demo extends ScalaModule with PublishModule {
// ...
}
object itest extends MillIntegrationTestModule {
def millTestVersion = "0.9.3"
def pluginsUnderTest = Seq(demo)
}
Your project should now look similar to this:
.
+-- demo/
| +-- src/
|
+-- it/
+-- src/
+-- 01-first-test/
| +-- build.sc
| +-- src/
|
+-- 02-second-test/
+-- build.sc
As the buildfiles build.sc
in your test cases typically want to access the locally built plugin(s),
the plugins publishes all plugins referenced under pluginsUnderTest
to a temporary ivy repository, just before the test is executed.
The mill version used in the integration test then used that temporary ivy repository.
Instead of referring to your plugin with import $ivy.'your::plugin:version'
,
you can use the following line instead, which ensures you will use the correct locally build plugins.
// build.sc
import $exec.plugins
Effectively, at execution time, this line gets replaced by the content of plugins.sc
, a file which was generated just before the test started to execute.
Please always refer to the official plugin documentation site for complete and up-to-date information.
JBake
Create static sites/blogs with JBake.
Plugin home: https://github.com/lefou/mill-jbake
JBake home: https://jbake.org
Quickstart
// build.sc
import mill._
import $ivy.`de.tototec::de.tobiasroeser.mill.jbake:0.1.0`
import de.tobiasroeser.mill.jbake._
object site extends JBakeModule {
def jbakeVersion = "2.6.4"
}
Generate the site:
bash> mill site.jbake
Start a local Web-Server on Port 8820 with the generated site:
bash> mill site.jbakeServe
JBuildInfo
This is a mill module similar to BuildInfo but for Java. It will generate a Java class containing information from your build.
Project home: https://github.com/carueda/mill-jbuildinfo
To declare a module that uses this plugin, extend the
com.github.carueda.mill.JBuildInfo
trait and provide
the desired information via the buildInfoMembers
method:
// build.sc
import $ivy.`com.github.carueda::jbuildinfo:0.1.2`
import com.github.carueda.mill.JBuildInfo
import mill.T
object project extends JBuildInfo {
def buildInfoMembers: T[Map[String, String]] = T {
Map(
"name" -> "some name",
"version" -> "x.y.z"
)
}
}
This will generate:
// BuildInfo.java
public class BuildInfo {
public static final String getName() { return "some name"; }
public static final String getVersion() { return "x.y.z"; }
}
Configuration options
-
def buildInfoMembers: T[Map[String, String]]
The map containing all member names and values for the generated class.
-
def buildInfoClassName: String
, default:BuildInfo
The name of the class that will contain all the members from
buildInfoMembers
.
-
def buildInfoPackageName: Option[String]
, default:None
The package name for the generated class.
Kotlin
Kotlin compiler support for mill.
Project home: https://github.com/lefou/mill-kotlin
Quickstart
// Load the plugin from Maven Central via ivy/coursier
import $ivy.`de.tototec::de.tobiasroeser.mill.kotlin_mill0.9:0.2.0`
import mill._
import mill.scalalib._
import mill.define._
import de.tobiasroeser.mill.kotlin._
object main extends KotlinModule {
// Select the Kotlin version
def kotlinVersion = "1.4.21"
// 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")
}
Documentation
For documentation please visit the mill-kotlin project page.
You will find there also a version compatibility matrix.
Mill Wrapper Scripts
Small script to automatically fetch and execute mill build tool.
Project home: https://github.com/lefou/millw
How it works
millw
is a small wrapper script around mill and works almost identical to mill. It automatically downloads a mill release into $HOME/.mill/download
.
The mill version to be used will be determined by the following steps. The search ends, after the first step that results in a version.
-
If the first parameter is
--mill-version
, the second parameter will be used as the mill version. Example
` sh $ mill --mill-version 0.3.6 --disable-ticker version 0.3.6 `
-
If there is a file
.mill-version
in the working directory, it’s content will be used as mill version. The file must have only a mill version as content, no additional content or comments are supported. Example
` sh $ echo -n "0.3.6" > .mill-version sh $ mill --disable-ticker version 0.3.6 `
The values of the DEFAULT_MILL_VERSION
variable inside the script will be used.
Use cases
As mill executable
Istead of installing mill, you can just place the script into you local $HOME/bin
directory and rename it to mill
.
If you need a special mill version in a project directory, just place a .mill-version
file with the best mill version.
Example: setting mill 0.3.6 as best local mill version
sh $ echo -n "0.3.6" > .mill-version
As a wrapper script in your project
To make the start for others easier or to always have the correct mill version in your CI environment, you can just place a copy of the script as millw
in your project root directory.
You should change the DEFAULT_MILL_VERSION
variable in that script to the correct version you want to use and add the file under version control.
OSGi
Produce OSGi Bundles with mill.
Project home: https://github.com/lefou/mill-osgi
Quickstart
import mill._, mill.scalalib._
import $ivy.`de.tototec::de.tobiasroeser.mill.osgi:0.0.5`
import de.tobiasroeser.mill.osgi._
object project extends ScalaModule with OsgiBundleModule {
def bundleSymbolicName = "com.example.project"
def osgiHeaders = T{ super.osgiHeaders().copy(
`Export-Package` = Seq("com.example.api"),
`Bundle-Activator` = Some("com.example.internal.Activator")
)}
// other settings ...
}
PublishM2
Since Mill 0.6.1-27-f265a4
there is a built-in publishM2Local
target in PublishModule
.
Mill plugin to publish artifacts into a local Maven repository.
Project home: https://github.com/lefou/mill-publishM2
Quickstart
Just mix-in the PublishM2Module
into your project.
PublishM2Module
already extends mill’s built-in PublishModule
.
File: build.sc
import mill._, scalalib._, publish._
import $ivy.`de.tototec::de.tobiasroeser.mill.publishM2:0.0.1`
import de.tobiasroeser.mill.publishM2._
object project extends PublishModule with PublishM2Module {
// ...
}
Publishing to default local Maven repository
> mill project.publishM2Local
[40/40] project.publishM2Local
Publishing to /home/user/.m2/repository
Publishing to custom local Maven repository
> mill project.publishM2Local /tmp/m2repo
[40/40] project.publishM2Local
Publishing to /tmp/m2repo
Scalafix
Scalafix support for mill.
Project home: https://github.com/joan38/mill-scalafix
Fix sources
build.sc:
import $ivy.`com.goyeau::mill-scalafix:<latest version>`
import com.goyeau.mill.scalafix.ScalafixModule
import mill.scalalib._
object project extends ScalaModule with ScalafixModule {
def scalaVersion = "2.12.11"
}
> mill project.fix
[29/29] project.fix
/project/project/src/MyClass.scala:12:11: error: [DisableSyntax.var] mutable state should be avoided
private var hashLength = 7
^^^
1 targets failed
project.fix A Scalafix linter error was reported
VCS Version
Mill plugin to derive a version from (last) git tag and edit state. It may support other VCS as well.
Project home: https://github.com/lefou/mill-vcs-version
Lots of formatting options are provided. When used with its defaults, the outcome is identical to the version scheme used by mill.
Quickstart
import mill._
import mill.scalalib._
// Load the plugin from Maven Central via ivy/coursier
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.2`
import de.tobiasroeser.mill.vcs.version.VcsVersion
object main extends JavaModule with PublishModule {
override def publishVersion: T[String] = VcsVersion.vcsState().format()
}