summaryrefslogtreecommitdiff
path: root/docs/pages/2 - Configuring Mill.md
diff options
context:
space:
mode:
authorSakib Hadžiavdić <sake92@users.noreply.github.com>2018-06-07 05:41:20 +0200
committerLi Haoyi <haoyi.sg@gmail.com>2018-06-06 20:41:20 -0700
commit8d8c951d2716873f8b1a2dd00b56a8a73ff45e31 (patch)
tree54cc9b0d8cfdf5359e80559b5286d5712f37aa2f /docs/pages/2 - Configuring Mill.md
parente34e67588be6978451fb198335ae938aa17e5964 (diff)
downloadmill-8d8c951d2716873f8b1a2dd00b56a8a73ff45e31.tar.gz
mill-8d8c951d2716873f8b1a2dd00b56a8a73ff45e31.tar.bz2
mill-8d8c951d2716873f8b1a2dd00b56a8a73ff45e31.zip
Fixed typos, wordings, formatted examples (#365)
Diffstat (limited to 'docs/pages/2 - Configuring Mill.md')
-rw-r--r--docs/pages/2 - Configuring Mill.md78
1 files changed, 37 insertions, 41 deletions
diff --git a/docs/pages/2 - Configuring Mill.md b/docs/pages/2 - Configuring Mill.md
index 03489f68..036fbe6b 100644
--- a/docs/pages/2 - Configuring Mill.md
+++ b/docs/pages/2 - Configuring Mill.md
@@ -3,8 +3,8 @@ You can configure your Mill build in a number of ways:
## Compilation & Execution Flags
```scala
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
@@ -40,8 +40,8 @@ mill foo.runLocal arg1 arg2 arg3
## Adding Ivy Dependencies
```scala
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
def ivyDeps = Agg(
@@ -77,6 +77,7 @@ custom `ScalaWorkerModule`, and override the `scalaWorker` method in your
```scala
import coursier.maven.MavenRepository
+
object CustomScalaWorkerModule extends ScalaWorkerModule {
def repositories() = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
@@ -92,12 +93,12 @@ object YourBuild extends ScalaModule {
## Adding a Test Suite
```scala
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
- object test extends Tests{
+ object test extends Tests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.0")
def testFrameworks = Seq("utest.runner.Framework")
}
@@ -154,16 +155,16 @@ You can define multiple test suites if you want, e.g.:
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
- object test extends Tests{
+ object test extends Tests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.0")
def testFrameworks = Seq("utest.runner.Framework")
}
- object integration extends Tests{
+ object integration extends Tests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.0")
def testFrameworks = Seq("utest.runner.Framework")
}
@@ -198,8 +199,8 @@ passing args to the test suite via `mill foo.test arg1 arg2 arg3`
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
@@ -221,9 +222,7 @@ To have a formatting per-module you need to make your module extend `mill.scalal
```scala
// build.sc
-import mill._
-import mill.scalalib._
-import mill.scalalib.scalafmt._
+import mill._, scalalib._, scalafmt._
object foo extends ScalaModule with ScalafmtModule {
def scalaVersion = "2.12.4"
@@ -239,9 +238,9 @@ It will reformat all sources that matches `__.sources` query.
```scala
// build.sc
-import mill._
-import mill.scalalib._
-trait CommonModule extends ScalaModule{
+import mill._, scalalib._
+
+trait CommonModule extends ScalaModule {
def scalaVersion = "2.12.4"
}
@@ -285,28 +284,28 @@ Everything declared in the above file will be available to any build you run.
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
+
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
}
-def lineCount = T{
+def lineCount = T {
import ammonite.ops._
foo.sources().flatMap(ref => ls.rec(ref.path)).filter(_.isFile).flatMap(read.lines).size
}
-def printLineCount() = T.command{
+def printLineCount() = T.command {
println(lineCount())
}
```
-You can define new cached Targets using the `T{...}` syntax, depending on
+You can define new cached Targets using the `T {...}` syntax, depending on
existing Targets e.g. `foo.sources` via the `foo.sources()` syntax to extract
their current value, as shown in `lineCount` above. The return-type of a Target
has to be JSON-serializable (using
[uPickle](https://github.com/lihaoyi/upickle)) and the Target is cached when
-first run until it's inputs change (in this case, if someone edits the
+first run until its inputs change (in this case, if someone edits the
`foo.sources` files which live in `foo/src`. Cached Targets cannot take
parameters.
@@ -316,12 +315,12 @@ You can print the value of your custom target using `show`, e.g.
mill run show lineCount
```
-You can define new un-cached Commands using the `T.command{...}` syntax. These
+You can define new un-cached Commands using the `T.command {...}` syntax. These
are un-cached and re-evaluate every time you run them, but can take parameters.
Their return type needs to be JSON-writable as well, or `(): Unit` if you want
to return nothing.
-Your custom targets can depend on each other using the `def bar = T{... foo()
+Your custom targets can depend on each other using the `def bar = T {... foo()
...}` syntax, and you can create arbitrarily long chains of dependent targets.
Mill will handle the re-evaluation and caching of the targets' output for you,
and will provide you a `T.ctx().dest` folder for you to use as scratch space or
@@ -332,15 +331,15 @@ download files (e.g. using `mill.modules.Util.download`), shell-out to Webpack
to compile some Javascript, generate sources to feed into a compiler, or create
some custom jar/zip assembly with the files you want (e.g. using
`mill.modules.Jvm.createJar`), all of these can simply be custom targets with
-your code running in the `T{...}` block.
+your code running in the `T {...}` block.
## Custom Modules
```scala
// build.sc
-import mill._
-import mill.scalalib._
-object qux extends Module{
+import mill._, scalalib._
+
+object qux extends Module {
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
}
@@ -365,7 +364,7 @@ to represent other things e.g. Javascript bundles, docker image building,:
```scala
// build.sc
-trait MySpecialModule extends Module{
+trait MySpecialModule extends Module {
...
}
object foo extends MySpecialModule
@@ -414,16 +413,15 @@ mill unhyphenatedModule.unhyphenated_target2
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
- def compile = T{
+ def compile = T {
println("Compiling...")
super.compile()
}
- def run(args: String*) = T.command{
+ def run(args: String*) = T.command {
println("Running..." + args.mkString(" "))
super.run(args:_*)
}
@@ -444,12 +442,11 @@ In Mill builds the `override` keyword is optional.
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
- def unmanagedClasspath = T{
+ def unmanagedClasspath = T {
if (!ammonite.ops.exists(millSourcePath / "lib")) Agg()
else Agg.from(ammonite.ops.ls(millSourcePath / "lib"))
}
@@ -481,8 +478,7 @@ main class to your `foo.jar` and `foo.assembly` jars.
```scala
// build.sc
-import mill._
-import mill.scalalib._
+import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.12.4"