Skip to content

Commit

Permalink
Update Mill from 0.10.15 to 0.11.7
Browse files Browse the repository at this point in the history
Some changes are wild guesses. And it does not compile all modules.

Here is one error:

```
amm.compiler[2.12.8].compile java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI
```
  • Loading branch information
lefou committed Mar 5, 2024
1 parent 11b2e64 commit a68e981
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.15
0.11.7
98 changes: 52 additions & 46 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mill._
import scalalib._
import publish._
import mill.api.Lazy
import mill.contrib.bloop.Bloop
import mill.scalalib.api.ZincWorkerUtil._
import coursier.mavenRepositoryString
Expand All @@ -9,7 +10,7 @@ import $file.ci.upload
import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $ivy.`io.get-coursier::coursier-launcher:2.1.0-RC1`
import mill.define.Command
import mill.testrunner.TestRunner
import mill.testrunner.TestResult
import scala.util.chaining.scalaUtilChainingOps

val ghOrg = "com-lihaoyi"
Expand Down Expand Up @@ -161,11 +162,12 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module {
ivy"$scalaO:scala-library:$scalaV"
)
}
trait AmmTests extends super.Tests with TestModule.Utest {
trait AmmTests extends CrossSbtModuleTests with TestModule.Utest {
def ivyDeps = super.ivyDeps() ++ Agg(Deps.utest)
def forkArgs = Seq("-Xmx2g", "-Dfile.encoding=UTF8")
}
def allIvyDeps = T { transitiveIvyDeps() ++ scalaLibraryIvyDeps() }
// why is this here?
// def allIvyDeps = T { transitiveIvyDeps() ++ scalaLibraryIvyDeps() }
def sources = T.sources {
val sv = scalaVersion()
val extraDir =
Expand Down Expand Up @@ -216,11 +218,13 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module {
super.sources() ++ extraDir ++ extraDir2 ++ extraDir3 ++ extraDir4 ++ extraDir5
}
def externalSources = T {
resolveDeps(allIvyDeps, sources = true)()
resolveDeps(transitiveIvyDeps, sources = true)()
}
def repositoriesTask = T.task {
super.repositoriesTask() ++ Seq(
mvn"https://scala-ci.typesafe.com/artifactory/scala-integration"
)
}
def repositories = super.repositories ++ Seq(
mvn"https://scala-ci.typesafe.com/artifactory/scala-integration"
)
override implicit def crossSbtModuleResolver: mill.define.Cross.Resolver[CrossModuleBase] =
new mill.define.Cross.Resolver[CrossModuleBase] {
def resolve[V <: CrossModuleBase](c: Cross[V]): V = {
Expand All @@ -232,14 +236,14 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module {
}
.flatMap(prefix =>
c.items
.map(_._2)
.map(_.module.value)
.find(_.crossScalaVersion.split('.').startsWith(prefix))
)
.collectFirst { case x => x }
.getOrElse {
throw new Exception(
s"Unable to find compatible cross version between $crossScalaVersion and " +
c.items.map(_._2.crossScalaVersion).mkString(",")
c.items.map(_.module.value.crossScalaVersion).mkString(",")
)
}

Expand All @@ -260,13 +264,13 @@ trait AmmModule extends AmmInternalModule with PublishModule {
)

def transitiveJars: T[Agg[PathRef]] = T {
mill.define.Target.traverse(this +: moduleDeps)(m =>
mill.define.Target.traverse(transitiveModuleDeps)(m =>
T.task { m.jar() }
)()
}

def transitiveSourceJars: T[Agg[PathRef]] = T {
mill.define.Target.traverse(this +: moduleDeps)(m =>
mill.define.Target.traverse(transitiveModuleDeps)(m =>
T.task { m.sourceJar() }
)()
}
Expand All @@ -276,11 +280,12 @@ trait AmmModule extends AmmInternalModule with PublishModule {
trait AmmDependenciesResourceFileModule extends JavaModule {
def dependencyResourceFileName: String
def dependencyFileResources = T {
val deps0 = T.task { compileIvyDeps() ++ transitiveIvyDeps() }()
// val deps0 = T.task { compileIvyDeps() ++ transitiveIvyDeps() }()
val deps0 = transitiveCompileIvyDeps()
val (_, res) = mill.modules.Jvm.resolveDependenciesMetadata(
repositoriesTask(),
deps0.map(resolveCoursierDependency().apply(_)),
deps0.filter(_.force).map(resolveCoursierDependency().apply(_)),
deps0.map(_.dep), // .map(resolveCoursierDependency().apply(_)),
deps0.filter(_.force).map(_.dep), // .map(resolveCoursierDependency().apply(_)),
mapDependencies = Some(mapDependencies())
)

Expand All @@ -295,8 +300,8 @@ trait AmmDependenciesResourceFileModule extends JavaModule {
}
}

object terminal extends Cross[TerminalModule](binCrossScalaVersions: _*)
class TerminalModule(val crossScalaVersion: String) extends AmmModule {
object terminal extends Cross[TerminalModule](binCrossScalaVersions)
trait TerminalModule extends AmmModule {
def ivyDeps = T {
super.ivyDeps() ++ Agg(
Deps.fansi,
Expand All @@ -308,9 +313,9 @@ class TerminalModule(val crossScalaVersion: String) extends AmmModule {
}
}

object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
object util extends Cross[UtilModule](binCrossScalaVersions: _*)
class UtilModule(val crossScalaVersion: String) extends AmmModule {
object amm extends Cross[MainModule](fullCrossScalaVersions) {
object util extends Cross[UtilModule](binCrossScalaVersions)
trait UtilModule extends AmmModule {
def moduleDeps = Seq()
def ivyDeps = T {
super.ivyDeps() ++ Agg(
Expand All @@ -325,8 +330,8 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
(if (isScala3(crossScalaVersion)) Agg.empty[Dep] else Agg(Deps.scalaReflect(scalaVersion())))
}

object runtime extends Cross[RuntimeModule](fullCrossScalaVersions: _*)
class RuntimeModule(val crossScalaVersion: String) extends AmmModule {
object runtime extends Cross[RuntimeModule](fullCrossScalaVersions)
trait RuntimeModule extends AmmModule {
def moduleDeps = Seq(amm.util(), interp.api(), amm.repl.api())
def isCrossFullScalaVersion = true
def ivyDeps = super.ivyDeps() ++ Agg(
Expand All @@ -338,9 +343,9 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
)
}

object compiler extends Cross[CompilerModule](fullCrossScalaVersions: _*) {
object interface extends Cross[CompilerInterfaceModule](fullCrossScalaVersions: _*)
class CompilerInterfaceModule(val crossScalaVersion: String) extends AmmModule {
object compiler extends Cross[CompilerModule](fullCrossScalaVersions) {
object interface extends Cross[CompilerInterfaceModule](fullCrossScalaVersions)
trait CompilerInterfaceModule extends AmmModule {
def isCrossFullScalaVersion = true
def moduleDeps = Seq(amm.util())
def exposedClassPath = T {
Expand All @@ -351,7 +356,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
}
}
}
class CompilerModule(val crossScalaVersion: String) extends AmmModule {
trait CompilerModule extends AmmModule {
def supports3 = true
def moduleDeps = Seq(amm.compiler.interface(), amm.util(), amm.repl.api())
def isCrossFullScalaVersion = true
Expand Down Expand Up @@ -384,9 +389,9 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
object test extends AmmTests
}

object interp extends Cross[InterpModule](fullCrossScalaVersions: _*) {
object api extends Cross[InterpApiModule](fullCrossScalaVersions: _*)
class InterpApiModule(val crossScalaVersion: String) extends AmmModule
object interp extends Cross[InterpModule](fullCrossScalaVersions) {
object api extends Cross[InterpApiModule](fullCrossScalaVersions)
trait InterpApiModule extends AmmModule
with AmmDependenciesResourceFileModule {
def moduleDeps = Seq(amm.compiler.interface(), amm.util())
def isCrossFullScalaVersion = true
Expand Down Expand Up @@ -419,7 +424,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
super.generatedSources() ++ Seq(constantsSourceDir())
}
}
class InterpModule(val crossScalaVersion: String) extends AmmModule {
trait InterpModule extends AmmModule {
def moduleDeps = Seq(amm.util(), amm.runtime(), amm.compiler.interface())
def isCrossFullScalaVersion = true
def ivyDeps = super.ivyDeps() ++ Agg(
Expand All @@ -444,10 +449,10 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
// )
// }

object repl extends Cross[ReplModule](fullCrossScalaVersions: _*) {
object repl extends Cross[ReplModule](fullCrossScalaVersions) {

object api extends Cross[ReplApiModule](fullCrossScalaVersions: _*)
class ReplApiModule(val crossScalaVersion: String) extends AmmModule
object api extends Cross[ReplApiModule](fullCrossScalaVersions)
trait ReplApiModule extends AmmModule
with AmmDependenciesResourceFileModule {
def isCrossFullScalaVersion = true
def dependencyResourceFileName = "amm-dependencies.txt"
Expand All @@ -473,7 +478,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
}

}
class ReplModule(val crossScalaVersion: String) extends AmmModule {
trait ReplModule extends AmmModule {
def isCrossFullScalaVersion = true
def moduleDeps = Seq(
amm.util(),
Expand Down Expand Up @@ -502,7 +507,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
amm.repl.api().exposedClassPath() ++
amm.compiler().exposedClassPath() ++
Seq(compile().classes) ++
resolveDeps(T.task { compileIvyDeps() ++ transitiveIvyDeps() })()
resolveDeps(T.task { compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })()
)
}

Expand All @@ -514,7 +519,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
(super.resources() ++
ReplModule.this.sources() ++
ReplModule.this.externalSources() ++
resolveDeps(ivyDeps, sources = true)()).distinct
resolveDeps(T.task { ivyDeps().map(bindDependency()) }, sources = true)()).distinct
}
def ivyDeps = super.ivyDeps() ++ amm.compiler().ivyDeps() ++ Agg(
Deps.scalazCore
Expand All @@ -523,7 +528,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) {
}
}

class MainModule(val crossScalaVersion: String) extends AmmModule {
trait MainModule extends AmmModule {

def isCrossFullScalaVersion = true

Expand Down Expand Up @@ -619,7 +624,7 @@ class MainModule(val crossScalaVersion: String) extends AmmModule {
amm.repl.api().exposedClassPath() ++
amm.compiler().exposedClassPath() ++
Seq(amm.repl().test.compile().classes, compile().classes) ++
resolveDeps(T.task { compileIvyDeps() ++ transitiveIvyDeps() })()
resolveDeps(T.task { compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })()
)
}

Expand Down Expand Up @@ -667,8 +672,8 @@ def generateApiWhitelist(replApiCp: Seq[PathRef])(implicit ctx: mill.api.Ctx.Des
PathRef(ctx.dest)
}

object integration extends Cross[IntegrationModule](fullCrossScalaVersions: _*)
class IntegrationModule(val crossScalaVersion: String) extends AmmInternalModule {
object integration extends Cross[IntegrationModule](fullCrossScalaVersions)
trait IntegrationModule extends AmmInternalModule {
def moduleDeps = Seq(amm())
def ivyDeps = T {
super.ivyDeps() ++ (
Expand All @@ -691,8 +696,8 @@ class IntegrationModule(val crossScalaVersion: String) extends AmmInternalModule
}
}

object sshd extends Cross[SshdModule](fullCrossScalaVersions: _*)
class SshdModule(val crossScalaVersion: String) extends AmmModule {
object sshd extends Cross[SshdModule](fullCrossScalaVersions)
trait SshdModule extends AmmModule {
def moduleDeps = Seq(amm())
def isCrossFullScalaVersion = true
def ivyDeps = super.ivyDeps() ++ Agg(
Expand All @@ -714,18 +719,19 @@ class SshdModule(val crossScalaVersion: String) extends AmmModule {
* Selects all cross module instances, that match the given predicate.
* In Mill 0.11, this can be hopefully replaced with a simple filter on the `crossValue`.
*/
def selectCrossPrefix[T <: Module, V](
def selectCrossPrefix[T <: Cross.Module[_], V](
crossModule: Cross[T],
predicate: String => Boolean
)(accessor: T => V): Seq[V] =
crossModule.items.collect {
case (List(key: String), mod) if predicate(key) => accessor(mod)
case item if predicate(item.crossSegments.head) => accessor(item.module.value)
// case (List(key: String), mod) if predicate(key) => accessor(mod)
}
.tap { mods =>
if (mods.isEmpty) sys.error(s"No matching cross-instances found in ${crossModule}")
}

def unitTest(scalaBinaryVersion: String = ""): Command[Seq[(String, Seq[TestRunner.Result])]] = {
def unitTest(scalaBinaryVersion: String = ""): Command[Seq[(String, Seq[TestResult])]] = {
val pred = (_: String).startsWith(scalaBinaryVersion)
val tests = Seq(
selectCrossPrefix(terminal, pred)(_.test),
Expand Down Expand Up @@ -757,7 +763,7 @@ def generateConstantsFile(
oldCurlUrls: Seq[(String, String)] = Nil,
oldUnstableCurlUrls: Seq[(String, String)] = Nil,
returnDirectory: Boolean = true
)(implicit ctx: mill.util.Ctx.Dest) = {
)(implicit ctx: mill.api.Ctx.Dest) = {
val versionTxt = s"""
package ammonite
object Constants{
Expand Down Expand Up @@ -785,7 +791,7 @@ def generateConstantsFile(
}

def generateDependenciesFile(fileName: String, deps: Seq[coursier.Dependency])(implicit
ctx: mill.util.Ctx.Dest
ctx: mill.api.Ctx.Dest
) = {

val dir = ctx.dest / "extra-resources"
Expand Down
2 changes: 1 addition & 1 deletion ci/upload.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env amm

@main
@mainargs.main
def apply(uploadedFile: os.Path,
tagName: String,
uploadName: String,
Expand Down

0 comments on commit a68e981

Please sign in to comment.