diff options
author | Nikolay Tatarinov <5min4eq.unity@gmail.com> | 2018-05-06 11:26:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-06 11:26:21 +0300 |
commit | f7a02a46f847d4433cd771840fd0b6cc314215d8 (patch) | |
tree | 612a1d01a63a75dedd1c53bbeccf3083b9f52a65 /docs/pages | |
parent | 32c7515d6507e1898562203ea7c9d13a53d933c1 (diff) | |
download | mill-f7a02a46f847d4433cd771840fd0b6cc314215d8.tar.gz mill-f7a02a46f847d4433cd771840fd0b6cc314215d8.tar.bz2 mill-f7a02a46f847d4433cd771840fd0b6cc314215d8.zip |
Scalafmt support (#308)
* add scalafmt module, that formats all sources files on every run
* scalafmt worker that internally chaches reformatted files
* move jvm process call to helper method
* use scala 2.12.4 to resolve scalafmt deps; check for config file existence; add quiet flags to scalafmt CLI
* make a scalafmt worker a singleton
* add tests for scalafmt module
* add reformatAll command
* tests for reformatAll command
* add docs about scalafmt support
Diffstat (limited to 'docs/pages')
-rw-r--r-- | docs/pages/2 - Configuring Mill.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/pages/2 - Configuring Mill.md b/docs/pages/2 - Configuring Mill.md index a229fa72..43191950 100644 --- a/docs/pages/2 - Configuring Mill.md +++ b/docs/pages/2 - Configuring Mill.md @@ -213,6 +213,28 @@ You can use Scala compiler plugins by setting `scalacPluginIvyDeps`. The above example also adds the plugin to `compileIvyDeps`, since that plugin's artifact is needed on the compilation classpath (though not at runtime). +## Reformatting your code + +Mill supports code formatting via [scalafmt](https://scalameta.org/scalafmt/) out of the box. + +To have a formatting per-module you need to make your module extend `mill.scalalib.scalafmt.ScalafmtModule`: + +```scala +// build.sc +import mill._ +import mill.scalalib._ +import mill.scalalib.scalafmt._ + +object foo extends ScalaModule with ScalafmtModule { + def scalaVersion = "2.12.4" +} +``` + +Now you can reformat code with `mill foo.reformat` command. + +You can also reformat your project's code globally with `mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources` command. +It will reformat all sources that matches `__.sources` query. + ## Common Configuration ```scala |