Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge April 1 - 4, 2018 changes on master #283

Merged
merged 14 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ clone_folder: c:\mill

environment:
matrix:
- COMPILER: default
JAVA_HOME: C:\Program Files\Java\jdk9
- COMPILER: cygwin
CYGWIN_DIR: cygwin64
JAVA_HOME: C:\Program Files\Java\jdk9
Expand All @@ -17,26 +19,26 @@ environment:
MSYS2_DIR: msys64
MSYSTEM: MINGW64
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- COMPILER: msys2
MSYS2_ARCH: x86_64
MSYS2_DIR: msys64
MSYSTEM: MINGW64
JAVA_HOME: C:\Program Files\Java\jdk9

cache:
- '%LOCALAPPDATA%\Coursier\cache'
- '%LOCALAPPDATA%\Coursier\cache -> build.sc'

install:
- SET MILL_URL=https://github.com/lihaoyi/mill/releases/download/0.1.7/0.1.7-8-b913c6
- SET MILL_URL=https://github.com/lihaoyi/mill/releases/download/0.1.7/0.1.7-29-f5097f

build_script:
- if [%COMPILER%]==[default] (
SET "PATH=%JAVA_HOME%\bin;%PATH%" &&
MD C:\bin &&
curl -Lo C:\bin\mill.bat %MILL_URL% &&
cmd /C C:\bin\mill.bat -i all __.publishLocal release &&
cmd /C C:\mill\out\release\dest\mill.bat -i all main.test scalajslib.test)
- if [%COMPILER%]==[msys2] (
SET "PATH=%JAVA_HOME%\bin;C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%" &&
C:\%MSYS2_DIR%\usr\bin\bash -lc 'mkdir -p /usr/local/bin' &&
C:\%MSYS2_DIR%\usr\bin\bash -lc "curl -Lo /usr/local/bin/mill %MILL_URL%" &&
C:\%MSYS2_DIR%\usr\bin\bash -lc 'chmod +x /usr/local/bin/mill' &&
C:\%MSYS2_DIR%\usr\bin\bash -lc "cd /c/mill && mill -i all __.publishLocal release" &&
rd /s /q %USERPROFILE%\.mill &&
C:\%MSYS2_DIR%\usr\bin\bash -lc "cd /c/mill && out/release/dest/mill -i all main.test scalajslib.test")
- if [%COMPILER%]==[cygwin] (
SET "PATH=%JAVA_HOME%\bin;C:\%CYGWIN_DIR%\bin;C:\%CYGWIN_DIR%\usr\bin;%PATH%" &&
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ matrix:
env: CI_SCRIPT=ci/test-mill-dev.sh
jdk: oraclejdk9
- stage: build
env: CI_SCRIPT=ci/test-mill-0.sh
env: CI_SCRIPT=ci/test-mill-bootstrap.sh
jdk: oraclejdk9

- stage: release
Expand All @@ -38,7 +38,7 @@ matrix:
jdk: oraclejdk8

script:
- curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.1.7/0.1.7-8-b913c6 && chmod +x ~/bin/mill
- curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.1.7/0.1.7-29-f5097f && chmod +x ~/bin/mill
- export PATH=~/bin/mill:$PATH
- "$CI_SCRIPT"

Expand Down
33 changes: 16 additions & 17 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,21 @@ def launcherScript(jvmArgs: Seq[String],
)
}

val isBatch =
scala.util.Properties.isWin &&
!(org.jline.utils.OSUtils.IS_CYGWIN
|| org.jline.utils.OSUtils.IS_MINGW
|| "MSYS" == System.getProperty("MSYSTEM"))


