diff options
author | Roman Timushev <rtimush@gmail.com> | 2017-12-13 17:47:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 17:47:59 +0100 |
commit | 7fc589857d7943668ac045997cc5eb128d2e24d1 (patch) | |
tree | 5578a0ad151abaedee4d12a61eb14a624e0fe9c7 | |
parent | 34494b02ac6622534694dd4285da5d5f224b8885 (diff) | |
parent | 7fea597f77386a4e430b6437e2c90ec8dbd9e9b7 (diff) | |
download | mill-7fc589857d7943668ac045997cc5eb128d2e24d1.tar.gz mill-7fc589857d7943668ac045997cc5eb128d2e24d1.tar.bz2 mill-7fc589857d7943668ac045997cc5eb128d2e24d1.zip |
Merge pull request #66 from lihaoyi/bin
Separate module for Mill binary
-rw-r--r-- | build.sbt | 7 | ||||
-rwxr-xr-x | build.sc | 12 | ||||
-rw-r--r-- | readme.md | 22 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala | 2 |
4 files changed, 29 insertions, 14 deletions
@@ -101,7 +101,12 @@ lazy val scalaplugin = project name := "mill-scalaplugin", fork in Test := true, baseDirectory in (Test, test) := (baseDirectory in (Test, test)).value / "..", - javaOptions in (Test, test) := bridgeProps.value.toSeq, + javaOptions in (Test, test) := bridgeProps.value.toSeq + ) +lazy val bin = project + .dependsOn(scalaplugin) + .settings( + sharedSettings, assemblyOption in assembly := { (assemblyOption in assembly).value.copy( prependShellScript = Some( @@ -82,10 +82,12 @@ val bridges = for{ Dep.Java("org.scala-sbt", "compiler-interface", "1.0.5") ) } + object ScalaPlugin extends MillModule { override def projectDeps = Seq(Core) def basePath = pwd / 'scalaplugin + override def testArgs = T{ val mapping = Map( "MILL_COMPILER_BRIDGE_2_10_6" -> bridges("2.10.6").compile().classes.path, @@ -97,6 +99,13 @@ object ScalaPlugin extends MillModule { for((k, v) <- mapping.toSeq) yield s"-D$k=$v" } +} + +object Bin extends MillModule { + + override def projectDeps = Seq(ScalaPlugin) + def basePath = pwd / 'bin + def releaseAssembly = T{ createAssembly( (runDepClasspath().filter(_.path.ext != "pom") ++ @@ -109,5 +118,6 @@ object ScalaPlugin extends MillModule { override def prependShellScript = "#!/usr/bin/env sh\n" + - s"""exec java ${testArgs().mkString(" ")} $$JAVA_OPTS -cp "$$0" mill.Main "$$@" """ + s"""exec java ${ScalaPlugin.testArgs().mkString(" ")} $$JAVA_OPTS -cp "$$0" mill.Main "$$@" """ + } @@ -14,7 +14,7 @@ sbt core/test Build a standalone executable jar: ```bash -sbt scalaplugin/test:assembly +sbt bin/test:assembly ``` Now you can re-build this very same project using the build.sc file, e.g. re-run @@ -22,16 +22,16 @@ core unit tests e.g.: ```bash -./scalaplugin/target/mill run Core.compile -./scalaplugin/target/mill run Core.test.compile -./scalaplugin/target/mill run Core.test -./scalaplugin/target/mill run ScalaPlugin.assembly +./bin/target/mill run Core.compile +./bin/target/mill run Core.test.compile +./bin/target/mill run Core.test +./bin/target/mill run ScalaPlugin.assembly ``` there is already a `watch` option that looks for changes on files, e.g.: ```bash -./scalaplugin/target/mill --watch run Core.compile +./bin/target/mill --watch run Core.compile ``` output will be generated into a the `./out` folder. @@ -39,7 +39,7 @@ output will be generated into a the `./out` folder. Lastly, you can generate IntelliJ Scala project files using Mill via ```bash -./scalaplugin/target/mill idea +./bin/target/mill idea ``` Allowing you to import a Mill project into Intellij without using SBT @@ -50,7 +50,7 @@ Mill provides a build REPL, which lets you explore the build interactively and run `Target`s from Scala code: ```scala -lihaoyi mill$ scalaplugin/target/mill --repl +lihaoyi mill$ bin/target/mill --repl Loading... Compiling (synthetic)/ammonite/predef/interpBridge.sc Compiling (synthetic)/ammonite/predef/replBridge.sc @@ -120,13 +120,13 @@ Mill executables that can you can use to run Mill commands: git clean -xdf # Build Mill executable using SBT -sbt scalaplugin/test:assembly +sbt bin/test:assembly # Build Mill executable using the Mill executable generated by SBT -scalaplugin/target/mill run ScalaPlugin.assembly +bin/target/mill run Bin.assembly # Build Mill executable using the Mill executable generated by Mill itself -out/ScalaPlugin/assembly run ScalaPlugin.assembly +out/Bin/assembly run Bin.assembly ``` Eventually, as Mill stabilizes, we will get rid of the SBT build entirely and diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala b/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala index 21ecdca1..5c9aa4f7 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala @@ -108,7 +108,7 @@ object Lib{ val newResult = ic.compile( ic.inputs( classpath = classesIODir +: compileClasspathFiles, - sources = sources.flatMap(ls.rec).filter(x => x.isFile && x.ext == "scala").map(_.toIO).toArray, + sources = sources.filter(_.toIO.exists()).flatMap(ls.rec).filter(x => x.isFile && x.ext == "scala").map(_.toIO).toArray, classesDirectory = classesIODir, scalacOptions = (scalacPluginClasspath.map(jar => s"-Xplugin:${jar}") ++ scalacOptions).toArray, javacOptions = javacOptions.toArray, |