Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update Mill to 0.10.13, cleanup and fix deprecations #2874

Merged
merged 7 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.10.13
45 changes: 23 additions & 22 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $file.project.millconfig
import $ivy.`com.lihaoyi::mill-contrib-bloop:`
import $ivy.`io.get-coursier.util::get-cs:0.1.1`
import $file.project.deps, deps.{Deps, ScalaVersions, scalaCliVersion}
import $file.project.docs
Expand Down Expand Up @@ -135,13 +136,13 @@ object `bootstrap-launcher` extends BootstrapLauncher { self =>
def proguardClassPath = T {
proguard.runClasspath()
}
object test extends Tests with CsTests {
object test extends SbtModuleTests with CsTests {
def ivyDeps = super.ivyDeps() ++ Seq(
Deps.collectionCompat,
Deps.java8Compat
)
}
object it extends Tests with CsTests {
object it extends SbtModuleTests with CsTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
Expand Down Expand Up @@ -207,7 +208,7 @@ class CoreJvm(val crossScalaVersion: String) extends CoreJvmBase {
Deps.concurrentReferenceHashMap,
Deps.scalaXml
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jol
)
Expand All @@ -220,7 +221,7 @@ class CoreJs(val crossScalaVersion: String) extends Core with CsScalaJsModule {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalaJsDom
)
object test extends Tests with CsTests
object test extends ScalaJSTests with CsTests
}

class SbtMavenRepositoryJvm(val crossScalaVersion: String) extends SbtMavenRepositoryJvmBase {
Expand Down Expand Up @@ -259,7 +260,7 @@ class CacheJvm(val crossScalaVersion: String) extends CacheJvmBase {
def customLoaderCp = T {
`custom-protocol-for-test`.runClasspath()
}
object test extends Tests with CsTests {
object test extends CacheJvmBaseTests with CsTests {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.http4sBlazeServer,
Deps.http4sDsl,
Expand Down Expand Up @@ -309,7 +310,7 @@ class Env(val crossScalaVersion: String) extends CrossSbtModule with CsModule
Deps.collectionCompat,
Deps.jniUtils
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jimfs
)
Expand All @@ -336,8 +337,8 @@ class CoursierJvm(val crossScalaVersion: String) extends CoursierJvmBase { self
`proxy-setup`
)
// Put CoursierTests right after TestModule, and see what happens
object test extends TestModule with Tests with CoursierTests with CsTests with JvmTests
object it extends TestModule with Tests with CoursierTests with CsTests with JvmTests {
object test extends TestModule with CrossSbtModuleTests with CoursierTests with CsTests with JvmTests
object it extends TestModule with CrossSbtModuleTests with CoursierTests with CsTests with JvmTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
Expand All @@ -360,7 +361,7 @@ class CoursierJs(val crossScalaVersion: String) extends Coursier with CsScalaJsM
core.js(),
cache.js()
)
object test extends Tests with CsTests with JsTests with CoursierTests
object test extends ScalaJSTests with CsTests with JsTests with CoursierTests
}

class TestsJvm(val crossScalaVersion: String) extends TestsModule { self =>
Expand All @@ -371,12 +372,12 @@ class TestsJvm(val crossScalaVersion: String) extends TestsModule { self =>
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.jsoup
)
object test extends Tests with CsTests with JvmTests {
object test extends CrossSbtModuleTests with CsTests with JvmTests {
def moduleDeps = super.moduleDeps ++ Seq(
coursier.jvm()
)
}
object it extends Tests with CsTests with JvmTests with workers.UsesRedirectingServer {
object it extends CrossSbtModuleTests with CsTests with JvmTests with workers.UsesRedirectingServer {
def redirectingServerCp =
`redirecting-server`.runClasspath()
def redirectingServerMainClass =
Expand Down Expand Up @@ -407,7 +408,7 @@ class TestsJs(val crossScalaVersion: String) extends TestsModule with CsScalaJsM
`sbt-maven-repository`.js()
)
// testOptions := testOptions.dependsOn(runNpmInstallIfNeeded).value
object test extends Tests with CsTests with JsTests {
object test extends ScalaJSTests with CsTests with JsTests {
def moduleDeps = super.moduleDeps ++ Seq(
coursier.js()
)
Expand All @@ -423,7 +424,7 @@ class ProxyTests(val crossScalaVersion: String) extends CrossSbtModule with CsMo
Deps.scalaAsync,
Deps.slf4JNop
)
object it extends Tests with CsTests {
object it extends CrossSbtModuleTests with CsTests {
def sources = T.sources(
millSourcePath / "src" / "it" / "scala",
millSourcePath / "src" / "it" / "java"
Expand All @@ -443,7 +444,7 @@ class ScalazJvm(val crossScalaVersion: String) extends Scalaz with CsMima {
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.scalazConcurrent
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def moduleDeps = super.moduleDeps ++ Seq(
tests.jvm().test
)
Expand All @@ -462,7 +463,7 @@ class CatsJvm(val crossScalaVersion: String) extends Cats with CsMima {
def moduleDeps = Seq(
cache.jvm()
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def moduleDeps = super.moduleDeps ++ Seq(
tests.jvm().test
)
Expand Down Expand Up @@ -493,7 +494,7 @@ class Install(val crossScalaVersion: String) extends CrossSbtModule with CsModul
Deps.argonautShapeless,
Deps.catsCore
)
object test extends Tests with CsTests
object test extends CrossSbtModuleTests with CsTests
}

class Jvm(val crossScalaVersion: String) extends CrossSbtModule with CsModule
Expand All @@ -515,7 +516,7 @@ class Jvm(val crossScalaVersion: String) extends CrossSbtModule with CsModule
Deps.argonautShapeless,
Deps.jsoniterCore
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def ivyDeps = super.ivyDeps() ++ Seq(
Deps.osLib
)
Expand Down Expand Up @@ -573,7 +574,7 @@ class Cli(val crossScalaVersion: String) extends CsCrossJvmJsModule
os.write.over(jar, baos.toByteArray)
PathRef(jar)
}
object test extends Tests with CsTests
object test extends CrossSbtModuleTests with CsTests
}

class CliTests(val crossScalaVersion: String) extends CsCrossJvmJsModule
Expand All @@ -592,7 +593,7 @@ class CliTests(val crossScalaVersion: String) extends CsCrossJvmJsModule
private def sharedTestArgs = Seq(
s"-Dcoursier-test.scala-cli=${GetCs.scalaCli(scalaCliVersion)}"
)
object test extends Tests with CsTests {
object test extends CrossSbtModuleTests with CsTests {
def forkArgs = {
val launcherTask = cli().launcher.map(_.path)
val assemblyTask = cli().assembly.map(_.path)
Expand All @@ -606,7 +607,7 @@ class CliTests(val crossScalaVersion: String) extends CsCrossJvmJsModule
}
}
}
trait NativeTests extends Tests with CsTests with Bloop.Module {
trait NativeTests extends CrossSbtModuleTests with CsTests with Bloop.Module {
def cliLauncher: T[PathRef]
def skipBloop = true
def sources = T.sources {
Expand Down Expand Up @@ -698,7 +699,7 @@ def simpleNative04CliTest() = T.command {
os.proc(tmpDir / "native-echo", "-n", "foo", "a").call()
}
finally cleanUp()
assert(res.out.text == "foo a")
assert(res.out.text() == "foo a")
}
def copyTo(task: mill.main.Tasks[PathRef], dest: os.Path) = T.command {
if (task.value.length > 1)
Expand Down
2 changes: 1 addition & 1 deletion project/cs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lazy val cs: String =

candidates
.filter(_.canExecute)
.toStream
.to(LazyList)
.headOption
.map(_.getAbsolutePath)
.getOrElse {
Expand Down
2 changes: 1 addition & 1 deletion project/docs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@ def gitRepoHasChanges(repo: os.Path): Boolean = {
stderr = os.Pipe,
mergeErrIntoOut = true
)
val output = res.out.text
val output = res.out.text()
!output.contains("nothing to commit")
}
1 change: 0 additions & 1 deletion project/ghreleaseassets.sc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// from https://github.com/coursier/coursier/blob/382250d4f26b4728400a0546088e27ca0f129e8b/scripts/shared/UploadGhRelease.sc

import $ivy.`com.softwaremill.sttp.client::core:2.0.0-RC6`
import $ivy.`com.lihaoyi::ujson:0.9.5`

import $file.docs, docs.gitRepoHasChanges
import $file.launchers, launchers.{platformExtension, platformSuffix}
Expand Down
4 changes: 2 additions & 2 deletions project/launchers.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ivy.`io.get-coursier::coursier-launcher:2.1.0`
import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.23`
import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.26`

import $file.cs
import $file.deps, deps.{Deps, Docker, graalVmJvmId, jvmIndex}
Expand Down Expand Up @@ -61,7 +61,7 @@ trait Launchers extends CsModule {
"-A",
"lib"
).call()
val libPath = os.Path(libRes.out.text.trim, os.pwd)
val libPath = os.Path(libRes.out.text().trim(), os.pwd)
os.copy.over(libPath, destDir / "csjniutils.lib")
}

Expand Down
5 changes: 5 additions & 0 deletions project/millconfig.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interp.configureCompiler { c =>
c.settings.nowarnings.value = false
c.settings.deprecation.value = true
c.settings.maxwarns.value = 100
}
2 changes: 1 addition & 1 deletion project/mima.sc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait Mima extends ScalaModule with PublishModule {

val lib = new MiMaLib(classPath.map(_.path.toIO))

mimaPreviousArtifacts().toList.map(_.path).map { path =>
mimaPreviousArtifacts().iterator.toList.map(_.path).map { path =>
val problems = lib.collectProblems(path.toIO, currentClassFiles.toIO)
path.toString -> problems.filter { problem =>
mimaBinaryIssueFilters.forall(_.apply(problem))
Expand Down
4 changes: 2 additions & 2 deletions project/modules/bootstrap-launcher0.sc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ trait BootstrapLauncher extends CsModule {

def assembly = T {
val baseJar = jar().path
val cp = upstreamAssemblyClasspath().toSeq.map(_.path)
val cp = upstreamAssemblyClasspath().iterator.toSeq.map(_.path)
val mainClass0 = mainClass().getOrElse(sys.error("No main class"))

val dest = T.dest / "bootstrap-orig.jar"
Expand Down Expand Up @@ -130,7 +130,7 @@ trait BootstrapLauncher extends CsModule {
def resourceAssemblyMainClass = T("coursier.bootstrap.launcher.ResourcesLauncher")
def resourceAssembly = T {
val baseJar = jar().path
val cp = upstreamAssemblyClasspath().toSeq.map(_.path)
val cp = upstreamAssemblyClasspath().iterator.toSeq.map(_.path)
val mainClass0 = resourceAssemblyMainClass()

val dest = T.dest / "bootstrap-orig.jar"
Expand Down
2 changes: 1 addition & 1 deletion project/modules/cache0.sc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait CacheJvmBase extends Cache with CsMima with Shading {
)
}

trait Tests extends super.Tests {
trait CacheJvmBaseTests extends CrossSbtModuleTests {
def sources = T.sources {
val dest = T.dest / "CustomLoaderClasspath.scala"
val customLoaderCp0 = customLoaderCp()
Expand Down
16 changes: 8 additions & 8 deletions project/modules/shared.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ trait CsMima extends Mima {
}

def commitHash = T {
os.proc("git", "rev-parse", "HEAD").call().out.text.trim
os.proc("git", "rev-parse", "HEAD").call().out.text().trim()
}

lazy val latestTaggedVersion = os.proc("git", "describe", "--abbrev=0", "--tags", "--match", "v*")
.call().out
.trim
.trim()
lazy val buildVersion = {
val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim
val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim()
val maybeExactTag = scala.util.Try {
os.proc("git", "describe", "--exact-match", "--tags", "--always", gitHead)
.call().out
.trim
.trim()
.stripPrefix("v")
}
maybeExactTag.toOption.getOrElse {
val commitsSinceTaggedVersion =
os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call().out.trim
os.proc("git", "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call().out.trim()
.toInt
val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim
val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim()
s"${latestTaggedVersion.stripPrefix("v")}-$commitsSinceTaggedVersion-$gitHash-SNAPSHOT"
}
}
Expand Down Expand Up @@ -139,7 +139,7 @@ trait CsModule extends SbtModule {
super.scalacPluginIvyDeps() ++ scala212Plugins
}
def sources = T.sources {
val sbv = mill.scalalib.api.Util.scalaBinaryVersion(scalaVersion())
val sbv = mill.scalalib.api.ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
val parent = super.sources()
val extra = parent.map(_.path).filter(_.last == "scala").flatMap { p =>
val dirNames = Seq(s"scala-$sbv")
Expand Down
2 changes: 2 additions & 0 deletions project/publishing.sc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def publishSonatype(
readTimeout = timeout.toMillis.toInt,
connectTimeout = timeout.toMillis.toInt,
log = log,
workspace = os.pwd,
env = sys.env,
awaitTimeout = timeout.toMillis.toInt,
stagingRelease = isRelease
)
Expand Down
2 changes: 1 addition & 1 deletion project/relativize.sc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.nio.file.attribute.BasicFileAttributes
import org.jsoup.Jsoup
import org.jsoup.nodes.Element

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

def relativize(site: Path): Unit =
Files.walkFileTree(
Expand Down
11 changes: 6 additions & 5 deletions project/shading.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mill._, mill.scalalib._
import java.io._
import java.util.zip._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.concurrent.ExecutionContext.Implicits.global

trait Shading extends JavaModule with PublishModule {
Expand All @@ -26,7 +26,8 @@ trait Shading extends JavaModule with PublishModule {
force = depSeq.filter(_.force).map(depToDependency),
mapDependencies = Some(mapDependencies()),
customizer = resolutionCustomizer(),
ctx = Some(implicitly[mill.api.Ctx.Log])
ctx = Some(implicitly[mill.api.Ctx.Log]),
coursierCacheCustomizer = None
)
val types = Set(
coursier.Type.jar,
Expand All @@ -42,7 +43,7 @@ trait Shading extends JavaModule with PublishModule {
val loadedArtifacts = Gather[Task].gather(
for (a <- artifacts)
yield coursier.cache.Cache.default.file(a).run.map(a.optional -> _)
).unsafeRun
).unsafeRun()

val errors = loadedArtifacts.collect {
case (false, Left(x)) => x
Expand All @@ -57,7 +58,7 @@ trait Shading extends JavaModule with PublishModule {

val allJars = load(resolution)
val retainedJars =
load(resolution.subset(depSeq.toSeq.filterNot(shadedDepSeq.toSet).map(depToDependency)))
load(resolution.subset(depSeq.iterator.toSeq.filterNot(shadedDepSeq.iterator.toSet).map(depToDependency)))

val shadedJars = allJars.filterNot(retainedJars.toSet)
println(s"${shadedJars.length} JAR(s) to shade")
Expand Down Expand Up @@ -180,6 +181,6 @@ trait Shading extends JavaModule with PublishModule {
val convert = resolvePublishDependency().apply(_)
val orig = super.publishXmlDeps()
val shaded = shadedDependencies().iterator.map(convert).toSet
Agg(orig.toSeq.filterNot(shaded): _*)
Agg(orig.iterator.toSeq.filterNot(shaded): _*)
}
}