object dev extends MillModule{
def moduleDeps = Seq(scalalib, scalajslib)
def forkArgs = T{
scalalib.testArgs() ++ scalajslib.testArgs() ++ scalaworker.testArgs()
}
def launcher = T{
val isWin = scala.util.Properties.isWin
val outputPath = T.ctx().dest / "run"
val outputPath = T.ctx().dest / (if (isBatch) "run.bat" else "run")

write(outputPath, prependShellScript())

Expand All @@ -280,7 +287,7 @@ object dev extends MillModule{
}

def assembly = T{
val filename = "mill"
val filename = if (isBatch) "mill.bat" else "mill"
mv(super.assembly().path, T.ctx().dest / filename)
PathRef(T.ctx().dest / filename)
}
Expand All @@ -307,29 +314,21 @@ object dev extends MillModule{
}
}

private def releaseHelper(dest: Path,
cp: Agg[Path],
ver: String)
(implicit ctx: mill.util.Ctx.Dest): PathRef = {
def release = T{
val dest = T.ctx().dest
val filename = if (isBatch) "mill.bat" else "mill"
mv(
createAssembly(
cp,
dev.runClasspath().map(_.path),
prependShellScript = launcherScript(
Seq("-DMILL_VERSION=" + ver),
Seq("-DMILL_VERSION=" + publishVersion()._2),
Agg("$0"),
Agg("%~dpnx0")
)
).path,
dest / "mill"
dest / filename
)
PathRef(dest / "mill")
}

def release = T{
releaseHelper(
T.ctx().dest,
dev.runClasspath().map(_.path),
publishVersion()._2)
PathRef(dest / filename)
}

val isMasterCommit = {
Expand Down
4 changes: 2 additions & 2 deletions ci/test-mill-0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -eux
# Starting from scratch...
git clean -xdf

# Run tests using Mill built using SBT
mill all {clientserver,main,scalalib,scalajslib}.test
# Run tests
mill -i all {clientserver,main,scalalib,scalajslib}.test
2 changes: 1 addition & 1 deletion ci/test-mill-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -eux
# Starting from scratch...
git clean -xdf

# Run tests using Mill built using SBT
# Run tests
mill integration.test "mill.integration.local.{JawnTests,BetterFilesTests,UpickleTests}"
2 changes: 1 addition & 1 deletion ci/test-mill-2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -eux
# Starting from scratch...
git clean -xdf

# Run tests using Mill built using SBT
# Run tests
mill integration.test "mill.integration.local.{AcyclicTests,AmmoniteTests}"
26 changes: 26 additions & 0 deletions ci/test-mill-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -eux

# Starting from scratch...
git clean -xdf

# First build
mill -i all __.publishLocal release
mv out/release/dest/mill ~/mill-1

# Clean up
git clean -xdf

# Differentiate first and second builds
echo "Build 2" > info.txt && git add info.txt && git commit -m "Add info.txt"

# Second build
~/mill-1 -i all __.publishLocal release
mv out/release/dest/mill ~/mill-2

# Clean up
git clean -xdf

# Use second build to run tests using Mill
~/mill-2 -i all {clientserver,main,scalalib,scalajslib}.test
4 changes: 1 addition & 3 deletions ci/test-mill-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ git clean -xdf
# Build Mill
mill -i dev.assembly

rm -fR ~/.mill

# Second build & run tests using Mill
# Second build & run tests
out/dev/assembly/dest/mill -i all {clientserver,main,scalalib,scalajslib}.test

7 changes: 3 additions & 4 deletions ci/test-mill-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ set -eux
# Starting from scratch...
git clean -xdf

# Build Mill
ci/publish-local.sh

# Clean up
git clean -xdf

rm -fR ~/.mill

# Second build & run tests using Mill

# Run tests
~/mill-release -i integration.test "mill.integration.forked.{AcyclicTests,UpickleTests,PlayJsonTests}"
8 changes: 3 additions & 5 deletions docs/pages/1 - Intro to Mill.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,12 @@ res2: mill.scalalib.CompilationResult = CompilationResult(
)
```

You can run `mill` alone to open a build REPL; this is a Scala console with your
You can run `mill -i` to open a build REPL; this is a Scala console with your
`build.sc` loaded, which lets you run tasks interactively. The task-running
syntax is slightly different from the command-line, but more in-line with how
you would depend on tasks from within your build file.

You can use this REPL to run build commands quicker, due to keeping the JVM warm
between runs, or to interactively explore your build to see what is available.
You can use this REPL to interactively explore your build to see what is available.

## Deploying your code

Expand Down Expand Up @@ -543,6 +542,5 @@ You also need to specify `release` as `true` or `false`, depending on whether
you just want to stage your module on `oss.sonatype.org` or you want Mill to
complete the release process to Maven Central.

If you are publishing multiple artifacts, you can also use `target/bin/mill
mill.scalalib.PublishModule/publishAll1 as described
If you are publishing multiple artifacts, you can also use `mill mill.scalalib.PublishModule/publishAll` as described
[here](http://www.lihaoyi.com/mill/page/common-project-layouts.html#publishing)
6 changes: 5 additions & 1 deletion main/src/mill/modules/Jvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ object Jvm {
jvmArgs: Seq[String])
(implicit ctx: Ctx.Dest)= {
val isWin = scala.util.Properties.isWin
val outputPath = ctx.dest / "run"
val isBatch = isWin &&
!(org.jline.utils.OSUtils.IS_CYGWIN
|| org.jline.utils.OSUtils.IS_MINGW
|| "MSYS" == System.getProperty("MSYSTEM"))
val outputPath = ctx.dest / (if (isBatch) "run.bat" else "run")
val classPathStrs = classPath.map(_.toString)

write(outputPath, launcherUniversalScript(mainClass, classPathStrs, classPathStrs, jvmArgs))
Expand Down
35 changes: 26 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,41 @@ rm -rf out/

## Changelog

### Master

- Universal (combined batch/sh) script generation for launcher, assembly, and release

For some shell (e.g., `ksh` or `fish`), a shebang line should be added, e.g., using GNU sed:

```bash
sed -i '1s;^;#!/usr/bin/env sh\n;' <mill-path>
```

Or download directly with shebang added as follows:

```bash
sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L <mill-url>) > /usr/local/bin/mill && chmod +x /usr/local/bin/mill'
```

On Windows, save `<mill-url>` as `mill.bat`

- Windows client/server improvements

- Windows repl support (note: MSYS2 subsystem/shell will be supported when jline3 v3.6.3 is released)

- Fixed Java 9 support

### 0.1.7

- Windows batch (.bat) generation for launcher, assembly, and release

- Support for non-interactive (client/server) mode on Windows.

Mill requires an `sh` environment to run on Windows;
it is recommended to use [MSYS2](https://www.msys2.org) on Windows.

[Cygwin](https://www.cygwin.com) can also be used,
but your mileage may vary when running mill on non-interactive (client/server) mode
(it failed intermittently in mill's AppVeyor tests).
On Cygwin, run the following after downloading mill:

```bash
sed -i '0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}; 0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}' <mill-path>
```

Mill also runs on [Git-Bash](https://gitforwindows.org) and [WSL](https://docs.microsoft.com/windows/wsl)
but only on interactive mode.

- More fixes for Java 9

Expand Down
10 changes: 6 additions & 4 deletions scalalib/src/mill/scalalib/Dep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ sealed trait Dep {
}
object Dep{

val DefaultConfiguration = "default(compile)"

implicit def parse(signature: String) = {
val parts = signature.split(';')
val module = parts.head
Expand All @@ -45,15 +47,15 @@ object Dep{
}).configure(attributes = attributes)
}
def apply(org: String, name: String, version: String, cross: Boolean): Dep = {
this(coursier.Dependency(coursier.Module(org, name), version), cross)
this(coursier.Dependency(coursier.Module(org, name), version, DefaultConfiguration), cross)
}
case class Java(dep: coursier.Dependency, cross: Boolean, force: Boolean) extends Dep {
def configure(attributes: coursier.Attributes): Dep = copy(dep = dep.copy(attributes = attributes))
}
object Java{
implicit def rw: RW[Java] = macroRW
def apply(org: String, name: String, version: String, cross: Boolean, force: Boolean): Dep = {
Java(coursier.Dependency(coursier.Module(org, name), version), cross, force)
Java(coursier.Dependency(coursier.Module(org, name), version, DefaultConfiguration), cross, force)
}
}
implicit def default(dep: coursier.Dependency): Dep = new Java(dep, false, false)
Expand All @@ -64,7 +66,7 @@ object Dep{
object Scala{
implicit def rw: RW[Scala] = macroRW
def apply(org: String, name: String, version: String, cross: Boolean, force: Boolean): Dep = {
Scala(coursier.Dependency(coursier.Module(org, name), version), cross, force)
Scala(coursier.Dependency(coursier.Module(org, name), version, DefaultConfiguration), cross, force)
}
}
case class Point(dep: coursier.Dependency, cross: Boolean, force: Boolean) extends Dep {
Expand All @@ -73,7 +75,7 @@ object Dep{
object Point{
implicit def rw: RW[Point] = macroRW
def apply(org: String, name: String, version: String, cross: Boolean, force: Boolean): Dep = {
Point(coursier.Dependency(coursier.Module(org, name), version), cross, force)
Point(coursier.Dependency(coursier.Module(org, name), version, DefaultConfiguration), cross, force)
}
}
implicit def rw = RW.merge[Dep](
Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/ScalaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ trait ScalaModule extends mill.Module with TaskModule { outer =>
unmanagedClasspath() ++
resolveDeps(T.task{
runIvyDeps() ++ scalaLibraryIvyDeps() ++ transitiveIvyDeps() ++
Agg(ivy"com.lihaoyi:::ammonite:1.1.0-7-33b728c")
Agg(ivy"com.lihaoyi:::ammonite:1.1.0-12-f07633d")
})()
}

Expand Down
6 changes: 3 additions & 3 deletions scalalib/src/mill/scalalib/publish/Ivy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ object Ivy {

private def renderDependency(dep: Dependency) = {
if (dep.exclusions.isEmpty)
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${dep.scope}->default(${dep.configuration.getOrElse("compile")})"} />
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${scopeToConf(dep.scope)}->${dep.configuration.getOrElse("default(compile)")}"} />
else
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${dep.scope}->default(${dep.configuration.getOrElse("compile")})"}>
{dep.exclusions.map(ex => <exclude org={ex._1} name={ex._2} matcher="exact"/>).toSeq}
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${scopeToConf(dep.scope)}->${dep.configuration.getOrElse("default(compile)")}"}>
{dep.exclusions.map(ex => <exclude org={ex._1} name={ex._2} matcher="exact"/>)}
</dependency>
}

Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/publish/Pom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object Pom {
<groupId>{ex._1}</groupId>
<artifactId>{ex._2}</artifactId>
</exclude>
)}.toSeq
)}
</exclusions>
{scope}
</dependency>
Expand Down
8 changes: 8 additions & 0 deletions scalalib/test/src/mill/scalalib/ResolveDepsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ object ResolveDepsTests extends TestSuite {
assert(paths.items.next.path.toString.contains("natives-macos"))
}

'resolveTransitiveRuntimeDeps - {
val deps = Agg(ivy"org.mockito:mockito-core:2.7.22")
val Success(paths) = evalDeps(deps)
assert(paths.nonEmpty)
assert(paths.exists(_.path.toString.contains("objenesis")))
assert(paths.exists(_.path.toString.contains("byte-buddy")))
}

'excludeTransitiveDeps - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".exclude("com.lihaoyi" -> "fansi_2.12"))
val Success(paths) = evalDeps(deps)
Expand Down