diff --git a/contrib/bloop/readme.adoc b/contrib/bloop/readme.adoc deleted file mode 100644 index f5554e28a21..00000000000 --- a/contrib/bloop/readme.adoc +++ /dev/null @@ -1,52 +0,0 @@ -= Bloop -:page-aliases: Plugin_Bloop.adoc - -This plugin generates https://scalacenter.github.io/bloop/[bloop] configuration -from your build file, which lets you use the bloop CLI for compiling, and makes -your scala code editable in https://scalameta.org/metals/[Metals] - -== Quickstart - -In your terminal: - -.Generate Bloop project configuration ----- -> mill --import ivy:com.lihaoyi::mill-contrib-bloop: mill.contrib.bloop.Bloop/install ----- - -It generate correct bloop config for any `JavaModule`, `ScalaModule`, -`ScalaJsModule` or `ScalaNativeModule` under the `.bloop` folder - -== Mix-in - -You can mix-in the `Bloop.Module` trait with any JavaModule to quickly access -the deserialised configuration for that particular module: - -.`build.mill` -[source,scala] ----- -//| mvnDeps: ["com.lihaoyi::mill-contrib-bloop:$MILL_VERSION"] - -package build - -import mill._ -import mill.scalalib._ -import mill.contrib.bloop.Bloop - -object MyModule extends ScalaModule with Bloop.Module { - def myTask = Task { bloop.config() } -} ----- - -== Note regarding metals - -Metals will automatically detect your mill workspace and generate the necessary files that bloop needs. -You don't need to manually include the bloop plugin in order for this to work. -Also note that your mill/ammonite related `.sc` files are only partially supported by metals when -located inside a project workspace. - -== Note regarding current mill support in bloop - -The mill-bloop integration currently present in the -https://github.com/scalacenter/bloop[bloop codebase] -will be deprecated in favour of this implementation. diff --git a/contrib/bloop/src/mill/contrib/bloop/Bloop.scala b/contrib/bloop/src/mill/contrib/bloop/Bloop.scala deleted file mode 100644 index dbfb685ee44..00000000000 --- a/contrib/bloop/src/mill/contrib/bloop/Bloop.scala +++ /dev/null @@ -1,13 +0,0 @@ -//package mill.contrib.bloop -// -//import WorkspaceRoot -//import mill.define.Evaluator -// -///** -// * Usage : `mill mill.contrib.bloop.Bloop/install` -// */ -//object Bloop extends BloopImpl( -// () => Evaluator.allBootstrapEvaluators.value.value, -// WorkspaceRoot.workspaceRoot, -// addMillSources = None -// ) diff --git a/contrib/bloop/src/mill/contrib/bloop/BloopFormats.scala b/contrib/bloop/src/mill/contrib/bloop/BloopFormats.scala deleted file mode 100644 index db64d85284e..00000000000 --- a/contrib/bloop/src/mill/contrib/bloop/BloopFormats.scala +++ /dev/null @@ -1,50 +0,0 @@ -//package mill.contrib.bloop -// -//import _root_.bloop.config.{Config => BloopConfig} -//import upickle.default.{ReadWriter, macroRW, readwriter} -// -//object BloopFormats { -// -// implicit val pathRW: ReadWriter[java.nio.file.Path] = -// readwriter[String].bimap[java.nio.file.Path]( -// _.toString, -// java.nio.file.Paths.get(_) -// ) -// implicit val artifactRW: ReadWriter[BloopConfig.Artifact] = macroRW -// implicit val checksumRW: ReadWriter[BloopConfig.Checksum] = macroRW -// implicit val linkerModeDebugRW: ReadWriter[BloopConfig.LinkerMode.Debug.type] = macroRW -// implicit val linkerModeReleaseRW: ReadWriter[BloopConfig.LinkerMode.Release.type] = macroRW -// implicit val moduleKindJSCommonJSModuleRW -// : ReadWriter[BloopConfig.ModuleKindJS.CommonJSModule.type] = macroRW -// implicit val moduleKindJSNoModuleRW: ReadWriter[BloopConfig.ModuleKindJS.NoModule.type] = macroRW -// implicit val moduleKindJSESModuleRW: ReadWriter[BloopConfig.ModuleKindJS.ESModule.type] = macroRW -// implicit val javaThenScalaRW: ReadWriter[BloopConfig.JavaThenScala.type] = macroRW -// implicit val scalaThenJavaRW: ReadWriter[BloopConfig.ScalaThenJava.type] = macroRW -// implicit val mixedRW: ReadWriter[BloopConfig.Mixed.type] = macroRW -// implicit val compileOrderRW: ReadWriter[BloopConfig.CompileOrder] = macroRW -// implicit val compileSetupRW: ReadWriter[BloopConfig.CompileSetup] = macroRW -// implicit val fileRW: ReadWriter[BloopConfig.File] = macroRW -// implicit val javaRW: ReadWriter[BloopConfig.Java] = macroRW -// implicit val jsConfigRW: ReadWriter[BloopConfig.JsConfig] = macroRW -// implicit val jvmConfigRW: ReadWriter[BloopConfig.JvmConfig] = macroRW -// implicit val linkerModeRW: ReadWriter[BloopConfig.LinkerMode] = macroRW -// implicit val moduleKindJSRW: ReadWriter[BloopConfig.ModuleKindJS] = macroRW -// implicit val moduleRW: ReadWriter[BloopConfig.Module] = macroRW -// implicit val nativeConfigRW: ReadWriter[BloopConfig.NativeConfig] = macroRW -// implicit val nativeOptionsRW: ReadWriter[BloopConfig.NativeOptions] = macroRW -// implicit val platformJsRW: ReadWriter[BloopConfig.Platform.Js] = macroRW -// implicit val platformJvmRW: ReadWriter[BloopConfig.Platform.Jvm] = macroRW -// implicit val platformNativeRW: ReadWriter[BloopConfig.Platform.Native] = macroRW -// implicit val platformRW: ReadWriter[BloopConfig.Platform] = macroRW -// implicit val resolutionRW: ReadWriter[BloopConfig.Resolution] = macroRW -// implicit val sbtRW: ReadWriter[BloopConfig.Sbt] = macroRW -// implicit val scalaRw: ReadWriter[BloopConfig.Scala] = macroRW -// implicit val sourcesGlobsRW: ReadWriter[BloopConfig.SourcesGlobs] = macroRW -// implicit val sourceGeneratorRW: ReadWriter[BloopConfig.SourceGenerator] = macroRW -// implicit val testArgumentRW: ReadWriter[BloopConfig.TestArgument] = macroRW -// implicit val testFrameworkRW: ReadWriter[BloopConfig.TestFramework] = macroRW -// implicit val testOptionsRW: ReadWriter[BloopConfig.TestOptions] = macroRW -// implicit val testRW: ReadWriter[BloopConfig.Test] = macroRW -// implicit val projectRW: ReadWriter[BloopConfig.Project] = macroRW -// -//} diff --git a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala b/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala deleted file mode 100644 index 659b1852666..00000000000 --- a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala +++ /dev/null @@ -1,533 +0,0 @@ -//package mill.contrib.bloop -// -//import _root_.bloop.config.{Config => BloopConfig, Tag => BloopTag} -//import mill._ -//import mill.api.Result -//import mill.define.{Discover, Evaluator, ExternalModule, Module as MillModule} -//import mill.main.BuildInfo -//import mill.scalalib.internal.JavaModuleUtils -//import mill.scalajslib.ScalaJSModule -//import mill.scalajslib.api.{JsEnvConfig, ModuleKind} -//import mill.scalalib._ -//import mill.scalanativelib.ScalaNativeModule -//import mill.scalanativelib.api.ReleaseMode -// -//import java.nio.file.{FileSystemNotFoundException, Files, Paths} -// -///** -// * Implementation of the Bloop related tasks. Inherited by the -// * `mill.contrib.bloop.Bloop` object, and usable in tests by passing -// * a custom evaluator. -// */ -//class BloopImpl( -// evs: () => Seq[Evaluator], -// wd: os.Path, -// addMillSources: Option[Boolean] -//) extends ExternalModule { -// outer => -// import BloopFormats._ -// -// private val bloopDir = wd / ".bloop" -// -// /** -// * Generates bloop configuration files reflecting the build, -// * under pwd/.bloop. -// */ -// def install() = Task.Command { -// val res = Task.traverse(computeModules) { -// case (mod, isRoot) => -// mod.bloop.writeConfigFile(isRoot) -// }() -// val written = res.map(_._2).map(_.path) -// // Make bloopDir if it doesn't exists -// if (!os.exists(bloopDir)) { -// os.makeDir(bloopDir) -// } -// // Cleaning up configs that weren't generated in this run. -// os.list(bloopDir) -// .filter(_.ext == "json") -// .filterNot(written.contains) -// .foreach(os.remove) -// res -// } -// -// /** -// * Trait that can be mixed-in to quickly access the bloop config -// * of the module. -// * -// * {{{ -// * object myModule extends ScalaModule with Bloop.Module { -// * ... -// * } -// * }}} -// */ -// trait Module extends MillModule { self: JavaModule => -// -// /** -// * Allows to tell Bloop whether it should use "fullOptJs" or -// * "fastOptJs" when compiling. Used exclusively with ScalaJsModules. -// */ -// def linkerMode: T[Option[BloopConfig.LinkerMode]] = None -// -// object bloop extends MillModule { -// def config = Task { -// bloopConfig(self, false)() -// } -// } -// -// /** -// * Setting to true enables skipping the bloop configuration generation -// */ -// def skipBloop: Boolean = false -// } -// -// /** -// * Extension class used to ensure that the config related tasks are -// * cached alongside their respective modules, without requesting the user -// * to extend a specific trait. -// * -// * This also ensures that we're not duplicating work between the global -// * "install" task that traverse all modules in the build, and "local" tasks -// * that traverse only their transitive dependencies. -// */ -// private implicit class BloopOps(jm: JavaModule) extends MillModule { -// override def moduleCtx = jm.moduleCtx -// -// object bloop extends MillModule { -// def writeConfigFile(isRootModule: Boolean): Command[(String, PathRef)] = Task.Command { -// os.makeDir.all(bloopDir) -// val path = bloopConfigPath(jm) -// _root_.bloop.config.write(outer.bloopConfig(jm, isRootModule)(), path.toNIO) -// Task.log.info(s"Wrote $path") -// name(jm) -> PathRef(path) -// } -// } -// -// def asBloop: Option[Module] = jm match { -// case m: Module => Some(m) -// case _ => None -// } -// } -// -// /** -// * All modules that are meant to be imported in Bloop -// * -// * @return sequence of modules and a boolean indicating whether the module is a root one -// */ -// protected def computeModules: Seq[(JavaModule, Boolean)] = -// evs() -// .filter(_ != null) -// .flatMap { eval => -// val rootModule = eval.rootModule -// JavaModuleUtils.transitiveModules(rootModule, accept) -// .collect { case jm: JavaModule => jm } -// .map(mod => (mod, mod == rootModule)) -// } -// -// // class-based pattern matching against path-dependant types doesn't seem to work. -// private def accept(module: MillModule): Boolean = -// if (module.isInstanceOf[JavaModule] && module.isInstanceOf[outer.Module]) -// !module.asInstanceOf[outer.Module].skipBloop -// else true -// -// /** -// * Computes sources files paths for the whole project. Cached in a way -// * that does not get invalidated upon source file change. Mainly called -// * from module#sources in bloopInstall -// */ -// def moduleSourceMap = Task { -// val sources = Task.traverse(computeModules) { -// case (m, _) => -// m.allSources.map { paths => -// name(m) -> paths.map(_.path) -// } -// }() -// Result.Success(sources.toMap) -// } -// -// protected def name(m: JavaModule): String = m.bspDisplayName.replace('/', '-') -// -// protected def bloopConfigPath(module: JavaModule): os.Path = -// bloopDir / s"${name(module)}.json" -// -// // //////////////////////////////////////////////////////////////////////////// -// // Computation of the bloop configuration for a specific module -// // //////////////////////////////////////////////////////////////////////////// -// -// def bloopConfig(module: JavaModule, isRootModule: Boolean): Task[BloopConfig.File] = { -// import _root_.bloop.config.Config -// def out(m: JavaModule) = bloopDir / "out" / name(m) -// def classes(m: JavaModule) = out(m) / "classes" -// -// val javaConfig = Task.Anon { -// val opts = module.javacOptions() ++ module.mandatoryJavacOptions() -// Some(Config.Java(options = opts.toList)) -// } -// -// // ////////////////////////////////////////////////////////////////////////// -// // Scalac -// // ////////////////////////////////////////////////////////////////////////// -// -// val scalaConfig = module match { -// case s: ScalaModule => -// Task.Anon { -// Some( -// BloopConfig.Scala( -// organization = s.scalaOrganization(), -// name = "scala-compiler", -// version = s.scalaVersion(), -// options = s.allScalacOptions().toList, -// jars = s.scalaCompilerClasspath().map(_.path.toNIO).toList, -// analysis = None, -// setup = None -// ) -// ) -// } -// case _ => Task.Anon(None) -// } -// -// // ////////////////////////////////////////////////////////////////////////// -// // Platform (Jvm/Js/Native) -// // ////////////////////////////////////////////////////////////////////////// -// -// def jsLinkerMode(m: JavaModule): Task[Config.LinkerMode] = -// (m.asBloop match { -// case Some(bm) => Task.Anon(bm.linkerMode()) -// case None => Task.Anon(None) -// }).map(_.getOrElse(Config.LinkerMode.Debug)) -// -// // ////////////////////////////////////////////////////////////////////////// -// // Classpath -// // ////////////////////////////////////////////////////////////////////////// -// -// val classpath = Task.Anon { -// val transitiveCompileClasspath = Task.traverse(module.transitiveModuleCompileModuleDeps)(m => -// Task.Anon { m.localCompileClasspath().map(_.path) ++ Seq(classes(m)) } -// )().flatten -// -// module.resolvedMvnDeps().map(_.path) ++ -// transitiveCompileClasspath ++ -// module.localCompileClasspath().map(_.path) -// } -// -// val isTestModule = module match { -// case _: TestModule => true -// case _ => false -// } -// val runtimeClasspathOpt = -// if (isTestModule) -// Task.Anon(None) -// else -// Task.Anon { -// val cp = module.transitiveModuleDeps.map(classes) ++ -// module.resolvedRunMvnDeps().map(_.path) ++ -// module.unmanagedClasspath().map(_.path) -// Some(cp.map(_.toNIO).toList) -// } -// -// val compileResources = -// Task.Anon(module.compileResources().map(_.path.toNIO).toList) -// val runtimeResources = -// Task.Anon(compileResources() ++ module.resources().map(_.path.toNIO).toList) -// -// val platform: Task[BloopConfig.Platform] = module match { -// case m: ScalaJSModule => -// Task.Anon { -// BloopConfig.Platform.Js( -// BloopConfig.JsConfig.empty.copy( -// version = m.scalaJSVersion(), -// mode = jsLinkerMode(m)(), -// kind = m.moduleKind() match { -// case ModuleKind.NoModule => Config.ModuleKindJS.NoModule -// case ModuleKind.CommonJSModule => -// Config.ModuleKindJS.CommonJSModule -// case ModuleKind.ESModule => Config.ModuleKindJS.ESModule -// }, -// emitSourceMaps = m.jsEnvConfig() match { -// case c: JsEnvConfig.NodeJs => c.sourceMap -// case _ => false -// }, -// jsdom = Some(false) -// ), -// mainClass = module.mainClass() -// ) -// } -// case m: ScalaNativeModule => -// Task.Anon { -// BloopConfig.Platform.Native( -// BloopConfig.NativeConfig.empty.copy( -// version = m.scalaNativeVersion(), -// mode = m.releaseMode() match { -// case ReleaseMode.Debug => BloopConfig.LinkerMode.Debug -// case ReleaseMode.ReleaseFast => BloopConfig.LinkerMode.Release -// case ReleaseMode.ReleaseFull => BloopConfig.LinkerMode.Release -// case ReleaseMode.ReleaseSize => BloopConfig.LinkerMode.Release -// }, -// gc = m.nativeGC(), -// targetTriple = m.nativeTarget(), -// clang = m.nativeClang().path.toNIO, -// clangpp = m.nativeClangPP().path.toNIO, -// options = Config.NativeOptions( -// m.nativeLinkingOptions().toList, -// m.nativeCompileOptions().toList -// ), -// linkStubs = m.nativeLinkStubs() -// ), -// mainClass = module.mainClass() -// ) -// } -// case _ => -// Task.Anon { -// BloopConfig.Platform.Jvm( -// BloopConfig.JvmConfig( -// home = Task.env.get("JAVA_HOME").map(s => os.Path(s).toNIO), -// options = { -// // See https://github.com/scalacenter/bloop/issues/1167 -// val forkArgs = module.forkArgs().toList -// if (forkArgs.exists(_.startsWith("-Duser.dir="))) forkArgs -// else s"-Duser.dir=$wd" :: forkArgs -// } -// ), -// mainClass = module.mainClass(), -// runtimeConfig = None, -// classpath = runtimeClasspathOpt(), -// resources = Some(runtimeResources()) -// ) -// } -// } -// -// // ////////////////////////////////////////////////////////////////////////// -// // Tests -// // ////////////////////////////////////////////////////////////////////////// -// -// val testConfig = module match { -// case m: TestModule => -// Task.Anon { -// Some( -// BloopConfig.Test( -// frameworks = Seq(m.testFramework()) -// .map(f => Config.TestFramework(List(f))) -// .toList, -// options = Config.TestOptions( -// excludes = List(), -// arguments = List() -// ) -// ) -// ) -// } -// case _ => Task.Anon(None) -// } -// -// // ////////////////////////////////////////////////////////////////////////// -// // Ivy dependencies + sources -// // ////////////////////////////////////////////////////////////////////////// -// -// /** -// * Resolves artifacts using coursier and creates the corresponding -// * bloop config. -// */ -// def artifacts( -// repos: Seq[coursier.Repository], -// deps: Seq[coursier.Dependency] -// ): List[BloopConfig.Module] = { -// -// import coursier._ -// import coursier.util._ -// -// import scala.concurrent.ExecutionContext.Implicits.global -// Fetch(coursier.cache.FileCache()) -// .addRepositories(repos*) -// .addDependencies(deps*) -// .withMainArtifacts() -// .addClassifiers(coursier.Classifier("sources")) -// .runResult() -// .fullDetailedArtifacts -// .collect { -// case (dep, _, _, Some(file)) if os.Path(file).ext == "jar" => -// ( -// dep.module.organization, -// dep.module.name, -// dep.version, -// Option(dep.attributes.classifier).filter(_.nonEmpty), -// file -// ) -// } -// .groupBy { -// case (org, mod, version, _, _) => (org, mod, version) -// } -// .view -// .mapValues { -// _.map { -// case (_, mod, _, classifier, file) => -// BloopConfig.Artifact(mod.value, classifier.map(_.value), None, file.toPath) -// }.toList -// } -// .map { -// case ((org, mod, version), artifacts) => -// BloopConfig.Module( -// organization = org.value, -// name = mod.value, -// version = version, -// configurations = None, -// artifacts = artifacts -// ) -// } -// .toList -// } -// -// val millBuildDependencies: Task[List[BloopConfig.Module]] = Task.Anon { -// -// val result = module.defaultResolver().artifacts( -// BuildInfo.millAllDistDependencies -// .split(',') -// .filter(_.nonEmpty) -// .map { str => -// str.split(":", 3) match { -// case Array(org, name, ver) => -// val module = -// coursier.Module(coursier.Organization(org), coursier.ModuleName(name), Map.empty) -// coursier.Dependency(module, ver) -// case other => -// sys.error( -// s"Unexpected misshapen entry in BuildInfo.millEmbeddedDeps ('$str', expected 'org:name')" -// ) -// } -// }, -// sources = true -// ) -// -// def moduleOf(dep: coursier.Dependency): BloopConfig.Module = -// BloopConfig.Module( -// dep.module.organization.value, -// dep.module.name.value, -// dep.version, -// Some(dep.configuration.value).filter(_.nonEmpty), -// Nil -// ) -// -// val indices = result.fullDetailedArtifacts -// .map { -// case (dep, _, _, _) => -// moduleOf(dep) -// } -// .zipWithIndex -// .reverseIterator -// .toMap -// -// result.fullDetailedArtifacts -// .groupBy { -// case (dep, _, _, _) => -// moduleOf(dep) -// } -// .toList -// .sortBy { -// case (mod, _) => -// indices(mod) -// } -// .map { -// case (mod, artifacts) => -// mod.copy( -// artifacts = artifacts.toList.collect { -// case (_, pub, art, Some(file)) => -// BloopConfig.Artifact( -// pub.name, -// Some(pub.classifier.value).filter(_.nonEmpty), -// None, -// file.toPath -// ) -// } -// ) -// } -// } -// -// val bloopDependencies: Task[List[BloopConfig.Module]] = Task.Anon { -// val repos = module.allRepositories() -// // same as input of resolvedMvnDeps -// val coursierDeps = Seq( -// module.coursierDependency.withConfiguration(coursier.core.Configuration.provided), -// module.coursierDependency -// ) -// artifacts(repos, coursierDeps) -// } -// -// val addMillSources0 = addMillSources.getOrElse { -// // We only try to resolve Mill's dependencies to get their source JARs -// // if we're not running from sources. If Mill is running purely from its sources -// // it's not is published in ~/.ivy2/local, so we can't get its source JARs. -// !BloopImpl.isMillRunningFromSources -// } -// val allBloopDependencies: Task[List[BloopConfig.Module]] = -// // Add Mill source JARs to root modules -// if (isRootModule && addMillSources0) -// Task.Anon { -// bloopDependencies() ::: millBuildDependencies() -// } -// else -// bloopDependencies -// -// // ////////////////////////////////////////////////////////////////////////// -// // Tying up -// // ////////////////////////////////////////////////////////////////////////// -// -// val project = Task.Anon { -// val mSources = moduleSourceMap() -// .get(name(module)) -// .toSeq -// .flatten -// .map(_.toNIO) -// .toList -// -// val tags = -// module match { case _: TestModule => List(BloopTag.Test); case _ => List(BloopTag.Library) } -// -// BloopConfig.Project( -// name = name(module), -// directory = module.moduleDir.toNIO, -// workspaceDir = Some(wd.toNIO), -// sources = mSources, -// sourcesGlobs = None, -// sourceRoots = None, -// dependencies = -// (module.moduleDepsChecked ++ module.compileModuleDepsChecked).map(name).toList, -// classpath = classpath().map(_.toNIO).toList, -// out = out(module).toNIO, -// classesDir = classes(module).toNIO, -// resources = Some(compileResources()), -// `scala` = scalaConfig(), -// java = javaConfig(), -// sbt = None, -// test = testConfig(), -// platform = Some(platform()), -// resolution = Some(BloopConfig.Resolution(allBloopDependencies())), -// tags = Some(tags), -// sourceGenerators = None // TODO: are we supposed to hook generated sources here? -// ) -// } -// -// Task.Anon { -// BloopConfig.File( -// version = BloopConfig.File.LatestVersion, -// project = project() -// ) -// } -// } -// -// lazy val millDiscover = Discover[this.type] -//} -// -//object BloopImpl { -// // If the class of BloopImpl is loaded from a directory rather than a JAR, -// // then we're running from sources (the directory should be something -// // like mill-repo/out/contrib/bloop/compile.dest/classes). -// private lazy val isMillRunningFromSources = -// Option(classOf[BloopImpl].getProtectionDomain.getCodeSource) -// .flatMap(s => Option(s.getLocation)) -// .flatMap { url => -// try Some(Paths.get(url.toURI)) -// catch { -// case _: FileSystemNotFoundException => None -// case _: IllegalArgumentException => None -// } -// } -// .exists(Files.isDirectory(_)) -//} diff --git a/contrib/bloop/test/src/mill/contrib/bloop/BloopTests.scala b/contrib/bloop/test/src/mill/contrib/bloop/BloopTests.scala deleted file mode 100644 index 829f2d79eb5..00000000000 --- a/contrib/bloop/test/src/mill/contrib/bloop/BloopTests.scala +++ /dev/null @@ -1,287 +0,0 @@ -//package mill.contrib.bloop -// -//import bloop.config.{Config => BloopConfig} -//import mill._ -//import mill.scalajslib.api.ModuleKind -//import mill.scalalib._ -//import mill.define.Discover -//import mill.scalanativelib.api.ReleaseMode -//import mill.testkit.UnitTester -//import mill.testkit.TestRootModule -//import os.Path -//import upickle.default._ -//import utest._ -//import bloop.config.Config.Platform.Jvm -//import scala.util.Properties.isWin -// -//object BloopTests extends TestSuite { -// import BloopFormats._ -// -// val unitTester = UnitTester(build, null) -// val workdir = unitTester.evaluator.rootModule.moduleDir -// val testBloop = new BloopImpl( -// () => Seq(unitTester.evaluator), -// workdir, -// addMillSources = None -// ) -// -// object build extends TestRootModule { -// object scalaModule extends scalalib.ScalaModule with testBloop.Module { -// def scalaVersion = "2.12.8" -// val bloopVersion = mill.contrib.bloop.Versions.bloop -// override def mainClass = Some("foo.bar.Main") -// -// override def mvnDeps = Seq( -// mvn"ch.epfl.scala::bloop-config:$bloopVersion" -// ) -// override def scalacOptions = Seq( -// "-language:higherKinds" -// ) -// -// override def compileMvnDeps = Seq( -// mvn"org.reactivestreams:reactive-streams:1.0.3" -// ) -// -// override def runMvnDeps = Seq( -// mvn"org.postgresql:postgresql:42.3.3" -// ) -// -// object test extends ScalaTests with TestModule.Utest -// } -// -// object scalaModule2 extends scalalib.ScalaModule { -// def scalaVersion = "2.12.8" -// def moduleDeps = Seq(scalaModule) -// } -// object scalaModule3 extends scalalib.ScalaModule { -// def scalaVersion = "2.12.8" -// def moduleDeps = Seq(scalaModule2) -// } -// object scalaModule4 extends scalalib.ScalaModule { -// def scalaVersion = "2.12.8" -// def compileModuleDeps = Seq(scalaModule3) -// } -// -// object scalajsModule extends scalajslib.ScalaJSModule with testBloop.Module { -// val sv = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???) -// val sjsv = sys.props.getOrElse("TEST_SCALAJS_VERSION", ???) -// override def scalaVersion = sv -// override def scalaJSVersion = sjsv -// override def linkerMode = T(Some(_root_.bloop.config.Config.LinkerMode.Release)) -// override def moduleKind = T(ModuleKind.CommonJSModule) -// } -// -// object scalanativeModule extends scalanativelib.ScalaNativeModule with testBloop.Module { -// val sv = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???) -// override def skipBloop: Boolean = isWin -// override def scalaVersion = sv -// override def scalaNativeVersion = sys.props.getOrElse("TEST_SCALANATIVE_0_5_VERSION", ???) -// override def releaseMode = T(ReleaseMode.Debug) -// } -// -// object skippedModule extends scalalib.ScalaModule with testBloop.Module { -// def scalaVersion = "2.12.8" -// override def skipBloop: Boolean = true -// } -// -// lazy val millDiscover = Discover[this.type] -// } -// -// def readBloopConf(jsonFile: String) = -// _root_.bloop.config.read((workdir / ".bloop" / jsonFile).toNIO) -// .toOption -// .get -// -// def tests: Tests = Tests { -// test("genBloopTests") { -// -// unitTester(testBloop.install()) -// val scalaModuleConfig = readBloopConf("scalaModule.json") -// val scalaModule2Config = readBloopConf("scalaModule2.json") -// val scalaModule3Config = readBloopConf("scalaModule3.json") -// val scalaModule4Config = readBloopConf("scalaModule4.json") -// val testModuleConfig = readBloopConf("scalaModule.test.json") -// val scalajsModuleConfig = readBloopConf("scalajsModule.json") -// // skipped on Windows -// val scalanativeModuleConfig = -// if (scala.util.Properties.isWin) None else Some(readBloopConf("scalanativeModule.json")) -// -// test("no-compilation") { -// val workspaceOut = unitTester.outPath -// -// // Ensuring that bloop config generation didn't trigger compilation -// assert(os.exists(workspaceOut / "scalaModule")) -// assert(!os.exists(workspaceOut / "scalaModule/compile")) -// assert(os.exists(workspaceOut / "scalaModule2")) -// assert(!os.exists(workspaceOut / "scalaModule2/compile")) -// } -// -// test("scalaModule") { -// val p = scalaModuleConfig.project -// val name = p.name -// val workspaceDir = p.workspaceDir -// val sources = p.sources.map(Path(_)) -// val options = p.scala.get.options -// val version = p.scala.get.version -// val compileClasspath = p.classpath.map(_.toString) -// val compileResources = p.resources.get.map(_.toString.replace('\\', '/')) -// val platform = p.platform.get.asInstanceOf[Jvm] -// val jvmOptions = platform.config.options -// val runtimeClasspath = platform.classpath.get.map(_.toString) -// val runtimeResources = platform.resources.get.map(_.toString) -// val resolution = p.resolution.get.modules -// -// assert(name == "scalaModule") -// assert(workspaceDir == Some(workdir.wrapped)) -// assert(sources == List(workdir / "scalaModule/src")) -// assert(options.contains("-language:higherKinds")) -// assert(version == "2.12.8") -// assert( -// compileClasspath.exists( -// _.contains(s"bloop-config_2.12-${build.scalaModule.bloopVersion}.jar") -// ) -// ) -// assert(compileClasspath.exists(_.contains("reactive-streams-1.0.3.jar"))) -// assert(!runtimeClasspath.exists(_.contains("reactive-streams-1.0.3.jar"))) -// -// assert(runtimeClasspath.exists(_.contains("postgresql-42.3.3.jar"))) -// assert(!compileClasspath.exists(_.contains("postgresql-42.3.3.jar"))) -// -// assert(platform.name == "jvm") -// assert(platform.mainClass.get == "foo.bar.Main") -// assert(jvmOptions.contains(s"-Duser.dir=$workdir")) -// -// val bloopConfigDep = resolution.find(_.name == "bloop-config_2.12").get -// val artifacts = bloopConfigDep.artifacts -// assert(bloopConfigDep.version == build.scalaModule.bloopVersion) -// assert(bloopConfigDep.organization == "ch.epfl.scala") -// assert(artifacts.map(_.name).distinct == List("bloop-config_2.12")) -// assert(artifacts.flatMap(_.classifier).contains("sources")) -// -// assert( -// compileResources.exists(_.replace('\\', '/').contains("scalaModule/compile-resources")) -// ) -// assert(!compileResources.exists(_.replace('\\', '/').contains("scalaModule/resources"))) -// -// assert( -// runtimeResources.exists(_.replace('\\', '/').contains("scalaModule/compile-resources")) -// ) -// assert(runtimeResources.exists(_.replace('\\', '/').contains("scalaModule/resources"))) -// } -// test("scalaModuleTest") { -// val p = testModuleConfig.project -// val name = p.name -// val workspaceDir = p.workspaceDir -// val sources = p.sources.map(Path(_)) -// val framework = p.test.get.frameworks.head.names.head -// val dep = p.dependencies.head -// val mainModuleClasspath = scalaModuleConfig.project.classpath -// assert(name == "scalaModule.test") -// assert(workspaceDir == Some(workdir.wrapped)) -// assert(sources == List(workdir / "scalaModule/test/src")) -// assert(framework == "utest.runner.Framework") -// assert(dep == "scalaModule") -// assert( -// mainModuleClasspath.filterNot(_.toString.contains("reactive-streams-1.0.3.jar")).forall( -// p.classpath.contains -// ) -// ) -// assert(p.platform.get.asInstanceOf[Jvm].classpath == None) -// } -// test("configAccessTest") { -// val accessedConfig = -// unitTester(build.scalaModule.bloop.config).asSuccess.get.value.toOption.get -// assert(accessedConfig.value == scalaModuleConfig) -// } -// test("noDepTest") { -// val cp = scalaModule2Config.project.classpath.map(_.toString) -// assert(cp.exists(_.contains("scala-library-2.12.8"))) -// } -// test("classpath") { -// val cp = scalaModule3Config.project.classpath.map(_.toString.replace('\\', '/')) -// assert(!cp.exists(_.contains(".bloop/out/scalaModule3/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule2/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule/classes"))) -// } -// test("platform-classpath") { -// val cp = scalaModule3Config.project.platform.get.asInstanceOf[Jvm].classpath.map( -// _.toString.replace('\\', '/') -// ) -// assert(cp.exists(_.contains(".bloop/out/scalaModule3/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule2/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule/classes"))) -// } -// test("classpath-compile-module-deps") { -// val cp = scalaModule4Config.project.classpath.map(_.toString.replace('\\', '/')) -// assert(cp.exists(_.contains(".bloop/out/scalaModule3/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule2/classes"))) -// assert(cp.exists(_.contains(".bloop/out/scalaModule/classes"))) -// } -// test("platform-classpath-compile-module-deps") { -// val cp = scalaModule4Config.project.platform.get.asInstanceOf[Jvm].classpath.map( -// _.toString.replace('\\', '/') -// ) -// assert(!cp.exists(_.contains(".bloop/out/scalaModule3/classes"))) -// assert(!cp.exists(_.contains(".bloop/out/scalaModule2/classes"))) -// assert(!cp.exists(_.contains(".bloop/out/scalaModule/classes"))) -// } -// test("scalajsModule") { -// val p = scalajsModuleConfig.project -// val name = p.name -// val workspaceDir = p.workspaceDir -// val sources = p.sources.map(Path(_)) -// val version = p.scala.get.version -// val platform = p.platform.get.asInstanceOf[BloopConfig.Platform.Js] -// -// assert(name == "scalajsModule") -// assert(workspaceDir == Some(workdir.wrapped)) -// assert(sources == List(workdir / "scalajsModule/src")) -// assert(version == build.scalajsModule.sv) -// assert(platform.config.emitSourceMaps) -// assert(platform.config.kind == BloopConfig.ModuleKindJS.CommonJSModule) -// assert(platform.config.mode == BloopConfig.LinkerMode.Release) -// } -// test("scalanativeModule") { -// scalanativeModuleConfig match { -// case None => -// val exists = os.exists(workdir / ".bloop/scalanativeModule.json") -// assert(exists == false) -// case Some(scalanativeModuleConfig) => -// val p = scalanativeModuleConfig.project -// val name = p.name -// val workspaceDir = p.workspaceDir -// val sources = p.sources.map(Path(_)) -// val version = p.scala.get.version -// val platform = p.platform.get.asInstanceOf[BloopConfig.Platform.Native] -// -// val clang = -// unitTester(build.scalanativeModule.nativeClang).asSuccess.get.value.toOption.get -// -// assert(name == "scalanativeModule") -// assert(workspaceDir == Some(workdir.wrapped)) -// assert(sources == List(workdir / "scalanativeModule/src")) -// assert(version == build.scalanativeModule.sv) -// assert(platform.config.mode == BloopConfig.LinkerMode.Debug) -// assert(platform.config.clang == clang.value.path.toNIO) -// } -// } -// test("skipped") { -// val exists = os.exists(workdir / ".bloop/skippedModule.json") -// assert(exists == false) -// } -// } -// test("regenerateAfterBloopDirRemoval") { -// unitTester(testBloop.install()) -// val bloopDir = workdir / ".bloop" -// val files = os.list(bloopDir) -// val size = (if (isWin) 6 else 7) -// assert(files.size == size) -// os.remove.all(bloopDir) -// unitTester(testBloop.install()) -// val files2 = os.list(bloopDir) -// assert(files2.size == size) -// assert(files2 == files) -// } -// } -// -//} diff --git a/core/util/package.mill b/core/util/package.mill index 069ea0cfdfd..57b785f2d6a 100644 --- a/core/util/package.mill +++ b/core/util/package.mill @@ -32,10 +32,6 @@ object `package` extends MillStableScalaModule with BuildInfo { def buildInfoPackageName = "mill.util" - // Inlining this method below currently triggers an error like - // java.lang.IllegalArgumentException: Could not find proxy for … - private def distAllDeps = build.dist +: build.dist.recursiveModuleDeps - def buildInfoMembers = Seq( BuildInfo.Value( "workerScalaVersion212", @@ -49,38 +45,6 @@ object `package` extends MillStableScalaModule with BuildInfo { ), BuildInfo.Value("scalaVersion", scalaVersion(), "Scala version used to compile mill core."), BuildInfo.Value("millVersion", build.millVersion(), "Mill version."), - BuildInfo.Value("millBinPlatform", build.millBinPlatform(), "Mill binary platform version."), - BuildInfo.Value( - "millAllDistDependencies", { - // Maps internal modules from JavaModule#coursierDependency (like 'mill-internal:thing:0+mill-internal') - // to actual coordinates used for publishing (like 'com.lihaoyi:mill-thing:0.13.1') - val internalToPublishedModuleMap = Task.traverse( - distAllDeps.collect { case m: PublishModule => m } - ) { mod => - Task.Anon { - val selfDep = mod.artifactMetadata() - ( - s"${mod.coursierDependency.module.repr}:${mod.coursierDependency.versionConstraint.asString}", - s"${selfDep.group}:${selfDep.id}:${selfDep.version}" - ) - } - }().toMap - - val result = build.dist.millResolver().resolution( - Seq(BoundDep(build.dist.coursierDependency, force = false)) - ) - result.orderedDependencies - .map(dep => s"${dep.module.repr}:${dep.versionConstraint.asString}") - .distinct - .map(mod => internalToPublishedModuleMap.getOrElse(mod, mod)) - .mkString(",") - }, - "All Mill distribution dependencies" - ), - BuildInfo.Value( - "millScalacPluginDeps", - Deps.millModuledefsString, - "Scalac compiler plugin dependencies to compile the build script." - ) + BuildInfo.Value("millBinPlatform", build.millBinPlatform(), "Mill binary platform version.") ) } diff --git a/libs/kotlinlib/package.mill b/libs/kotlinlib/package.mill index 3e94fc55941..84baee65d55 100644 --- a/libs/kotlinlib/package.mill +++ b/libs/kotlinlib/package.mill @@ -18,9 +18,6 @@ object `package` extends MillPublishScalaModule with BuildInfo { def buildInfoObjectName = "Versions" def buildInfoMembers = Seq( BuildInfo.Value("kotlinVersion", Deps.kotlinVersion, "Version of Kotlin"), - BuildInfo.Value("kotlinVersion2", Deps.kotlinVersion, "Version of Kotlin"), - BuildInfo.Value("kotlinVersion3", Deps.kotlinVersion, "Version of Kotlin"), - BuildInfo.Value("kotlinVersion4", Deps.kotlinVersion, "Version of Kotlin"), BuildInfo.Value("koverVersion", Deps.RuntimeDeps.koverVersion, "Version of Kover."), BuildInfo.Value("ktfmtVersion", Deps.RuntimeDeps.ktfmt.version, "Version of Ktfmt."), BuildInfo.Value("ktlintVersion", Deps.RuntimeDeps.ktlint.version, "Version of ktlint."),