diff --git a/build.sc b/build.sc index c16284069fa4..1df11f92b94e 100755 --- a/build.sc +++ b/build.sc @@ -1,7 +1,7 @@ import $file.ci.shared import $file.ci.upload import java.nio.file.attribute.PosixFilePermission -import $ivy.`org.scalaj::scalaj-http:2.4.1` +import $ivy.`org.scalaj::scalaj-http:2.4.2` import coursier.maven.MavenRepository import mill._ @@ -12,19 +12,18 @@ import mill.modules.Jvm.createAssembly object Deps { object Scalajs_0_6 { - val scalajsJsEnvs = ivy"org.scala-js::scalajs-js-envs:0.6.22" - val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:0.6.22" - val scalajsTools = ivy"org.scala-js::scalajs-tools:0.6.22" + val scalajsJsEnvs = ivy"org.scala-js::scalajs-js-envs:0.6.32" + val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:0.6.32" + val scalajsTools = ivy"org.scala-js::scalajs-tools:0.6.32" } object Scalajs_1_0 { - val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.0.0-RC1" - val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.0.0-RC1" - val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0-RC1" - val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:1.0.0-RC1" - val scalajsLinker = ivy"org.scala-js::scalajs-linker:1.0.0-RC1" + val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.0.0" + val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.0.0" + val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0" + val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:1.0.0" + val scalajsLinker = ivy"org.scala-js::scalajs-linker:1.0.0" } - object Scalanative_0_3 { val scalanativeTools = ivy"org.scala-native::tools:0.3.9" val scalanativeUtil = ivy"org.scala-native::util:0.3.9" @@ -47,14 +46,14 @@ object Deps { val graphvizJava = ivy"guru.nidi:graphviz-java:0.8.3" val ipcsocket = ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0" val ipcsocketExcludingJna = ipcsocket.exclude( - "net.java.dev.jna" -> "jna", - "net.java.dev.jna" -> "jna-platform" + "net.java.dev.jna" -> "jna", + "net.java.dev.jna" -> "jna-platform" ) val javaxServlet = ivy"org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" val jettyServer = ivy"org.eclipse.jetty:jetty-server:8.1.16.v20140903" val jettyWebsocket = ivy"org.eclipse.jetty:jetty-websocket:8.1.16.v20140903" val jgraphtCore = ivy"org.jgrapht:jgrapht-core:1.3.0" - val jna = ivy"net.java.dev.jna:jna:4.5.0" + val jna = ivy"net.java.dev.jna:jna:5.0.0" val jnaPlatform = ivy"net.java.dev.jna:jna-platform:4.5.0" val junitInterface = ivy"com.novocode:junit-interface:0.11" val lambdaTest = ivy"de.tototec:de.tobiasroeser.lambdatest:0.7.0" @@ -62,14 +61,14 @@ object Deps { val testng = ivy"org.testng:testng:6.11" val sbtTestInterface = ivy"org.scala-sbt:test-interface:1.0" def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}" - val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:2.0.0-RC6" + val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:2.2.1" def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}" - def scalacScoveragePlugin = ivy"org.scoverage::scalac-scoverage-plugin:1.4.0" + def scalacScoveragePlugin = ivy"org.scoverage::scalac-scoverage-plugin:1.4.1" val sourcecode = ivy"com.lihaoyi::sourcecode:0.2.0" val ujsonCirce = ivy"com.lihaoyi::ujson-circe:0.9.8" val upickle = ivy"com.lihaoyi::upickle:1.0.0" val utest = ivy"com.lihaoyi::utest:0.7.3" - val zinc = ivy"org.scala-sbt::zinc:1.2.5" + val zinc = ivy"org.scala-sbt::zinc:1.4.0-M1" val bsp = ivy"ch.epfl.scala:bsp4j:2.0.0-M4" } @@ -92,7 +91,7 @@ trait MillPublishModule extends PublishModule{ def javacOptions = Seq("-source", "1.8", "-target", "1.8") } trait MillApiModule extends MillPublishModule with ScalaModule{ - def scalaVersion = T{ "2.12.10" } + def scalaVersion = T{ "2.13.1" } def compileIvyDeps = Agg(Deps.acyclic) def scalacOptions = Seq("-P:acyclic:force") def scalacPluginIvyDeps = Agg(Deps.acyclic) @@ -101,6 +100,7 @@ trait MillApiModule extends MillPublishModule with ScalaModule{ ) } trait MillModule extends MillApiModule { outer => + def scalaVersion = T{ "2.13.1" } def scalacPluginClasspath = super.scalacPluginClasspath() ++ Seq(main.moduledefs.jar()) @@ -142,7 +142,7 @@ object main extends MillModule { Seq(PathRef(shared.generateCoreTestSources(T.ctx.dest))) } } - object api extends MillApiModule{ + object api extends MillApiModule { def ivyDeps = Agg( Deps.osLib, Deps.upickle, @@ -158,6 +158,7 @@ object main extends MillModule { def ivyDeps = Agg( Deps.ammonite, + Deps.coursier, // Necessary so we can share the JNA classes throughout the build process Deps.jna, Deps.jnaPlatform, @@ -186,7 +187,7 @@ object main extends MillModule { } object moduledefs extends MillPublishModule with ScalaModule{ - def scalaVersion = T{ "2.12.10" } + def scalaVersion = T{ "2.13.1" } def ivyDeps = Agg( Deps.scalaCompiler(scalaVersion()), Deps.sourcecode, @@ -283,7 +284,7 @@ object scalalib extends MillModule { object api extends MillApiModule { def moduleDeps = Seq(main.api) } - object worker extends MillApiModule{ + object worker extends MillApiModule { def moduleDeps = Seq(scalalib.api) @@ -312,8 +313,8 @@ object scalajslib extends MillModule { (for((k, v) <- mapping.toSeq) yield s"-D$k=$v") } - object api extends MillApiModule{ - def moduleDeps = Seq(main.core) + object api extends MillApiModule { + def moduleDeps = Seq(main.api) def ivyDeps = Agg(Deps.sbtTestInterface) } object worker extends Cross[WorkerModule]("0.6", "1.0") @@ -362,8 +363,8 @@ object contrib extends MillModule { def testArgs = T { val mapping = Map( - "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_2_6" -> worker("2.6").compile().classes.path, - "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_2_7" -> worker("2.7").compile().classes.path + "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_2_6" -> worker("2.6").assembly().path, + "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_2_7" -> worker("2.7").assembly().path ) scalalib.worker.testArgs() ++ @@ -371,21 +372,23 @@ object contrib extends MillModule { (for ((k, v) <- mapping.toSeq) yield s"-D$k=$v") } - object api extends MillApiModule { - def moduleDeps = Seq(scalalib) + object api extends MillPublishModule { + } object worker extends Cross[WorkerModule]( "2.6", "2.7") - class WorkerModule(scalajsBinary: String) extends MillApiModule { + class WorkerModule(scalajsBinary: String) extends MillApiModule { + def scalaVersion = T { "2.12.10" } def moduleDeps = Seq(playlib.api) - def ivyDeps = scalajsBinary match { case "2.6"=> Agg( + Deps.osLib, ivy"com.typesafe.play::routes-compiler::2.6.0" ) case "2.7" => Agg( + Deps.osLib, ivy"com.typesafe.play::routes-compiler::2.7.0" ) } @@ -398,7 +401,6 @@ object contrib extends MillModule { } object scoverage extends MillModule { - object api extends MillApiModule { def moduleDeps = Seq(main.api) } @@ -441,7 +443,10 @@ object contrib extends MillModule { object tut extends MillModule { def moduleDeps = Seq(scalalib) - def testArgs = Seq("-DMILL_VERSION=" + build.publishVersion()._2) + def testArgs = T{ + scalalib.worker.testArgs() ++ + scalalib.backgroundwrapper.testArgs() + } } object flyway extends MillModule { @@ -494,24 +499,25 @@ object scalanativelib extends MillModule { def testArgs = T{ val mapping = Map( - "MILL_SCALANATIVE_WORKER_0_3" -> worker("0.3").compile().classes.path, - "MILL_SCALANATIVE_WORKER_0_4" -> worker("0.4").compile().classes.path + "MILL_SCALANATIVE_WORKER_0_3" -> worker("0.3").assembly().path, + "MILL_SCALANATIVE_WORKER_0_4" -> worker("0.4").assembly().path ) scalalib.worker.testArgs() ++ scalalib.backgroundwrapper.testArgs() ++ (for((k, v) <- mapping.toSeq) yield s"-D$k=$v") } - object api extends MillApiModule{ - def moduleDeps = Seq(main.core) + object api extends MillPublishModule { def ivyDeps = Agg(Deps.sbtTestInterface) } object worker extends Cross[WorkerModule]("0.3", "0.4") class WorkerModule(scalaNativeWorkerVersion: String) extends MillApiModule { + def scalaVersion = T{ "2.12.10" } override def millSourcePath(): os.Path = super.millSourcePath / os.up def moduleDeps = Seq(scalanativelib.api) def ivyDeps = scalaNativeWorkerVersion match { case "0.3" => Agg( + Deps.osLib, Deps.Scalanative_0_3.scalanativeTools, Deps.Scalanative_0_3.scalanativeUtil, Deps.Scalanative_0_3.scalanativeNir, @@ -519,6 +525,7 @@ object scalanativelib extends MillModule { ) case "0.4" => Agg( + Deps.osLib, Deps.Scalanative_0_4.scalanativeTools, Deps.Scalanative_0_4.scalanativeUtil, Deps.Scalanative_0_4.scalanativeNir, diff --git a/ci/shared.sc b/ci/shared.sc index 89e504fe910a..5f9fb7fcc59b 100644 --- a/ci/shared.sc +++ b/ci/shared.sc @@ -4,7 +4,7 @@ * via import $file */ -import $ivy.`org.scalaj::scalaj-http:2.4.1` +import $ivy.`org.scalaj::scalaj-http:2.4.2` import ammonite.ops.{write, Path, mkdir, RelPath, up} def argNames(n: Int) = { diff --git a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala b/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala index dbbfbed8d016..3542532ef28a 100644 --- a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala +++ b/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala @@ -401,7 +401,7 @@ class BloopImpl(ev: () => Evaluator, wd: Path) extends ExternalModule { outer => sbt = None, test = testConfig(), platform = Some(platform()), - resolution = Some(bloopResolution()) + resolution = Some(bloopResolution()), ) } diff --git a/contrib/bsp/src/mill/contrib/bsp/TaskParameters.scala b/contrib/bsp/src/mill/contrib/bsp/TaskParameters.scala index a235c9228f11..b4720722d4b4 100644 --- a/contrib/bsp/src/mill/contrib/bsp/TaskParameters.scala +++ b/contrib/bsp/src/mill/contrib/bsp/TaskParameters.scala @@ -27,7 +27,7 @@ case class CParams(compileParams: CompileParams) extends Parameters { override def getArguments: Option[Seq[String]] = { try { - Option(compileParams.getArguments.asScala) + Option(compileParams.getArguments.asScala.toSeq) } catch { case e: Exception => Option.empty[Seq[String]] } @@ -51,7 +51,7 @@ case class RParams(runParams: RunParams) extends Parameters { override def getArguments: Option[Seq[String]] = { try { - Option(runParams.getArguments.asScala) + Option(runParams.getArguments.asScala.toSeq) } catch { case e: Exception => Option.empty[Seq[String]] } @@ -75,7 +75,7 @@ case class TParams(testParams: TestParams) extends Parameters { override def getArguments: Option[Seq[String]] = { try { - Option(testParams.getArguments.asScala) + Option(testParams.getArguments.asScala.toSeq) } catch { case e: Exception => Option.empty[Seq[String]] } diff --git a/contrib/playlib/api/src/RouteCompilerType.java b/contrib/playlib/api/src/RouteCompilerType.java new file mode 100644 index 000000000000..38942dbe4aed --- /dev/null +++ b/contrib/playlib/api/src/RouteCompilerType.java @@ -0,0 +1,6 @@ +package mill.playlib.api; + +public enum RouteCompilerType{ + InjectedGenerator, + StaticGenerator +} diff --git a/contrib/playlib/api/src/RouteCompilerWorkerApi.java b/contrib/playlib/api/src/RouteCompilerWorkerApi.java new file mode 100644 index 000000000000..d7a6e401006e --- /dev/null +++ b/contrib/playlib/api/src/RouteCompilerWorkerApi.java @@ -0,0 +1,12 @@ +package mill.playlib.api; +public interface RouteCompilerWorkerApi { + String compile(java.io.File[] files, + String[] additionalImports, + boolean forwardsRouter, + boolean reverseRouter, + boolean namespaceReverseRouter, + RouteCompilerType generatorType, + java.io.File dest); + + +} diff --git a/contrib/playlib/api/src/RouteCompilerWorkerApi.scala b/contrib/playlib/api/src/RouteCompilerWorkerApi.scala deleted file mode 100644 index 4523f3aebde4..000000000000 --- a/contrib/playlib/api/src/RouteCompilerWorkerApi.scala +++ /dev/null @@ -1,25 +0,0 @@ -package mill -package playlib -package api - -import mill.api.Result -import mill.scalalib.api.CompilationResult - - -private[playlib] trait RouteCompilerWorkerApi { - def compile(files: Seq[os.Path], - additionalImports: Seq[String], - forwardsRouter: Boolean, - reverseRouter: Boolean, - namespaceReverseRouter: Boolean, - generatorType:RouteCompilerType, - dest: os.Path)(implicit ctx: mill.api.Ctx):Result[CompilationResult] - - -} - -sealed trait RouteCompilerType -object RouteCompilerType{ - case object InjectedGenerator extends RouteCompilerType - case object StaticGenerator extends RouteCompilerType -} diff --git a/contrib/playlib/api/src/Versions.java b/contrib/playlib/api/src/Versions.java new file mode 100644 index 000000000000..b498941f4d92 --- /dev/null +++ b/contrib/playlib/api/src/Versions.java @@ -0,0 +1,5 @@ +package mill.playlib.api; +public class Versions { + public static final String PLAY_2_6 = "2.6"; + public static final String PLAY_2_7 = "2.7"; +} diff --git a/contrib/playlib/api/src/Versions.scala b/contrib/playlib/api/src/Versions.scala deleted file mode 100644 index 8c58f6e06506..000000000000 --- a/contrib/playlib/api/src/Versions.scala +++ /dev/null @@ -1,7 +0,0 @@ -package mill -package playlib -package api -object Versions { - val PLAY_2_6="2.6" - val PLAY_2_7="2.7" -} diff --git a/contrib/playlib/src/mill/playlib/PlayModule.scala b/contrib/playlib/src/mill/playlib/PlayModule.scala index 10b6d40d47d1..78b8fb99f9c2 100644 --- a/contrib/playlib/src/mill/playlib/PlayModule.scala +++ b/contrib/playlib/src/mill/playlib/PlayModule.scala @@ -3,7 +3,7 @@ package playlib import mill.scalalib._ -import api.Versions +import mill.playlib.api.Versions trait PlayApiModule extends Dependencies with Router with Server{ trait PlayTests extends super.Tests{ diff --git a/contrib/playlib/src/mill/playlib/RouteCompilerWorkerApi.scala b/contrib/playlib/src/mill/playlib/RouteCompilerWorkerApi.scala index a9982f12e9ff..07ea50d7e4eb 100644 --- a/contrib/playlib/src/mill/playlib/RouteCompilerWorkerApi.scala +++ b/contrib/playlib/src/mill/playlib/RouteCompilerWorkerApi.scala @@ -20,7 +20,8 @@ private[playlib] class RouteCompilerWorker { ctx.log.debug("Loading classes from\n"+toolsClassPath.mkString("\n")) val cl = mill.api.ClassLoader.create( toolsClassPath, - getClass.getClassLoader + null, + sharedPrefixes = Seq("mill.playlib.api.") ) val bridge = cl .loadClass("mill.playlib.worker.RouteCompilerWorker") @@ -46,18 +47,18 @@ private[playlib] class RouteCompilerWorker { //by the others bridge(routerClasspath) .compile( - files, - additionalImports, + files.toArray.map(_.toIO), + additionalImports.toArray, forwardsRouter, reverseRouter, namespaceReverseRouter, generatorType, - dest - )(ctx) + dest.toIO + ) match{ + case null => Result.Success(CompilationResult(T.dest / 'zinc, PathRef(T.dest))) + case err => Result.Failure(err) + } } - - - } private[playlib] object RouteCompilerWorkerModule extends ExternalModule { diff --git a/contrib/playlib/src/mill/playlib/RouterModule.scala b/contrib/playlib/src/mill/playlib/RouterModule.scala index 3e7a794e9adc..2edec5bfd66e 100644 --- a/contrib/playlib/src/mill/playlib/RouterModule.scala +++ b/contrib/playlib/src/mill/playlib/RouterModule.scala @@ -2,7 +2,7 @@ package mill package playlib import coursier.MavenRepository -import mill.eval.PathRef +import mill.api.PathRef import mill.playlib.api.RouteCompilerType import mill.scalalib.Lib.resolveDependencies import mill.scalalib._ @@ -82,7 +82,8 @@ trait RouterModule extends ScalaModule with Version { workerKey, s"mill-contrib-playlib-worker-${playMinorVersion()}", repositories, - resolveFilter = _.toString.contains("mill-contrib-playlib-worker") + resolveFilter = _.toString.contains("mill-contrib-playlib-worker"), + artifactSuffix = "_2.12" ) } diff --git a/contrib/playlib/worker/2.6/src/RouteCompilerWorker.scala b/contrib/playlib/worker/2.6/src/RouteCompilerWorker.scala index 77c087e75772..3b1694f56c3c 100644 --- a/contrib/playlib/worker/2.6/src/RouteCompilerWorker.scala +++ b/contrib/playlib/worker/2.6/src/RouteCompilerWorker.scala @@ -4,10 +4,7 @@ package worker import java.io.File -import mill.api.{Ctx, Result} -import mill.eval.PathRef import mill.playlib.api.{RouteCompilerType, RouteCompilerWorkerApi} -import mill.scalalib.api.CompilationResult import play.routes.compiler import play.routes.compiler.RoutesCompiler.RoutesCompilerTask import play.routes.compiler._ @@ -15,24 +12,23 @@ import play.routes.compiler._ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { - override def compile(files: Seq[os.Path], - additionalImports: Seq[String], + override def compile(files: Array[java.io.File], + additionalImports: Array[String], forwardsRouter: Boolean, reverseRouter: Boolean, namespaceReverseRouter: Boolean, generatorType: RouteCompilerType, - dest: os.Path) - (implicit ctx: mill.api.Ctx): mill.api.Result[CompilationResult] = { + dest: java.io.File): String = { generatorType match { case RouteCompilerType.InjectedGenerator => - val result = compileWithPlay(files, additionalImports, forwardsRouter, reverseRouter, - namespaceReverseRouter, dest, ctx, InjectedRoutesGenerator) - asMillResult(ctx, result) + val result = compileWithPlay(files.map(os.Path(_)).toSeq, additionalImports.toSeq, forwardsRouter, reverseRouter, + namespaceReverseRouter, os.Path(dest), InjectedRoutesGenerator) + asMillResult(result) case RouteCompilerType.StaticGenerator => - ctx.log.error("Static generator was deprecated in 2.6.0 and will be removed in 2.7.0") - val result = compileWithPlay(files, additionalImports, forwardsRouter, reverseRouter, - namespaceReverseRouter, dest, ctx, StaticRoutesGenerator) - asMillResult(ctx, result) + println("Static generator was deprecated in 2.6.0 and will be removed in 2.7.0") + val result = compileWithPlay(files.map(os.Path(_)).toSeq, additionalImports.toSeq, forwardsRouter, reverseRouter, + namespaceReverseRouter, os.Path(dest), StaticRoutesGenerator) + asMillResult(result) case _ => throw new Exception(s"Unrecognized generator type: $generatorType. Use injected or static") } } @@ -43,11 +39,10 @@ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { reverseRouter: Boolean, namespaceReverseRouter: Boolean, dest: os.Path, - ctx: Ctx, routesGenerator: RoutesGenerator): Either[Seq[compiler.RoutesCompilationError], Seq[File]] = { val seed: Either[Seq[compiler.RoutesCompilationError], List[File]] = Right(List.empty[File]) files.map(file => compileWithPlay(file, additionalImports, forwardsRouter, reverseRouter, - namespaceReverseRouter, dest, ctx, routesGenerator)).foldLeft(seed) { + namespaceReverseRouter, dest, routesGenerator)).foldLeft(seed) { case (Right(accFiles), Right(files)) => Right(accFiles ++ files) case (Right(accFiles), Left(errors)) => Left(errors) case (left@Left(errors), _) => left @@ -60,9 +55,7 @@ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { reverseRouter: Boolean, namespaceReverseRouter: Boolean, dest: os.Path, - ctx: Ctx, routesGenerator: RoutesGenerator): Either[Seq[compiler.RoutesCompilationError], Seq[File]] = { - ctx.log.debug(s"compiling $file with play generator $routesGenerator") val result = RoutesCompiler.compile( RoutesCompilerTask(file.toIO, additionalImports, forwardsRouter, reverseRouter, @@ -70,21 +63,18 @@ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { generator = routesGenerator, generatedDir = dest.toIO ) - ctx.log.debug(s"compilation result: $result") result } - private def asMillResult(ctx: Ctx, result: Either[Seq[RoutesCompilationError], Seq[File]]): Result[CompilationResult] = { + private def asMillResult(result: Either[Seq[RoutesCompilationError], Seq[File]]): String = { result match { - case Right(_) => - val zincFile = ctx.dest / 'zinc - Result.Success(CompilationResult(zincFile, PathRef(ctx.dest))) + case Right(_) => null case Left(errors) => val errorMsg = errors.map(error => s"compilation error in ${error.source.getPath} at line ${error.line.getOrElse("?")}, " + s"column ${error.column.getOrElse("?")}: ${error.message}") .mkString("\n") - Result.Failure("Unable to compile play routes\n" + errorMsg) + "Unable to compile play routes\n" + errorMsg } } } diff --git a/contrib/playlib/worker/2.7/src/RouteCompilerWorker.scala b/contrib/playlib/worker/2.7/src/RouteCompilerWorker.scala index 4cf1415d9d89..568d7e705613 100644 --- a/contrib/playlib/worker/2.7/src/RouteCompilerWorker.scala +++ b/contrib/playlib/worker/2.7/src/RouteCompilerWorker.scala @@ -4,10 +4,7 @@ package worker import java.io.File -import mill.api.{Ctx, Result} -import mill.eval.PathRef import mill.playlib.api.{RouteCompilerType, RouteCompilerWorkerApi} -import mill.scalalib.api.CompilationResult import play.routes.compiler import play.routes.compiler.RoutesCompiler.RoutesCompilerTask import play.routes.compiler.{InjectedRoutesGenerator, RoutesCompilationError, RoutesCompiler, RoutesGenerator} @@ -15,21 +12,20 @@ import play.routes.compiler.{InjectedRoutesGenerator, RoutesCompilationError, Ro private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { - override def compile(files: Seq[os.Path], - additionalImports: Seq[String], + override def compile(files: Array[java.io.File], + additionalImports: Array[String], forwardsRouter: Boolean, reverseRouter: Boolean, namespaceReverseRouter: Boolean, generatorType: RouteCompilerType, - dest: os.Path) - (implicit ctx: mill.api.Ctx): mill.api.Result[CompilationResult] = { + dest: java.io.File): String = { generatorType match { case RouteCompilerType.InjectedGenerator => - val result = compileWithPlay(files, additionalImports, forwardsRouter, reverseRouter, - namespaceReverseRouter, dest, ctx, InjectedRoutesGenerator) - asMillResult(ctx, result) + val result = compileWithPlay(files.map(os.Path(_)), additionalImports, forwardsRouter, reverseRouter, + namespaceReverseRouter, os.Path(dest), InjectedRoutesGenerator) + asMillResult(result) case RouteCompilerType.StaticGenerator => - Result.Failure("Static generator was deprecated in 2.6.0 then removed in 2.7.x, see https://www.playframework.com/documentation/2.7.x/Migration27#StaticRoutesGenerator-removed") + "Static generator was deprecated in 2.6.0 then removed in 2.7.x, see https://www.playframework.com/documentation/2.7.x/Migration27#StaticRoutesGenerator-removed" } } @@ -42,19 +38,23 @@ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { reverseRouter: Boolean, namespaceReverseRouter: Boolean, dest: os.Path, - ctx: Ctx, routesGenerator: RoutesGenerator): Either[Seq[compiler.RoutesCompilationError], Seq[File]] = { val seed: Either[Seq[compiler.RoutesCompilationError], List[File]] = Right(List.empty[File]) - files.map(file => compileWithPlay(file, additionalImports, forwardsRouter, reverseRouter, - namespaceReverseRouter, dest, ctx, routesGenerator)).foldLeft(seed) { + files.map(file => compileWithPlay(file, additionalImports.toSeq, forwardsRouter, reverseRouter, + namespaceReverseRouter, dest, routesGenerator)).foldLeft(seed) { case (Right(accFiles), Right(files)) => Right(accFiles ++ files) case (Right(accFiles), Left(errors)) => Left(errors) case (left@Left(errors), _) => left } } - private def compileWithPlay(file: os.Path, additionalImports: Seq[String], forwardsRouter: Boolean, reverseRouter: Boolean, namespaceReverseRouter: Boolean, dest: os.Path, ctx: Ctx, routesGenerator: RoutesGenerator) = { - ctx.log.debug(s"compiling file $file with play generator $routesGenerator") + private def compileWithPlay(file: os.Path, + additionalImports: Seq[String], + forwardsRouter: Boolean, + reverseRouter: Boolean, + namespaceReverseRouter: Boolean, + dest: os.Path, + routesGenerator: RoutesGenerator) = { val result = RoutesCompiler.compile( RoutesCompilerTask(file.toIO, additionalImports, forwardsRouter, reverseRouter, @@ -62,21 +62,18 @@ private[playlib] class RouteCompilerWorker extends RouteCompilerWorkerApi { generator = routesGenerator, generatedDir = dest.toIO ) - ctx.log.debug(s"compilation result: $result") result } - private def asMillResult(ctx: Ctx, result: Either[Seq[RoutesCompilationError], Seq[File]]): Result[CompilationResult] = { + private def asMillResult(result: Either[Seq[RoutesCompilationError], Seq[File]]): String = { result match { - case Right(_) => - val zincFile = ctx.dest / 'zinc - Result.Success(CompilationResult(zincFile, PathRef(ctx.dest))) + case Right(_) => null case Left(errors) => val errorMsg = errors.map(error => s"compilation error in ${error.source.getPath} at line ${error.line.getOrElse("?")}, " + s"column ${error.column.getOrElse("?")}: ${error.message}") .mkString("\n") - Result.Failure("Unable to compile play routes, " + errorMsg) + "Unable to compile play routes, " + errorMsg } } } diff --git a/contrib/scoverage/src/ScoverageModule.scala b/contrib/scoverage/src/ScoverageModule.scala index f93377a317b5..96b52c83f4b7 100644 --- a/contrib/scoverage/src/ScoverageModule.scala +++ b/contrib/scoverage/src/ScoverageModule.scala @@ -70,7 +70,7 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule => def scoverageClasspath = T { Lib.resolveDependencies( Seq(coursier.LocalRepositories.ivy2Local, MavenRepository("https://repo1.maven.org/maven2")), - Lib.depToDependency(_, outer.scalaVersion()), + Lib.depToDependency(_, "2.13.1"), Seq(scoveragePluginDep()), ctx = Some(implicitly[mill.util.Ctx.Log]) ) diff --git a/contrib/scoverage/worker/src/ScoverageReportWorkerImpl.scala b/contrib/scoverage/worker/src/ScoverageReportWorkerImpl.scala index d56c59ade2b8..43dba546dce9 100644 --- a/contrib/scoverage/worker/src/ScoverageReportWorkerImpl.scala +++ b/contrib/scoverage/worker/src/ScoverageReportWorkerImpl.scala @@ -10,7 +10,7 @@ import mill.contrib.scoverage.api.ScoverageReportWorkerApi.ReportType class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi { - override def report(reportType: ReportType, sources: Seq[os.Path], dataDir: os.Path)(implicit ctx: Ctx): Unit = { + override def report(reportType: ReportType, sources: Seq[os.Path], dataDir: os.Path)(implicit ctx: Ctx): Unit = try{ val coverageFileObj = coverageFile(dataDir.toIO) val coverage = deserialize(coverageFileObj) coverage(invoked(findMeasurementFiles(dataDir.toIO))) @@ -28,5 +28,9 @@ class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi { ctx.log.info(s"Statement coverage.: ${coverage.statementCoverageFormatted}%") ctx.log.info(s"Branch coverage....: ${coverage.branchCoverageFormatted}%") } + }catch{case e => + + e.printStackTrace() + throw e } } diff --git a/integration/test/resources/ammonite/build.sc b/integration/test/resources/ammonite/build.sc index 86f354b4c95a..b93fbf562f2d 100644 --- a/integration/test/resources/ammonite/build.sc +++ b/integration/test/resources/ammonite/build.sc @@ -106,7 +106,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ def ivyDeps = Agg( ivy"io.get-coursier::coursier:1.1.0-M7", ivy"io.get-coursier::coursier-cache:1.1.0-M7", - ivy"org.scalaj::scalaj-http:2.4.0" + ivy"org.scalaj::scalaj-http:2.4.2" ) def generatedSources = T{ diff --git a/integration/test/resources/play-json/build.sc b/integration/test/resources/play-json/build.sc index 3aa71ece847a..33ee292d600c 100644 --- a/integration/test/resources/play-json/build.sc +++ b/integration/test/resources/play-json/build.sc @@ -2,22 +2,22 @@ import mill._, mill.scalalib._, mill.scalalib.publish._, mill.scalajslib._ import $file.playJsonVersion import $file.reformat import reformat.Scalariform -import $file.mima -import mima.MiMa +//import $file.mima +//import mima.MiMa import $file.headers import $file.jmh import jmh.Jmh -import headers.Headers -import com.typesafe.tools.mima.core._ +//import headers.Headers +//import com.typesafe.tools.mima.core._ import mill.define.Task val ScalaVersions = Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3") -trait BaseModule extends CrossSbtModule with Scalariform with Headers +trait BaseModule extends CrossSbtModule with Scalariform /*with Headers*/ -trait PlayJsonModule extends BaseModule with PublishModule with MiMa { +trait PlayJsonModule extends BaseModule with PublishModule /*with MiMa */{ def pomSettings = PomSettings( description = artifactName(), @@ -34,7 +34,7 @@ trait PlayJsonModule extends BaseModule with PublishModule with MiMa { ) ) - trait Tests extends super.Tests with Scalariform with Headers { + trait Tests extends super.Tests with Scalariform /*with Headers */{ val specs2Core = T { val v = mill.scalalib.api.Util.scalaBinaryVersion(scalaVersion()) match { case "2.10" => "3.9.1" @@ -74,20 +74,20 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule { def scalacPluginIvyDeps = Agg(macroParadise) - def mimaBinaryIssueFilters = Seq( - // AbstractFunction1 is in scala.runtime and isn't meant to be used by end users - ProblemFilters.exclude[MissingTypesProblem]("play.api.libs.json.JsArray$"), - ProblemFilters.exclude[MissingTypesProblem]("play.api.libs.json.JsObject$"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntWrites"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntegerWrites"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntReads"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntegerReads"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntWrites"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntegerWrites"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntReads"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntegerReads"), - ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.JsonConfiguration.optionHandlers") - ) +// def mimaBinaryIssueFilters = Seq( +// // AbstractFunction1 is in scala.runtime and isn't meant to be used by end users +// ProblemFilters.exclude[MissingTypesProblem]("play.api.libs.json.JsArray$"), +// ProblemFilters.exclude[MissingTypesProblem]("play.api.libs.json.JsObject$"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntWrites"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntegerWrites"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntReads"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntegerReads"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntWrites"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultWrites.BigIntegerWrites"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntReads"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.DefaultReads.BigIntegerReads"), +// ProblemFilters.exclude[ReversedMissingMethodProblem]("play.api.libs.json.JsonConfiguration.optionHandlers") +// ) def generatedSources = T { @@ -194,10 +194,10 @@ object playJsonJs extends Cross[PlayJsonJs](ScalaVersions:_*) class PlayJsonJs(val crossScalaVersion: String) extends PlayJson("js") with ScalaJSModule { def moduleDeps = Seq(playFunctionalJs(crossScalaVersion)) - def scalaJSVersion = "0.6.22" + def scalaJSVersion = "0.6.32" // TODO: remove super[PlayJson].Tests with super[ScalaJSModule].Tests hack - object test extends super[PlayJson].Tests with super[ScalaJSModule].Tests with Scalariform with Headers { + object test extends super[PlayJson].Tests with super[ScalaJSModule].Tests with Scalariform/* with Headers*/ { def ivyDeps = Agg( ivy"org.scalatest::scalatest::3.0.5-M1", @@ -226,7 +226,7 @@ class PlayFunctionalJvm(val crossScalaVersion: String) extends PlayFunctional object playFunctionalJs extends Cross[PlayFunctionalJs](ScalaVersions:_*) class PlayFunctionalJs(val crossScalaVersion: String) extends PlayFunctional with ScalaJSModule { - def scalaJSVersion = "0.6.22" + def scalaJSVersion = "0.6.32" } object playJoda extends Cross[PlayJoda](ScalaVersions:_*) @@ -272,45 +272,45 @@ val sourceModules = Seq( val allModules = testModules ++ sourceModules -def reportBinaryIssues() = T.command { - Task.traverse(sourceModules) { module => - module.mimaReportBinaryIssues.map(issues => module.millModuleSegments.render -> issues) - }.map { issues => - val issuesByModules = issues.flatMap { case (moduleName, issues) => - val messageForModule = issues.foldLeft(Seq.empty[String]) { case (acc, (artifact, problems)) => - val elem = if(problems.nonEmpty) { - Some( - s"""Compared to artifact: ${artifact} - |found ${problems.size} binary incompatibilities: - |${problems.mkString("\n")} - """.stripMargin - ) - } else { - None - } - acc ++ elem - } - if(messageForModule.nonEmpty) { - Some( - s""" - |For module: ${moduleName}: - |${messageForModule.mkString("\n")} - """.stripMargin - ) - } else { - None - } - } - - if(issuesByModules.nonEmpty) { - sys.error(issuesByModules.mkString("\n")) - } - } -} - -def validateCode() = T.command { - Task.traverse(allModules)(_.checkCodeFormat()).zip(Task.traverse(allModules)(_.headerCheck())) -} +//def reportBinaryIssues() = T.command { +// Task.traverse(sourceModules) { module => +// module.mimaReportBinaryIssues.map(issues => module.millModuleSegments.render -> issues) +// }.map { issues => +// val issuesByModules = issues.flatMap { case (moduleName, issues) => +// val messageForModule = issues.foldLeft(Seq.empty[String]) { case (acc, (artifact, problems)) => +// val elem = if(problems.nonEmpty) { +// Some( +// s"""Compared to artifact: ${artifact} +// |found ${problems.size} binary incompatibilities: +// |${problems.mkString("\n")} +// """.stripMargin +// ) +// } else { +// None +// } +// acc ++ elem +// } +// if(messageForModule.nonEmpty) { +// Some( +// s""" +// |For module: ${moduleName}: +// |${messageForModule.mkString("\n")} +// """.stripMargin +// ) +// } else { +// None +// } +// } +// +// if(issuesByModules.nonEmpty) { +// sys.error(issuesByModules.mkString("\n")) +// } +// } +//} + +//def validateCode() = T.command { +// Task.traverse(allModules)(_.checkCodeFormat()).zip(Task.traverse(allModules)(_.headerCheck())) +//} /** * Release steps are: diff --git a/integration/test/resources/play-json/headers.sc b/integration/test/resources/play-json/headers.sc index 31613fe6cff4..5c361d19aab3 100644 --- a/integration/test/resources/play-json/headers.sc +++ b/integration/test/resources/play-json/headers.sc @@ -1,63 +1,63 @@ -import $ivy.`com.github.rockjam::license-headers:0.0.1` - - -import mill._, scalalib._ -import mill.api.PathRef -import de.heikoseeberger.sbtheader.{CommentStyle, FileType, HeaderCreator, License} - -trait Headers extends ScalaModule { - - val headerMappings = Map( - FileType.scala.extension -> (FileType.scala, CommentStyle.cStyleBlockComment), - FileType.java.extension -> (FileType.java, CommentStyle.cStyleBlockComment) - ) - - val license = { - val currentYear = java.time.Year.now(java.time.Clock.systemUTC).getValue - License.Custom( - s"Copyright (C) 2009-$currentYear Lightbend Inc. " - ) - } - - def headerCreate() = T.command { - val withoutHeaders = filesWithoutHeaders(sources() ++ resources()) - - val updatedFiles = withoutHeaders.map { - case (file, updated) => - os.write.over(file, updated) - file - } - - if (updatedFiles.nonEmpty) { - T.ctx.log.info( - s"Headers created for ${updatedFiles.size} files:\n${updatedFiles.mkString("\n")}") - } - updatedFiles - } - - def headerCheck() = T.command { - val withoutHeaders = filesWithoutHeaders(sources() ++ resources()).map(_._1) - - if (withoutHeaders.nonEmpty) { - sys.error( - s"There are files without headers!\n${withoutHeaders.mkString("\n")}" - ) - } - } - - private def filesWithoutHeaders(input: Seq[PathRef]) = { - for { - ref <- input if os.exists(ref.path) - file <- os.walk(ref.path) if os.isFile(file) - (fileType, commentStyle) <- headerMappings.get(file.ext) - updatedContent <- HeaderCreator( - fileType, - commentStyle, - license, - log = _ => (), - os.read.inputStream(file) - ).createText - } yield file -> updatedContent - } - -} +//import $ivy.`com.github.rockjam::license-headers:0.0.1` +// +// +//import mill._, scalalib._ +//import mill.api.PathRef +//import de.heikoseeberger.sbtheader.{CommentStyle, FileType, HeaderCreator, License} +// +//trait Headers extends ScalaModule { +// +// val headerMappings = Map( +// FileType.scala.extension -> (FileType.scala, CommentStyle.cStyleBlockComment), +// FileType.java.extension -> (FileType.java, CommentStyle.cStyleBlockComment) +// ) +// +// val license = { +// val currentYear = java.time.Year.now(java.time.Clock.systemUTC).getValue +// License.Custom( +// s"Copyright (C) 2009-$currentYear Lightbend Inc. " +// ) +// } +// +// def headerCreate() = T.command { +// val withoutHeaders = filesWithoutHeaders(sources() ++ resources()) +// +// val updatedFiles = withoutHeaders.map { +// case (file, updated) => +// os.write.over(file, updated) +// file +// } +// +// if (updatedFiles.nonEmpty) { +// T.ctx.log.info( +// s"Headers created for ${updatedFiles.size} files:\n${updatedFiles.mkString("\n")}") +// } +// updatedFiles +// } +// +// def headerCheck() = T.command { +// val withoutHeaders = filesWithoutHeaders(sources() ++ resources()).map(_._1) +// +// if (withoutHeaders.nonEmpty) { +// sys.error( +// s"There are files without headers!\n${withoutHeaders.mkString("\n")}" +// ) +// } +// } +// +// private def filesWithoutHeaders(input: Seq[PathRef]) = { +// for { +// ref <- input if os.exists(ref.path) +// file <- os.walk(ref.path) if os.isFile(file) +// (fileType, commentStyle) <- headerMappings.get(file.ext) +// updatedContent <- HeaderCreator( +// fileType, +// commentStyle, +// license, +// log = _ => (), +// os.read.inputStream(file) +// ).createText +// } yield file -> updatedContent +// } +// +//} diff --git a/integration/test/resources/play-json/mima.sc b/integration/test/resources/play-json/mima.sc index baca333ca463..3aaa6563db2e 100644 --- a/integration/test/resources/play-json/mima.sc +++ b/integration/test/resources/play-json/mima.sc @@ -1,53 +1,53 @@ -import $ivy.`com.typesafe::mima-reporter:0.1.18` -import com.typesafe.tools.mima.lib.MiMaLib -import com.typesafe.tools.mima.core._ -import mill._, scalalib._ - -trait MiMa extends ScalaModule with PublishModule { - def previousVersions = T { - scalaVersion().split('.')(1) match { - case "10" => Seq("2.6.0") - case "11" => Seq("2.6.0") - case "12" => Seq("2.6.0") - case _ => Nil - } - } - - def mimaBinaryIssueFilters: Seq[ProblemFilter] = Seq.empty - - def previousDeps = T { - Agg.from(previousVersions().map { version => - ivy"${pomSettings().organization}:${artifactId()}:${version}" - }) - } - - def previousArtifacts = T { - resolveDeps(previousDeps)().filter(_.path.segments.contains(artifactId())) - } - - def mimaReportBinaryIssues: T[List[(String, List[String])]] = T { - val currentClassfiles = compile().classes.path - val classpath = runClasspath() - - val lib = { - com.typesafe.tools.mima.core.Config.setup("sbt-mima-plugin", Array.empty) - val cpstring = classpath - .map(_.path) - .filter(os.exists) - .mkString(System.getProperty("path.separator")) - new MiMaLib( - com.typesafe.tools.mima.core.reporterClassPath(cpstring) - ) - } - - previousArtifacts().toList.map { path => - val problems = - lib.collectProblems(path.path.toString, currentClassfiles.toString) - path.path.toString -> problems.filter { problem => - mimaBinaryIssueFilters.forall(_.apply(problem)) - }.map(_.description("current")) - } - } - -} +//import $ivy.`com.typesafe::mima-reporter:0.1.18` +//import com.typesafe.tools.mima.lib.MiMaLib +//import com.typesafe.tools.mima.core._ +//import mill._, scalalib._ +// +//trait MiMa extends ScalaModule with PublishModule { +// def previousVersions = T { +// scalaVersion().split('.')(1) match { +// case "10" => Seq("2.6.0") +// case "11" => Seq("2.6.0") +// case "12" => Seq("2.6.0") +// case _ => Nil +// } +// } +// +// def mimaBinaryIssueFilters: Seq[ProblemFilter] = Seq.empty +// +// def previousDeps = T { +// Agg.from(previousVersions().map { version => +// ivy"${pomSettings().organization}:${artifactId()}:${version}" +// }) +// } +// +// def previousArtifacts = T { +// resolveDeps(previousDeps)().filter(_.path.segments.contains(artifactId())) +// } +// +// def mimaReportBinaryIssues: T[List[(String, List[String])]] = T { +// val currentClassfiles = compile().classes.path +// val classpath = runClasspath() +// +// val lib = { +// com.typesafe.tools.mima.core.Config.setup("sbt-mima-plugin", Array.empty) +// val cpstring = classpath +// .map(_.path) +// .filter(os.exists) +// .mkString(System.getProperty("path.separator")) +// new MiMaLib( +// com.typesafe.tools.mima.core.reporterClassPath(cpstring) +// ) +// } +// +// previousArtifacts().toList.map { path => +// val problems = +// lib.collectProblems(path.path.toString, currentClassfiles.toString) +// path.path.toString -> problems.filter { problem => +// mimaBinaryIssueFilters.forall(_.apply(problem)) +// }.map(_.description("current")) +// } +// } +// +//} diff --git a/integration/test/resources/play-json/reformat.sc b/integration/test/resources/play-json/reformat.sc index 3127bc5d92b4..8a98e5d03689 100644 --- a/integration/test/resources/play-json/reformat.sc +++ b/integration/test/resources/play-json/reformat.sc @@ -1,4 +1,4 @@ -import $ivy.`org.scalariform::scalariform:0.2.5` +import $ivy.`org.scalariform::scalariform:0.2.10` import mill._, scalalib._ diff --git a/integration/test/resources/upickle/build.sc b/integration/test/resources/upickle/build.sc index 8ec442fc12b3..c8c1815e18ff 100644 --- a/integration/test/resources/upickle/build.sc +++ b/integration/test/resources/upickle/build.sc @@ -122,7 +122,7 @@ object upickleJs extends Cross[UpickleJsModule]("2.11.11", "2.12.4") class UpickleJsModule(val crossScalaVersion: String) extends UpickleModule with ScalaJSModule { def platformSegment = "js" - def scalaJSVersion = "0.6.22" + def scalaJSVersion = "0.6.32" def scalacOptions = T{ super.scalacOptions() ++ Seq({ val a = build.millSourcePath.toString.replaceFirst("[^/]+/?$", "") diff --git a/main/api/src/mill/api/AggWrapper.scala b/main/api/src/mill/api/AggWrapper.scala index 98d46d68b625..7d85b8aca525 100644 --- a/main/api/src/mill/api/AggWrapper.scala +++ b/main/api/src/mill/api/AggWrapper.scala @@ -108,6 +108,7 @@ sealed class AggWrapper(strictUniqueness: Boolean){ def isEmpty: Boolean = items.isEmpty def seq: scala.collection.TraversableOnce[V] = items def toTraversable: Traversable[V] = items.toTraversable + def iterator: Iterator[V] = items override def hashCode() = items.map(_.hashCode()).sum override def equals(other: Any) = other match{ diff --git a/main/api/src/mill/api/ClassLoader.scala b/main/api/src/mill/api/ClassLoader.scala index dc52f7d25192..7d882eb50a6f 100644 --- a/main/api/src/mill/api/ClassLoader.scala +++ b/main/api/src/mill/api/ClassLoader.scala @@ -1,6 +1,7 @@ package mill.api import java.net.{URL, URLClassLoader} + import java.nio.file.FileAlreadyExistsException import io.github.retronym.java9rtexport.Export @@ -8,22 +9,18 @@ import scala.util.Try object ClassLoader { def java9OrAbove = !System.getProperty("java.specification.version").startsWith("1.") - def create(urls: Seq[URL], - parent: java.lang.ClassLoader) - (implicit ctx: Ctx.Home): URLClassLoader = { - create(urls, parent, _ => None) - } def create(urls: Seq[URL], parent: java.lang.ClassLoader, - customFindClass: String => Option[Class[_]]) + sharedPrefixes: Seq[String] = Seq()) (implicit ctx: Ctx.Home): URLClassLoader = { new URLClassLoader( makeUrls(urls).toArray, refinePlatformParent(parent) ) { + val allSharedPrefixes = sharedPrefixes :+ "com.sun.jna" override def findClass(name: String): Class[_] = { - if (name.startsWith("com.sun.jna")) getClass.getClassLoader.loadClass(name) - else customFindClass(name).getOrElse(super.findClass(name)) + if (allSharedPrefixes.exists(name.startsWith)) getClass.getClassLoader.loadClass(name) + else super.findClass(name) } } } @@ -58,7 +55,7 @@ object ClassLoader { if(!os.exists(java90rtJar)) { Try { os.copy(os.Path(Export.rt()), java90rtJar, createFolders = true) - } recoverWith { case e: FileAlreadyExistsException => + }.recoverWith { case e: FileAlreadyExistsException => // some race? if(os.exists(java90rtJar) && PathRef(java90rtJar) == PathRef(os.Path(Export.rt()))) Try { // all good @@ -67,7 +64,7 @@ object ClassLoader { // retry os.copy(os.Path(Export.rt()), java90rtJar, replaceExisting = true, createFolders = true) } - } get + }.get } urls :+ java90rtJar.toIO.toURI().toURL() } else { diff --git a/main/core/src/eval/Evaluator.scala b/main/core/src/eval/Evaluator.scala index 23ff236f923f..b59f4f88175a 100644 --- a/main/core/src/eval/Evaluator.scala +++ b/main/core/src/eval/Evaluator.scala @@ -127,13 +127,13 @@ case class Evaluator( vs.items.flatMap(results.get).collect{case f: Result.Failing[_] => f.map(_._1)} ) } - Evaluator.writeTimings(timings, outPath) + Evaluator.writeTimings(timings.toSeq, outPath) Evaluator.Results( goals.indexed.map(results(_).map(_._1)), evaluated, transitive, failing, - timings, + timings.toIndexedSeq, results.map{case (k, v) => (k, v.map(_._1))} ) } @@ -173,7 +173,7 @@ case class Evaluator( testReporter, logger ) - Evaluated(newResults, newEvaluated, false) + Evaluated(newResults, newEvaluated.toSeq, false) case lntRight @ Right(labelledNamedTask) => val out = if (!labelledNamedTask.task.ctx.external) outPath @@ -239,7 +239,7 @@ case class Evaluator( os.remove.all(paths.meta) } - Evaluated(newResults, newEvaluated, false) + Evaluated(newResults, newEvaluated.toSeq, false) } } } @@ -458,7 +458,7 @@ case class Evaluator( private[ParallelEvaluator] val nextCounterMsg = new Evaluator.NextCounterMsg(sortedGroups.keyCount) // The unprocessed terminal groups, MUTABLE - private[ParallelEvaluator] val pending: mutable.LinkedHashSet[TerminalGroup] = sortedGroups.items.to[mutable.LinkedHashSet] + private[ParallelEvaluator] val pending: mutable.LinkedHashSet[TerminalGroup] = sortedGroups.items.to(mutable.LinkedHashSet) // The persistent segments for each terminal group, if any // Used to determine potential collisions @@ -608,7 +608,7 @@ case class Evaluator( vs.items.flatMap(i => Option(state.results.get(i))).collect { case f: Result.Failing[_] => f.map(_._1) } ) } - Evaluator.writeTimings(state.timings, outPath) + Evaluator.writeTimings(state.timings.toSeq, outPath) evalLog.debug(s"End time: ${new java.util.Date()}") @@ -620,7 +620,7 @@ case class Evaluator( state.evaluated, transitive, failing, - state.timings, + state.timings.toIndexedSeq, state.results.asScala.map { case (k, v) => (k, v.map(_._1)) } ) } @@ -712,7 +712,7 @@ case class Evaluator( val scheduleStart = System.currentTimeMillis() - val oldSeen: Set[Segments] = state.inProgress.flatMap(state.taskSegments.get).to[Set] + val oldSeen: Set[Segments] = state.inProgress.flatMap(state.taskSegments.get).to(Set) val newSeen: mutable.Set[Segments] = mutable.Set() var taken: Int = 0 diff --git a/main/core/src/eval/Tarjans.scala b/main/core/src/eval/Tarjans.scala index ade335a9679f..78a8f475c8e6 100644 --- a/main/core/src/eval/Tarjans.scala +++ b/main/core/src/eval/Tarjans.scala @@ -43,9 +43,9 @@ object Tarjans { lowlink(x) = Integer.MAX_VALUE if (x == u) done = true } - components.append(component) + components.append(component.toSeq) } } - components + components.toSeq } } diff --git a/main/core/src/util/JsonFormatters.scala b/main/core/src/util/JsonFormatters.scala index b148c8241f22..7ec98aa77db0 100644 --- a/main/core/src/util/JsonFormatters.scala +++ b/main/core/src/util/JsonFormatters.scala @@ -2,6 +2,8 @@ package mill.util import upickle.default.{ReadWriter => RW} +import scala.reflect.ClassTag + trait JsonFormatters extends mill.api.JsonFormatters{ implicit lazy val publicationFormat: RW[coursier.core.Publication] = upickle.default.macroRW implicit lazy val extensionFormat: RW[coursier.core.Extension] = upickle.default.macroRW @@ -14,5 +16,15 @@ trait JsonFormatters extends mill.api.JsonFormatters{ implicit lazy val configurationFormat: RW[coursier.core.Configuration] = upickle.default.macroRW implicit lazy val typeFormat: RW[coursier.core.Type] = upickle.default.macroRW implicit lazy val classifierFormat: RW[coursier.core.Classifier] = upickle.default.macroRW + + implicit def enumFormat[T <: java.lang.Enum[_]: ClassTag]: RW[T] = upickle.default.readwriter[String].bimap( + _.name(), + (s: String) => + implicitly[ClassTag[T]] + .runtimeClass + .getConstructor(classOf[String]) + .newInstance(s) + .asInstanceOf[T] + ) } object JsonFormatters extends JsonFormatters diff --git a/main/core/src/util/Router.scala b/main/core/src/util/Router.scala index 9785a6874d54..4987ce94ff7d 100644 --- a/main/core/src/util/Router.scala +++ b/main/core/src/util/Router.scala @@ -127,7 +127,7 @@ object Router{ } else { missing0.filter(x => incomplete != Some(x)) } - val duplicates = accumulatedKeywords.toSeq.filter(_._2.length > 1) + val duplicates = accumulatedKeywords.view.mapValues(_.toSeq).toSeq.filter(_._2.length > 1) if ( incomplete.nonEmpty || @@ -137,18 +137,18 @@ object Router{ ){ Result.Error.MismatchedArguments( missing = missing, - unknown = leftoverArgs, + unknown = leftoverArgs.toSeq, duplicate = duplicates, incomplete = incomplete ) } else { - val mapping = accumulatedKeywords + val mapping: Map[String, String] = accumulatedKeywords .iterator - .collect{case (k, Seq(single)) => (k.name, single)} + .collect{case (k, mutable.Seq(single)) => (k.name, single)} .toMap - try invoke0(target, mapping, leftoverArgs, argSignatures) + try invoke0(target, mapping, leftoverArgs.toSeq, argSignatures) catch{case e: Throwable => Result.Error.Exception(e) } diff --git a/main/src/main/RunScript.scala b/main/src/main/RunScript.scala index ea39b73c1b42..1f75115ac4e4 100644 --- a/main/src/main/RunScript.scala +++ b/main/src/main/RunScript.scala @@ -52,7 +52,7 @@ object RunScript{ rootModule, rootModule.getClass.getClassLoader.asInstanceOf[SpecialClassLoader].classpathSignature, mutable.Map.empty[Segments, (Int, Any)], - interp.watchedFiles + interp.watchedFiles.toSeq ) (eval, interp.watchedFiles) } @@ -69,7 +69,7 @@ object RunScript{ } yield { (evaluator, evalWatches, res.map(_.flatMap(_._2))) } - (evaluated, interpWatched) + (evaluated, interpWatched.toSeq) } def watchedSigUnchanged(sig: Seq[(os.Path, Long)]) = { diff --git a/main/src/modules/Jvm.scala b/main/src/modules/Jvm.scala index 7f38401e97a1..12834224a51b 100644 --- a/main/src/modules/Jvm.scala +++ b/main/src/modules/Jvm.scala @@ -183,11 +183,7 @@ object Jvm { val urls = classPath.map(_.toIO.toURI.toURL) val cl = if (classLoaderOverrideSbtTesting) { val outerClassLoader = getClass.getClassLoader - mill.api.ClassLoader.create(urls.toVector, null, customFindClass = { name => - if (name.startsWith("sbt.testing.")) - Some(outerClassLoader.loadClass(name)) - else None - }) + mill.api.ClassLoader.create(urls.toVector, null, Seq("sbt.testing.")) } else if (isolated) { mill.api.ClassLoader.create(urls.toVector, null) } else { diff --git a/main/src/modules/Util.scala b/main/src/modules/Util.scala index 4bf8a9682434..dbfd182caa0e 100644 --- a/main/src/modules/Util.scala +++ b/main/src/modules/Util.scala @@ -63,7 +63,7 @@ object Util { artifact: String, repositories: Seq[Repository], resolveFilter: os.Path => Boolean = _ => true, - artifactSuffix: String = "_2.12") = { + artifactSuffix: String = "_2.13") = { val localPath = millProperty(key) if (localPath != null) { mill.api.Result.Success( diff --git a/main/test/src/util/TestUtil.scala b/main/test/src/util/TestUtil.scala index 462b7f5c1e37..a9c7b75419ef 100644 --- a/main/test/src/util/TestUtil.scala +++ b/main/test/src/util/TestUtil.scala @@ -48,7 +48,7 @@ object TestUtil { var counter = 0 var failure = Option.empty[String] var exception = Option.empty[Throwable] - override def evaluate(args: Ctx) = { + override def evaluate(args: mill.api.Ctx) = { failure.map(Result.Failure(_)) orElse exception.map(Result.Exception(_, new OuterStack(Nil))) getOrElse Result.Success(counter + args.args.map(_.asInstanceOf[Int]).sum) diff --git a/scalajslib/src/ScalaJSModule.scala b/scalajslib/src/ScalaJSModule.scala index 429d738aa593..9a43dde30d64 100644 --- a/scalajslib/src/ScalaJSModule.scala +++ b/scalajslib/src/ScalaJSModule.scala @@ -66,7 +66,7 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => } resolveDependencies( repositories, - Lib.depToDependency(_, "2.12.4", ""), + Lib.depToDependency(_, "2.13.1", ""), commonDeps ++ envDep, ctx = Some(implicitly[mill.util.Ctx.Log]) ) diff --git a/scalajslib/test/src/HelloJSWorldTests.scala b/scalajslib/test/src/HelloJSWorldTests.scala index 3eca11b529cf..8f935dd65f1d 100644 --- a/scalajslib/test/src/HelloJSWorldTests.scala +++ b/scalajslib/test/src/HelloJSWorldTests.scala @@ -24,8 +24,8 @@ object HelloJSWorldTests extends TestSuite { object HelloJSWorld extends TestUtil.BaseModule { val matrix = for { - scala <- Seq("2.11.12", "2.12.3", "2.12.4") - scalaJS <- Seq("0.6.22", "0.6.31", "1.0.0-RC1", "1.0.0") + scala <- Seq("2.11.12", "2.12.3", "2.12.4", "2.13.1") + scalaJS <- Seq("0.6.32", "1.0.0") } yield (scala, scalaJS) object helloJsWorld extends Cross[BuildModule](matrix:_*) @@ -50,7 +50,7 @@ object HelloJSWorldTests extends TestSuite { override def sources = T.sources{ millSourcePath / 'src / 'utest } def testFrameworks = Seq("utest.runner.Framework") override def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.6.3" + ivy"com.lihaoyi::utest::0.7.4" ) } } @@ -62,7 +62,7 @@ object HelloJSWorldTests extends TestSuite { override def sources = T.sources{ millSourcePath / 'src / 'scalatest } def testFrameworks = Seq("org.scalatest.tools.Framework") override def ivyDeps = Agg( - ivy"org.scalatest::scalatest::3.1.0" + ivy"org.scalatest::scalatest::3.1.1" ) } } @@ -98,11 +98,11 @@ object HelloJSWorldTests extends TestSuite { assert(unchangedEvalCount == 0) } - 'fromScratch_2124_0622 - testCompileFromScratch("2.12.4", "0.6.22") - 'fromScratch_2123_0622 - testCompileFromScratch("2.12.3", "0.6.22") - 'fromScratch_21112_0622 - TestUtil.disableInJava9OrAbove(testCompileFromScratch("2.11.12", "0.6.22")) - 'fromScratch_2124_100RC1 - testCompileFromScratch("2.12.4", "1.0.0-RC1") + 'fromScratch_2124_0632 - testCompileFromScratch("2.12.4", "0.6.32") + 'fromScratch_2123_0632 - testCompileFromScratch("2.12.3", "0.6.32") + 'fromScratch_21112_0632 - TestUtil.disableInJava9OrAbove(testCompileFromScratch("2.11.12", "0.6.32")) 'fromScratch_2124_100 - testCompileFromScratch("2.12.4", "1.0.0") + 'fromScratch_2131_100 - testCompileFromScratch("2.13.1", "1.0.0") } def testRun(scalaVersion: String, @@ -118,22 +118,20 @@ object HelloJSWorldTests extends TestSuite { } 'fullOpt - { - 'run_2124_0622 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "0.6.22", FullOpt)) - 'run_2123_0622 - TestUtil.disableInJava9OrAbove(testRun("2.12.3", "0.6.22", FullOpt)) - 'run_21112_0622 - TestUtil.disableInJava9OrAbove(testRun("2.11.12", "0.6.22", FullOpt)) - 'run_2124_100RC1 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "1.0.0-RC1", FullOpt)) + 'run_2124_0632 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "0.6.32", FullOpt)) + 'run_2123_0632 - TestUtil.disableInJava9OrAbove(testRun("2.12.3", "0.6.32", FullOpt)) + 'run_21112_0632 - TestUtil.disableInJava9OrAbove(testRun("2.11.12", "0.6.32", FullOpt)) 'run_2124_100 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "1.0.0", FullOpt)) } 'fastOpt - { - 'run_2124_0622 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "0.6.22", FastOpt)) - 'run_2123_0622 - TestUtil.disableInJava9OrAbove(testRun("2.12.3", "0.6.22", FastOpt)) - 'run_21112_0622 - TestUtil.disableInJava9OrAbove(testRun("2.11.12", "0.6.22", FastOpt)) - 'run_2124_100RC1 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "1.0.0-RC1", FastOpt)) + 'run_2124_0632 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "0.6.32", FastOpt)) + 'run_2123_0632 - TestUtil.disableInJava9OrAbove(testRun("2.12.3", "0.6.32", FastOpt)) + 'run_21112_0632 - TestUtil.disableInJava9OrAbove(testRun("2.11.12", "0.6.32", FastOpt)) 'run_2124_100 - TestUtil.disableInJava9OrAbove(testRun("2.12.4", "1.0.0", FastOpt)) } 'jar - { 'containsSJSIRs - { - val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld("2.12.4", "0.6.22").jar) + val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld("2.12.4", "0.6.32").jar) val jar = result.path val entries = new JarFile(jar.toIO).entries().asScala.map(_.getName) assert(entries.contains("Main$.sjsir")) @@ -146,8 +144,7 @@ object HelloJSWorldTests extends TestSuite { val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).artifactMetadata) assert(result.id == artifactId) } - 'artifactId_0622 - testArtifactId("2.12.4", "0.6.22", "hello-js-world_sjs0.6_2.12") - 'artifactId_100RC1 - testArtifactId("2.12.4", "1.0.0-RC1", "hello-js-world_sjs1.0-RC1_2.12") + 'artifactId_0632 - testArtifactId("2.12.4", "0.6.32", "hello-js-world_sjs0.6_2.12") 'artifactId_100 - testArtifactId("2.12.4", "1.0.0", "hello-js-world_sjs1_2.12") } @@ -158,6 +155,7 @@ object HelloJSWorldTests extends TestSuite { testResults .groupBy(_.fullyQualifiedName) .mapValues(_.map(e => e.selector -> e).toMap) + .toMap } def checkUtest(scalaVersion: String, scalaJSVersion: String, cached: Boolean) = { @@ -202,19 +200,19 @@ object HelloJSWorldTests extends TestSuite { 'test - { val cached = false - 'utest_21112_0622 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "0.6.22", cached)) - 'utest_2124_0622 - checkUtest("2.12.4", "0.6.22", cached) - 'utest_21112_0631 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "0.6.31", cached)) - 'utest_2124_0631 - checkUtest("2.12.4", "0.6.31", cached) + 'utest_2124_0632 - checkUtest("2.12.4", "0.6.32", cached) + 'utest_2131_0632 - checkUtest("2.13.1", "0.6.32", cached) + 'utest_2124_100 - checkUtest("2.12.4", "1.0.0", cached) + 'utest_2131_100 - checkUtest("2.13.1", "1.0.0", cached) // No utest artifact for Scala.js 1.0.0 published yet // 'utest_21112_100 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "1.0.0")) // 'utest_2124_100 - checkUtest("2.12.4", "1.0.0") // No test for ScalaTest with 0.6.22 because ScalaTest 3.1.0 requires Scala.js 0.6.29+ - 'scalaTest_21112_0631 - TestUtil.disableInJava9OrAbove(checkScalaTest("2.11.12", "0.6.31", cached)) - 'scalaTest_2124_0631 - checkScalaTest("2.12.4", "0.6.31", cached) - 'scalaTest_21112_100RC1 - checkScalaTest("2.11.12", "1.0.0-RC1", cached) - 'scalaTest_2124_100RC1 - checkScalaTest("2.12.4", "1.0.0-RC1", cached) + 'scalaTest_21112_0632 - TestUtil.disableInJava9OrAbove(checkScalaTest("2.11.12", "0.6.32", cached)) + 'scalaTest_2124_0632 - checkScalaTest("2.12.4", "0.6.32", cached) + 'scalaTest_21112_100 - checkScalaTest("2.11.12", "1.0.0", cached) + 'scalaTest_2124_100 - checkScalaTest("2.12.4", "1.0.0", cached) // No ScalaTest artifact for Scala.js 1.0.0 published yet // 'scalaTest_21112_100 - checkScalaTest("2.11.12", "1.0.0") // 'scalaTest_2124_100 - checkScalaTest("2.12.4", "1.0.0") @@ -222,19 +220,19 @@ object HelloJSWorldTests extends TestSuite { 'testCached - { val cached = true - 'utest_21112_0622 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "0.6.22", cached)) - 'utest_2124_0622 - checkUtest("2.12.4", "0.6.22", cached) - 'utest_21112_0631 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "0.6.31", cached)) - 'utest_2124_0631 - checkUtest("2.12.4", "0.6.31", cached) + 'utest_2124_0632 - checkUtest("2.12.4", "0.6.32", cached) + 'utest_2131_0632 - checkUtest("2.13.1", "0.6.32", cached) + 'utest_2124_100 - checkUtest("2.12.4", "1.0.0", cached) + 'utest_2131_100 - checkUtest("2.13.1", "1.0.0", cached) // No utest artifact for Scala.js 1.0.0 published yet // 'utest_21112_100 - TestUtil.disableInJava9OrAbove(checkUtest("2.11.12", "1.0.0")) // 'utest_2124_100 - checkUtest("2.12.4", "1.0.0") // No test for ScalaTest with 0.6.22 because ScalaTest 3.1.0 requires Scala.js 0.6.29+ - 'scalaTest_21112_0631 - TestUtil.disableInJava9OrAbove(checkScalaTest("2.11.12", "0.6.31", cached)) - 'scalaTest_2124_0631 - checkScalaTest("2.12.4", "0.6.31", cached) - 'scalaTest_21112_100RC1 - checkScalaTest("2.11.12", "1.0.0-RC1", cached) - 'scalaTest_2124_100RC1 - checkScalaTest("2.12.4", "1.0.0-RC1", cached) + 'scalaTest_21112_0632 - TestUtil.disableInJava9OrAbove(checkScalaTest("2.11.12", "0.6.32", cached)) + 'scalaTest_2124_0632 - checkScalaTest("2.12.4", "0.6.32", cached) + 'scalaTest_21112_100 - checkScalaTest("2.11.12", "1.0.0", cached) + 'scalaTest_2124_100 - checkScalaTest("2.12.4", "1.0.0", cached) // No ScalaTest artifact for Scala.js 1.0.0 published yet // 'scalaTest_21112_100 - checkScalaTest("2.11.12", "1.0.0") // 'scalaTest_2124_100 - checkScalaTest("2.12.4", "1.0.0") @@ -260,12 +258,13 @@ object HelloJSWorldTests extends TestSuite { } 'run - { - 'run_21112_0622 - TestUtil.disableInJava9OrAbove(checkRun("2.11.12", "0.6.22")) - 'run_2124_0622 - checkRun("2.12.4", "0.6.22") - 'run_21112_100RC1 - TestUtil.disableInJava9OrAbove(checkRun("2.11.12", "1.0.0-RC1")) - 'run_2124_100RC1 - checkRun("2.12.4", "1.0.0-RC1") + 'run_21112_0632 - TestUtil.disableInJava9OrAbove(checkRun("2.11.12", "0.6.32")) + 'run_2124_0632 - checkRun("2.12.4", "0.6.32") + 'run_2131_0632 - checkRun("2.13.1", "0.6.32") 'run_21112_100 - TestUtil.disableInJava9OrAbove(checkRun("2.11.12", "1.0.0")) 'run_2124_100 - checkRun("2.12.4", "1.0.0") + 'run_21112_100 - TestUtil.disableInJava9OrAbove(checkRun("2.11.12", "1.0.0")) + 'run_2131_100 - checkRun("2.13.1", "1.0.0") } } diff --git a/scalajslib/test/src/MultiModuleTests.scala b/scalajslib/test/src/MultiModuleTests.scala index 2ffea2cf4859..05670bfac779 100644 --- a/scalajslib/test/src/MultiModuleTests.scala +++ b/scalajslib/test/src/MultiModuleTests.scala @@ -14,7 +14,7 @@ object MultiModuleTests extends TestSuite { object MultiModule extends TestUtil.BaseModule { trait BaseModule extends ScalaJSModule { def scalaVersion = "2.12.4" - def scalaJSVersion = "0.6.22" + def scalaJSVersion = "0.6.32" } object client extends BaseModule { diff --git a/scalajslib/test/src/NodeJSConfigTests.scala b/scalajslib/test/src/NodeJSConfigTests.scala index 25b5face56fa..87c20aa425ea 100644 --- a/scalajslib/test/src/NodeJSConfigTests.scala +++ b/scalajslib/test/src/NodeJSConfigTests.scala @@ -11,7 +11,7 @@ import mill.scalajslib.api._ object NodeJSConfigTests extends TestSuite { val workspacePath = TestUtil.getOutPathStatic() / "hello-js-world" val scalaVersion = "2.12.4" - val scalaJSVersion = "0.6.22" + val scalaJSVersion = "0.6.32" val utestVersion = "0.6.3" val nodeArgsEmpty = List() val nodeArgs2G = List("--max-old-space-size=2048") diff --git a/scalalib/src/GenIdeaImpl.scala b/scalalib/src/GenIdeaImpl.scala index 26a93214ea5f..dd272c0d0437 100755 --- a/scalalib/src/GenIdeaImpl.scala +++ b/scalalib/src/GenIdeaImpl.scala @@ -241,7 +241,11 @@ case class GenIdeaImpl(evaluator: Evaluator, //TODO: also check against fixed files val fileContributions: Seq[(RelPath, Elem)] = collisionFree(configFileContributions).toSeq.map { case (file, configs) => - val map: Map[String, Seq[GenIdeaModule.Element]] = configs.groupBy(_.component).mapValues(_.flatMap(_.config)) + val map: Map[String, Seq[GenIdeaModule.Element]] = + configs + .groupBy(_.component) + .mapValues(_.flatMap(_.config)) + .toMap (os.rel / ".idea" / file) -> ideaConfigFileTemplate(map) } @@ -251,6 +255,7 @@ case class GenIdeaImpl(evaluator: Evaluator, .filter(_._2.size > 1) .mapValues(_.zipWithIndex) .flatMap(y => y._2.map(x => x._1 -> s"${y._1} (${x._2})")) + .toMap val pathToLibName = allResolved .map(p => p -> pathShortLibNameDuplicate.getOrElse(p, p.last)) diff --git a/scalalib/src/TestRunner.scala b/scalalib/src/TestRunner.scala index 7e5754e72d98..43e5de8258e0 100644 --- a/scalalib/src/TestRunner.scala +++ b/scalalib/src/TestRunner.scala @@ -89,7 +89,7 @@ object TestRunner { yield new TaskDef(cls.getName.stripSuffix("$"), fingerprint, true, Array(new SuiteSelector)) ) - val taskQueue = tasks.to[mutable.Queue] + val taskQueue = tasks.to(mutable.Queue) while (taskQueue.nonEmpty){ val next = taskQueue.dequeue().execute( new EventHandler { @@ -114,7 +114,7 @@ object TestRunner { def info(msg: String) = ctx.log.outputStream.println(msg) }) ) - taskQueue.enqueue(next:_*) + taskQueue.enqueueAll(next) } runner.done() } @@ -138,7 +138,7 @@ object TestRunner { ) } - (doneMessages.mkString("\n"), results) + (doneMessages.mkString("\n"), results.toSeq) }) } diff --git a/scalalib/src/ZincWorkerModule.scala b/scalalib/src/ZincWorkerModule.scala index 8746e75a525f..64a367d7cd18 100644 --- a/scalalib/src/ZincWorkerModule.scala +++ b/scalalib/src/ZincWorkerModule.scala @@ -26,7 +26,12 @@ trait ZincWorkerModule extends mill.Module { } def scalalibClasspath = T{ - mill.modules.Util.millProjectModule("MILL_SCALA_LIB", "mill-scalalib", repositories) + mill.modules.Util.millProjectModule( + "MILL_SCALA_LIB", + "mill-scalalib", + repositories, + artifactSuffix = "_2.13" + ) } def backgroundWrapperClasspath = T{ @@ -76,9 +81,8 @@ trait ZincWorkerModule extends mill.Module { def scalaCompilerBridgeJar(scalaVersion: String, scalaOrganization: String, - compileClassPath: Agg[mill.eval.PathRef]) = { + compileClassPath: Agg[mill.api.PathRef]) = { val (scalaVersion0, scalaBinaryVersion0) = scalaVersion match { - case s if s.startsWith("2.13.") => ("2.13.0-M2", "2.13.0-M2") case _ => (scalaVersion, mill.scalalib.api.Util.scalaBinaryVersion(scalaVersion)) } diff --git a/scalalib/src/dependency/updates/UpdatesFinder.scala b/scalalib/src/dependency/updates/UpdatesFinder.scala index e09018e6756c..b18741391dce 100644 --- a/scalalib/src/dependency/updates/UpdatesFinder.scala +++ b/scalalib/src/dependency/updates/UpdatesFinder.scala @@ -48,7 +48,7 @@ private[dependency] object UpdatesFinder { def findUpdates(dependencyVersion: DependencyVersions, allowPreRelease: Boolean): DependencyUpdates = { val current = dependencyVersion.currentVersion - val versions = dependencyVersion.allversions.to[SortedSet] + val versions = dependencyVersion.allversions.to(SortedSet) val updates = versions .filter(isUpdate(current)) diff --git a/scalalib/test/src/HelloWorldTests.scala b/scalalib/test/src/HelloWorldTests.scala index 8fd3de53f521..e91b24b8be3f 100644 --- a/scalalib/test/src/HelloWorldTests.scala +++ b/scalalib/test/src/HelloWorldTests.scala @@ -35,7 +35,7 @@ object HelloWorldTests extends TestSuite { object core extends HelloWorldModule } object CrossHelloWorld extends HelloBase { - object core extends Cross[HelloWorldCross]("2.10.6", "2.11.11", "2.12.3", "2.12.4", "2.13.0-M3") + object core extends Cross[HelloWorldCross]("2.10.6", "2.11.11", "2.12.3", "2.12.4", "2.13.1") class HelloWorldCross(val crossScalaVersion: String) extends CrossScalaModule } @@ -193,7 +193,7 @@ object HelloWorldTests extends TestSuite { object HelloWorldScalaOverride extends HelloBase{ object core extends HelloWorldModule { - override def scalaVersion: Target[String] = "2.11.11" + override def scalaVersion: Target[String] = "2.13.1" } } @@ -259,17 +259,6 @@ object HelloWorldTests extends TestSuite { } } - object HelloDotty extends HelloBase{ - object foo extends ScalaModule { - def scalaVersion = "0.9.0-RC1" - def ivyDeps = Agg(ivy"org.typelevel::cats-core:1.2.0".withDottyCompat(scalaVersion())) - } - object boo extends ScalaModule { - def scalaVersion = "0.16.0-RC3" - def ivyDeps = Agg(ivy"org.typelevel::cats-core:1.6.1".withDottyCompat(scalaVersion())) - } - } - object Dotty213 extends HelloBase { object foo extends ScalaModule { def scalaVersion = "0.18.1-RC1" @@ -335,7 +324,7 @@ object HelloWorldTests extends TestSuite { val Right((result, evalCount)) = eval.apply(HelloWorldScalaOverride.core.scalaVersion) assert( - result == "2.11.11", + result == "2.13.1", evalCount > 0 ) } @@ -528,7 +517,7 @@ object HelloWorldTests extends TestSuite { 'v211 - TestUtil.disableInJava9OrAbove(workspaceTest(CrossHelloWorld)(cross(_, "2.11.11", "2.11.11 pwns"))) 'v2123 - workspaceTest(CrossHelloWorld)(cross(_, "2.12.3", "2.12.3 leet")) 'v2124 - workspaceTest(CrossHelloWorld)(cross(_, "2.12.4", "2.12.4 leet")) - 'v2130M3 - workspaceTest(CrossHelloWorld)(cross(_, "2.13.0-M3", "2.13.0-M3 idk")) + 'v2131 - workspaceTest(CrossHelloWorld)(cross(_, "2.13.1", "2.13.1 idk")) } @@ -930,19 +919,6 @@ object HelloWorldTests extends TestSuite { ) } - 'dotty - workspaceTest( - HelloDotty, - resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-dotty" - ){ eval => - if (isJavaAtLeast("9")) { - // Skip the test because Dotty does not support Java >= 9 yet - // (see https://github.com/lampepfl/dotty/pull/3138) - } else { - val Right((_, evalCount)) = eval.apply(HelloDotty.foo.run()) - assert(evalCount > 0) - } - } - 'dotty213 - workspaceTest( Dotty213, resourcePath = os.pwd / 'scalalib / 'test / 'resources / "dotty213" diff --git a/scalalib/worker/src/ZincWorkerImpl.scala b/scalalib/worker/src/ZincWorkerImpl.scala index 84b050dd2e99..7e05a75cce3d 100644 --- a/scalalib/worker/src/ZincWorkerImpl.scala +++ b/scalalib/worker/src/ZincWorkerImpl.scala @@ -1,10 +1,14 @@ package mill.scalalib.worker -import java.io.File -import java.util.Optional +import java.io.{ByteArrayInputStream, File, InputStream, SequenceInputStream} +import java.net.URI +import java.nio.file.attribute.PosixFilePermission +import java.nio.file.{FileSystems, Files, StandardOpenOption} +import java.util.{Collections, Optional} +import java.util.jar.JarFile import mill.api.Loose.Agg -import mill.api.{Info, KeyedLockedCache, PathRef, Problem, ProblemPosition, Severity, Warn, BuildProblemReporter} +import mill.api.{BuildProblemReporter, IO, Info, KeyedLockedCache, PathRef, Problem, ProblemPosition, Severity, Warn} import mill.scalalib.api.Util.{grepJar, isDotty, scalaBinaryVersion} import mill.scalalib.api.{CompilationResult, ZincWorkerApi} import sbt.internal.inc._ @@ -165,7 +169,6 @@ class ZincWorkerImpl(compilerBridge: Either[ case Left((ctx0, bridgeProvider)) => val workingDir = ctx0.dest / scalaVersion val compiledDest = workingDir / 'compiled - if (os.exists(compiledDest)) { compiledDest } else { @@ -330,10 +333,14 @@ class ZincWorkerImpl(compilerBridge: Either[ grepJar(compilerClasspath, s"dotty-compiler_${scalaBinaryVersion(scalaVersion)}", scalaVersion) else compilerJarNameGrep(compilerClasspath, scalaVersion) + val scalaInstance = new ScalaInstance( version = scalaVersion, loader = getCachedClassLoader(compilersSig, combinedCompilerJars), - libraryJar = libraryJarNameGrep(compilerClasspath, scalaVersion).toIO, + libraryJar = libraryJarNameGrep( + compilerClasspath, + if (isDotty(scalaVersion)) "2.13.0" else scalaVersion + ).toIO, compilerJar = compilerJar.toIO, allJars = combinedCompilerJars, explicitActual = None @@ -430,7 +437,8 @@ class ZincWorkerImpl(compilerBridge: Either[ pr = { val prev = store.get() PreviousResult.of(prev.map(_.getAnalysis), prev.map(_.getMiniSetup)) - } + }, + temporaryClassesDirectory = java.util.Optional.empty() ) try { diff --git a/scalanativelib/api/src/NativeConfig.java b/scalanativelib/api/src/NativeConfig.java new file mode 100644 index 000000000000..32dd04c86248 --- /dev/null +++ b/scalanativelib/api/src/NativeConfig.java @@ -0,0 +1,8 @@ +package mill.scalanativelib.api; +// result wrapper to preserve some type safety +public class NativeConfig{ + public Object config; + public NativeConfig(Object config0){ + config = config0; + } +} diff --git a/scalanativelib/api/src/NativeLogLevel.java b/scalanativelib/api/src/NativeLogLevel.java new file mode 100644 index 000000000000..243a8b02ea42 --- /dev/null +++ b/scalanativelib/api/src/NativeLogLevel.java @@ -0,0 +1,13 @@ +package mill.scalanativelib.api; +public enum NativeLogLevel { + Error(200), + Warn(300), + Info(400), + Debug(500), + Trace(600); + + public int value; + NativeLogLevel(int value0){ + this.value = value0; + } +} diff --git a/scalanativelib/api/src/ReleaseMode.java b/scalanativelib/api/src/ReleaseMode.java new file mode 100644 index 000000000000..196eda757d6d --- /dev/null +++ b/scalanativelib/api/src/ReleaseMode.java @@ -0,0 +1,16 @@ +package mill.scalanativelib.api; +public enum ReleaseMode{ + /** Fast compile, little optimization. */ + Debug("debug"), + /** Same as [[ReleaseFull]] for versions 0.3.x. Deprecated since ScalaNative 0.4. */ + Release("release"), + /** Runtime optimize, faster compile, smaller binary. */ + ReleaseFast("release-fast"), + /** Runtime optimize, prefer speed over compile time and size. */ + ReleaseFull("release-full"); + + public String value; + ReleaseMode(String value0){ + value = value0; + } +} diff --git a/scalanativelib/api/src/ScalaNativeWorkerApi.java b/scalanativelib/api/src/ScalaNativeWorkerApi.java new file mode 100644 index 000000000000..79ef10418e95 --- /dev/null +++ b/scalanativelib/api/src/ScalaNativeWorkerApi.java @@ -0,0 +1,32 @@ +package mill.scalanativelib.api; +import sbt.testing.Framework; + +public interface ScalaNativeWorkerApi { + java.io.File discoverClang(); + java.io.File discoverClangPP(); + String discoverTarget(java.io.File clang, java.io.File workDir); + String[] discoverCompileOptions(); + String[] discoverLinkingOptions(); + + NativeConfig config(java.io.File nativeLibJar, + String mainClass, + java.io.File[] classpath, + java.io.File nativeWorkdir, + java.io.File nativeClang, + java.io.File nativeClangPP, + String nativeTarget, + String[] nativeCompileOptions, + String[] nativeLinkingOptions, + String nativeGC, + boolean nativeLinkStubs, + ReleaseMode releaseMode, + NativeLogLevel logLevel); + + String defaultGarbageCollector(); + java.io.File nativeLink(NativeConfig nativeConfig, java.io.File outPath); + + Framework newScalaNativeFrameWork(Framework framework, int id, + java.io.File testBinary, + NativeLogLevel logLevel, + java.util.Map envVars); + } diff --git a/scalanativelib/api/src/ScalaNativeWorkerApi.scala b/scalanativelib/api/src/ScalaNativeWorkerApi.scala deleted file mode 100644 index ac536156c11c..000000000000 --- a/scalanativelib/api/src/ScalaNativeWorkerApi.scala +++ /dev/null @@ -1,66 +0,0 @@ -package mill.scalanativelib.api - -import upickle.default.{macroRW, ReadWriter => RW} -import java.io.File -import sbt.testing.Framework - -trait ScalaNativeWorkerApi { - def discoverClang: os.Path - def discoverClangPP: os.Path - def discoverTarget(clang: os.Path, workDir: os.Path): String - def discoverCompileOptions: Seq[String] - def discoverLinkingOptions: Seq[String] - - def config(nativeLibJar: os.Path, - mainClass: String, - classpath: Seq[os.Path], - nativeWorkdir: os.Path, - nativeClang: os.Path, - nativeClangPP: os.Path, - nativeTarget: String, - nativeCompileOptions: Seq[String], - nativeLinkingOptions: Seq[String], - nativeGC: String, - nativeLinkStubs: Boolean, - releaseMode: ReleaseMode, - logLevel: NativeLogLevel): NativeConfig - - def defaultGarbageCollector: String - def nativeLink(nativeConfig: NativeConfig, outPath: os.Path): os.Path - - def newScalaNativeFrameWork(framework: Framework, id: Int, testBinary: File, - logLevel: NativeLogLevel, envVars: Map[String, String]): Framework -} - - -sealed abstract class NativeLogLevel(val level: Int) extends Ordered[NativeLogLevel] { - def compare(that: NativeLogLevel) = this.level - that.level -} - -object NativeLogLevel { - case object Error extends NativeLogLevel(200) - case object Warn extends NativeLogLevel(300) - case object Info extends NativeLogLevel(400) - case object Debug extends NativeLogLevel(500) - case object Trace extends NativeLogLevel(600) - - implicit def rw: RW[NativeLogLevel] = macroRW -} - -sealed abstract class ReleaseMode(val name: String) - -object ReleaseMode { - /** Fast compile, little optimization. */ - case object Debug extends ReleaseMode("debug") - /** Same as [[ReleaseFull]] for versions 0.3.x. Deprecated since ScalaNative 0.4. */ - case object Release extends ReleaseMode("release") - /** Runtime optimize, faster compile, smaller binary. */ - case object ReleaseFast extends ReleaseMode("release-fast") - /** Runtime optimize, prefer speed over compile time and size. */ - case object ReleaseFull extends ReleaseMode("release-full") - - implicit def rw: RW[ReleaseMode] = macroRW -} - -// result wrapper to preserve some type safety -case class NativeConfig(config: Any) diff --git a/scalanativelib/src/ScalaNativeModule.scala b/scalanativelib/src/ScalaNativeModule.scala index 7e6af7eab4b4..0b29111ec156 100644 --- a/scalanativelib/src/ScalaNativeModule.scala +++ b/scalanativelib/src/ScalaNativeModule.scala @@ -34,7 +34,9 @@ trait ScalaNativeModule extends ScalaModule { outer => def scalaNativeWorkerVersion = T{ mill.scalalib.api.Util.scalaJSNativeWorkerVersion(scalaNativeVersion()) } - def scalaNativeWorker = T.task{ ScalaNativeWorkerApi.scalaNativeWorker().impl(bridgeFullClassPath()) } + def scalaNativeWorker = T.task{ + mill.scalanativelib.ScalaNativeWorkerApi.scalaNativeWorker().impl(bridgeFullClassPath()) + } def scalaNativeWorkerClasspath = T { val workerKey = "MILL_SCALANATIVE_WORKER_" + scalaNativeWorkerVersion().replace('.', '_') @@ -42,7 +44,8 @@ trait ScalaNativeModule extends ScalaModule { outer => workerKey, s"mill-scalanativelib-worker-${scalaNativeWorkerVersion()}", repositories, - resolveFilter = _.toString.contains("mill-scalanativelib-worker") + resolveFilter = _.toString.contains("mill-scalanativelib-worker"), + artifactSuffix = "_2.12" ) } @@ -89,10 +92,10 @@ trait ScalaNativeModule extends ScalaModule { outer => def nativeWorkdir = T{ T.dest } // Location of the clang compiler - def nativeClang = T{ scalaNativeWorker().discoverClang } + def nativeClang = T{ os.Path(scalaNativeWorker().discoverClang) } // Location of the clang++ compiler - def nativeClangPP = T{ scalaNativeWorker().discoverClangPP } + def nativeClangPP = T{ os.Path(scalaNativeWorker().discoverClangPP) } // GC choice, either "none", "boehm" or "immix" def nativeGC = T{ @@ -100,7 +103,9 @@ trait ScalaNativeModule extends ScalaModule { outer => .getOrElse(scalaNativeWorker().defaultGarbageCollector) } - def nativeTarget = T{ scalaNativeWorker().discoverTarget(nativeClang(), nativeWorkdir()) } + def nativeTarget = T{ + scalaNativeWorker().discoverTarget(nativeClang().toIO, nativeWorkdir().toIO) + } // Options that are passed to clang during compilation def nativeCompileOptions = T{ scalaNativeWorker().discoverCompileOptions } @@ -123,12 +128,12 @@ trait ScalaNativeModule extends ScalaModule { outer => val classpath = runClasspath().map(_.path).filter(_.toIO.exists).toList scalaNativeWorker().config( - nativeLibJar().path, + nativeLibJar().path.toIO, finalMainClass(), - classpath, - nativeWorkdir(), - nativeClang(), - nativeClangPP(), + classpath.toArray.map(_.toIO), + nativeWorkdir().toIO, + nativeClang().toIO, + nativeClangPP().toIO, nativeTarget(), nativeCompileOptions(), nativeLinkingOptions(), @@ -139,7 +144,9 @@ trait ScalaNativeModule extends ScalaModule { outer => } // Generates native binary - def nativeLink = T{ scalaNativeWorker().nativeLink(nativeConfig(), (T.dest / 'out)) } + def nativeLink = T{ + os.Path(scalaNativeWorker().nativeLink(nativeConfig(), (T.dest / 'out).toIO)) + } // Runs the native binary override def run(args: String*) = T.command{ @@ -173,7 +180,10 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule { testOute val nativeFrameworks = (cl: ClassLoader) => frameworkInstances.zipWithIndex.map { case (f, id) => - scalaNativeWorker().newScalaNativeFrameWork(f, id, testBinary, logLevel(), envVars) + import collection.JavaConverters._ + scalaNativeWorker().newScalaNativeFrameWork( + f, id, testBinary, logLevel(), envVars.asJava + ) } TestRunner.runTests( diff --git a/scalanativelib/src/ScalaNativeWorkerApi.scala b/scalanativelib/src/ScalaNativeWorkerApi.scala index 80325f1e4550..ca9b05b41724 100644 --- a/scalanativelib/src/ScalaNativeWorkerApi.scala +++ b/scalanativelib/src/ScalaNativeWorkerApi.scala @@ -11,14 +11,16 @@ import mill.scalanativelib.api._ class ScalaNativeWorker { private var scalaInstanceCache = Option.empty[(Long, ScalaNativeWorkerApi)] - def impl(toolsClasspath: Agg[os.Path]): ScalaNativeWorkerApi = { + def impl(toolsClasspath: Agg[os.Path]) + (implicit ctx: mill.api.Ctx.Home): ScalaNativeWorkerApi = { val classloaderSig = toolsClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum scalaInstanceCache match { case Some((sig, bridge)) if sig == classloaderSig => bridge case _ => - val cl = new URLClassLoader( - toolsClasspath.map(_.toIO.toURI.toURL).toArray, - getClass.getClassLoader + val cl = mill.api.ClassLoader.create( + toolsClasspath.map(_.toIO.toURI.toURL).toSeq, + null, + sharedPrefixes = Seq("mill.scalanativelib.api.", "sbt.testing.") ) try { val bridge = cl diff --git a/scalanativelib/test/src/HelloNativeWorldTests.scala b/scalanativelib/test/src/HelloNativeWorldTests.scala index 192ec2927e41..1b4ca140fa03 100644 --- a/scalanativelib/test/src/HelloNativeWorldTests.scala +++ b/scalanativelib/test/src/HelloNativeWorldTests.scala @@ -148,6 +148,7 @@ object HelloNativeWorldTests extends TestSuite { testResults .groupBy(_.fullyQualifiedName) .mapValues(_.map(e => e.selector -> e).toMap) + .toMap } def checkNoTests(scalaVersion: String, scalaNativeVersion: String, mode: ReleaseMode, cached: Boolean) = { diff --git a/scalanativelib/worker/src/ScalaNativeWorkerImpl.scala b/scalanativelib/worker/src/ScalaNativeWorkerImpl.scala index b32e84ffde97..c07f889435e4 100644 --- a/scalanativelib/worker/src/ScalaNativeWorkerImpl.scala +++ b/scalanativelib/worker/src/ScalaNativeWorkerImpl.scala @@ -13,61 +13,62 @@ import scala.scalanative.testinterface.ScalaNativeFramework class ScalaNativeWorkerImpl extends mill.scalanativelib.api.ScalaNativeWorkerApi { def logger(level: NativeLogLevel) = Logger( - debugFn = msg => if (level >= NativeLogLevel.Debug) out.println(msg), - infoFn = msg => if (level >= NativeLogLevel.Info) out.println(msg), - warnFn = msg => if (level >= NativeLogLevel.Warn) out.println(msg), - errorFn = msg => if (level >= NativeLogLevel.Error) err.println(msg)) + debugFn = msg => if (level.value >= NativeLogLevel.Debug.value) out.println(msg), + infoFn = msg => if (level.value >= NativeLogLevel.Info.value) out.println(msg), + warnFn = msg => if (level.value >= NativeLogLevel.Warn.value) out.println(msg), + errorFn = msg => if (level.value >= NativeLogLevel.Error.value) err.println(msg)) - def discoverClang: os.Path = os.Path(Discover.clang()) - def discoverClangPP: os.Path = os.Path(Discover.clangpp()) - def discoverTarget(clang: os.Path, workdir: os.Path): String = Discover.targetTriple(clang.toNIO, workdir.toNIO) - def discoverCompileOptions: Seq[String] = Discover.compileOptions() - def discoverLinkingOptions: Seq[String] = Discover.linkingOptions() + def discoverClang: java.io.File = Discover.clang().toFile + def discoverClangPP: java.io.File = Discover.clangpp().toFile + def discoverTarget(clang: java.io.File, + workdir: java.io.File): String = Discover.targetTriple(clang.toPath, workdir.toPath) + def discoverCompileOptions: Array[String] = Discover.compileOptions().toArray + def discoverLinkingOptions: Array[String] = Discover.linkingOptions().toArray def defaultGarbageCollector: String = GC.default.name - def config(nativeLibJar: os.Path, + def config(nativeLibJar: java.io.File, mainClass: String, - classpath: Seq[os.Path], - nativeWorkdir: os.Path, - nativeClang: os.Path, - nativeClangPP: os.Path, + classpath: Array[java.io.File], + nativeWorkdir: java.io.File, + nativeClang: java.io.File, + nativeClangPP: java.io.File, nativeTarget: String, - nativeCompileOptions: Seq[String], - nativeLinkingOptions: Seq[String], + nativeCompileOptions: Array[String], + nativeLinkingOptions: Array[String], nativeGC: String, nativeLinkStubs: Boolean, releaseMode: ReleaseMode, logLevel: NativeLogLevel): NativeConfig = { val entry = mainClass + "$" - val config = Config.empty - .withNativelib(nativeLibJar.toNIO) + .withNativelib(nativeLibJar.toPath) .withMainClass(entry) - .withClassPath(classpath.map(_.toNIO)) - .withWorkdir(nativeWorkdir.toNIO) - .withClang(nativeClang.toNIO) - .withClangPP(nativeClangPP.toNIO) + .withClassPath(classpath.map(_.toPath)) + .withWorkdir(nativeWorkdir.toPath) + .withClang(nativeClang.toPath) + .withClangPP(nativeClangPP.toPath) .withTargetTriple(nativeTarget) .withCompileOptions(nativeCompileOptions) .withLinkingOptions(nativeLinkingOptions) .withGC(GC(nativeGC)) .withLinkStubs(nativeLinkStubs) - .withMode(Mode(releaseMode.name)) + .withMode(Mode(releaseMode.value)) .withLogger(logger(logLevel)) - NativeConfig(config) + new NativeConfig(config) } - def nativeLink(nativeConfig: NativeConfig, outPath: os.Path): os.Path = { + def nativeLink(nativeConfig: NativeConfig, outPath: java.io.File): java.io.File = { val config = nativeConfig.config.asInstanceOf[Config] - Build.build(config, outPath.toNIO) + Build.build(config, outPath.toPath) outPath } override def newScalaNativeFrameWork(framework: Framework, id: Int, testBinary: File, - logLevel: NativeLogLevel, envVars: Map[String, String]): Framework = + logLevel: NativeLogLevel, envVars: java.util.Map[String, String]): Framework = { - new ScalaNativeFramework(framework, id, logger(logLevel), testBinary, envVars) + import collection.JavaConverters._ + new ScalaNativeFramework(framework, id, logger(logLevel), testBinary, envVars.asScala.toMap) } }