Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lihaoyi/mill
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jul 7, 2018
2 parents d93b9ab + 94fd8e3 commit 2c5546d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
13 changes: 13 additions & 0 deletions docs/pages/1 - Intro to Mill.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ To get started, download Mill from:
https://github.com/lihaoyi/mill/releases/download/0.2.4/0.2.4, and save it as
`mill.bat`.

If you're using [Scoop](https://scoop.sh) you can install Mill via

```bash
scoop install mill
```

Mill also works on a sh environment on Windows (e.g.,
[MSYS2](https://www.msys2.org),
[Cygwin](https://www.cygwin.com),
Expand All @@ -54,6 +60,13 @@ to get started, follow the instructions in the [manual](#manual) section below.
sed -i '0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}; 0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}' /usr/local/bin/mill
```

### Docker
You can download and run a [Docker image containing OpenJDK, Scala and Mill](https://hub.docker.com/r/nightscape/scala-mill/) using
```bash
docker pull nightscape/scala-mill
docker run -it nightscape/scala-mill
```

### Manual

To get started, download Mill and install it into your system via the following
Expand Down
26 changes: 25 additions & 1 deletion docs/pages/2 - Configuring Mill.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ object foo extends ScalaModule {
def scalaVersion = "2.12.4"
def unmanagedClasspath = T {
if (!ammonite.ops.exists(millSourcePath / "lib")) Agg()
else Agg.from(ammonite.ops.ls(millSourcePath / "lib"))
else Agg.from(ammonite.ops.ls(millSourcePath / "lib").map(PathRef(_)))
}
}
```
Expand All @@ -474,6 +474,30 @@ compilation output, but if there is more than one or the main class comes from
some library you can explicitly specify which one to use. This also adds the
main class to your `foo.jar` and `foo.assembly` jars.

## Merge/exclude files from assembly

When you make a runnable jar of your project with `assembly` command,
you may want to exclude some files from a final jar (like signature files, and manifest files from library jars),
and merge duplicated files (for instance `reference.conf` files from library dependencies).

By default mill excludes all `*.sf`, `*.dsa`, `*.rsa`, and `META-INF/MANIFEST.MF` files from assembly, and concatenates all `reference.conf` files.
You can also define your own merge/exclude rules.

```scala
// build.sc
import mill._, scalalib._
import mill.modules.Assembly._

object foo extends ScalaModule {
def scalaVersion = "2.12.4"
def assemblyRules = Seq(
Rule.Append("application.conf"), // all application.conf files will be concatenated into single file
Rule.AppendPattern(".*\\.conf"), // all *.conf files will be concatenated into single file
Rule.ExcludePattern("*.temp") // all *.temp files will be excluded from a final jar
)
}
```

## Downloading Non-Maven Jars

```scala
Expand Down
7 changes: 6 additions & 1 deletion scalalib/src/mill/scalalib/ScalaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ trait ScalaModule extends JavaModule { outer =>
}

override def resolvePublishDependency: Task[Dep => publish.Dependency] = T.task{
publish.Artifact.fromDep(_: Dep, scalaVersion(), Lib.scalaBinaryVersion(scalaVersion()))
publish.Artifact.fromDep(
_: Dep,
scalaVersion(),
Lib.scalaBinaryVersion(scalaVersion()),
platformSuffix()
)
}

override def finalMainClassOpt: T[Either[String, String]] = T{
Expand Down
7 changes: 4 additions & 3 deletions scalalib/src/mill/scalalib/publish/settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ object Artifact {
}
def fromDep(dep: Dep,
scalaFull: String,
scalaBin: String): Dependency = {
scalaBin: String,
platformSuffix: String): Dependency = {
dep match {
case d: Dep.Java => fromDepJava(d)
case Dep.Scala(dep, cross, force) =>
Dependency(
Artifact(
dep.module.organization,
s"${dep.module.name}_${scalaBin}",
s"${dep.module.name}${platformSuffix}_${scalaBin}",
dep.version
),
Scope.Compile,
Expand All @@ -38,7 +39,7 @@ object Artifact {
Dependency(
Artifact(
dep.module.organization,
s"${dep.module.name}_${scalaFull}",
s"${dep.module.name}${platformSuffix}_${scalaFull}",
dep.version
),
Scope.Compile,
Expand Down

0 comments on commit 2c5546d

Please sign in to comment.