Skip to content

Commit

Permalink
Update mill to 0.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nightscape committed Dec 18, 2024
1 parent 0802653 commit 0c56bb1
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.12
0.12.4
44 changes: 25 additions & 19 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import de.tobiasroeser.mill.vcs.version.VcsVersion
import io.kipp.mill.ci.release.CiReleaseModule
import io.kipp.mill.ci.release.SonatypeHost

val millVersions = Seq("0.10.15", "0.11.12")
val millVersions = Seq("0.12.4", "0.11.12", "0.10.15")
val millBinaryVersions = millVersions.map(scalaNativeBinaryVersion)
val scala213 = "2.13.14"
val artifactBase = "mill-github-dependency-graph"
Expand Down Expand Up @@ -102,25 +102,31 @@ trait ItestCross extends Cross.Module[String] with MillIntegrationTestModule {

override def testInvocations: T[Seq[(PathRef, Seq[TestInvocation.Targets])]] =
T {
val env = if(millTestVersion() >= "0.12")
Map(
"COURSIER_REPOSITORIES" -> s"central sonatype:releases ivy:file://${T.dest.toString.replaceFirst("testInvocations", "test")}/ivyRepo/local/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
)
else
Map.empty[String, String]
Seq(
PathRef(testBase / "minimal") -> Seq(
TestInvocation.Targets(Seq("checkManifest"), noServer = true)
),
PathRef(testBase / "directRelationship") -> Seq(
TestInvocation.Targets(Seq("verify"), noServer = true)
),
PathRef(testBase / "eviction") -> Seq(
TestInvocation.Targets(Seq("verify"), noServer = true)
),
PathRef(testBase / "range") -> Seq(
TestInvocation.Targets(Seq("verify"), noServer = true)
),
PathRef(testBase / "reconciledRange") -> Seq(
TestInvocation.Targets(Seq("verify"), noServer = true)
),
PathRef(testBase / "cyclical") -> Seq(
TestInvocation.Targets(Seq("checkManifest"), noServer = true)
"minimal" -> "checkManifest",
"directRelationship" -> "verify",
"eviction" -> "verify",
"range" -> "verify",
"reconciledRange" -> "verify",
"cyclical" -> "checkManifest"
).filter {
// The reconciledRange test doesn't work under 0.12 atm
case ("reconciledRange", _) if millTestVersion() >= "0.12" => false
case _ => true
}.map { case (testName, testMethod) =>
PathRef(testBase / testName) -> Seq(
TestInvocation.Targets(
Seq(testMethod),
noServer = true,
env = env
)
)
)
}
}
}
3 changes: 2 additions & 1 deletion itest/src/cyclical/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ object overflow extends ScalaModule {
}

def checkManifest(ev: Evaluator) = T.command {
val expected = ujson.read(os.read(os.pwd / "manifests.json"))
val projectDir = sys.env.get("MILL_WORKSPACE_ROOT").map(os.Path(_)).getOrElse(os.pwd)
val expected = ujson.read(os.read(projectDir / "manifests.json"))

val manifestMapping = Graph.generate(ev)()

Expand Down
3 changes: 2 additions & 1 deletion itest/src/minimal/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ object minimal extends ScalaModule {
}

def checkManifest(ev: Evaluator) = T.command {
val expected = ujson.read(os.read(os.pwd / "manifests.json"))
val projectDir = sys.env.get("MILL_WORKSPACE_ROOT").map(os.Path(_)).getOrElse(os.pwd)
val expected = ujson.read(os.read(projectDir / "manifests.json"))

val manifestMapping = Graph.generate(ev)()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.kipp.mill.github.dependency.graph

object Graph extends GraphModule {

import Discover._
lazy val millDiscover: mill.define.Discover[this.type] =
mill.define.Discover[this.type]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.kipp.mill.github.dependency.graph

private[graph] object Discover {
implicit def millEvaluatorTokenReader =
implicit def millEvaluatorTokenReader
: mainargs.TokensReader[mill.eval.Evaluator] =
mill.main.TokenReaders.millEvaluatorTokenReader
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.kipp.mill.github.dependency.graph

import scala.annotation.nowarn

// In here for the Discover import
@nowarn("msg=Unused import")
object Graph extends GraphModule {

import Discover._
lazy val millDiscover: mill.define.Discover[this.type] =
mill.define.Discover[this.type]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.kipp.mill.github.dependency.graph

private[graph] object Discover {
implicit def millEvaluatorTokenReader
: mainargs.TokensReader[mill.eval.Evaluator] =
mill.main.TokenReaders.millEvaluatorTokenReader
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.kipp.mill.github.dependency.graph

import mill._

object Graph extends GraphModule {

import Discover._
lazy val millDiscover: mill.define.Discover =
mill.define.Discover[this.type]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.kipp.mill.github.dependency.graph

import coursier.graph.DependencyTree
import mill._
import mill.eval.Evaluator
import mill.scalalib.JavaModule
import mill.scalalib.Lib

/** Utils to help find all your modules and resolve their dependencies.
*/
object Resolver {

/** Given an evaluator and your javaModules, use coursier to resolve all of
* their dependencies into trees.
*
* @param evaluator Evaluator passed in from the command
* @param javaModules All the JavaModules to resolve dependencies from
* @return A collection of ModuleTrees
*/
private[graph] def resolveModuleTrees(
evaluator: Evaluator,
javaModules: Seq[JavaModule]
): Seq[ModuleTrees] = evaluator.evalOrThrow() {
javaModules.map { javaModule =>
T.task {

val deps =
javaModule.transitiveCompileIvyDeps() ++ javaModule
.transitiveIvyDeps()
val repos = javaModule.repositoriesTask()
val mapDeps = javaModule.mapDependencies()
val custom = javaModule.resolutionCustomizer()

val (dependencies, resolution) =
Lib.resolveDependenciesMetadata(
repositories = repos,
deps = deps,
mapDependencies = Some(mapDeps),
customizer = custom,
ctx = Some(T.log)
)

val trees =
DependencyTree(resolution = resolution, roots = dependencies)

ModuleTrees(
javaModule,
trees
)
}
}
}

private[graph] def computeModules(ev: Evaluator) =
ev.rootModule.millInternal.modules.collect { case j: JavaModule => j }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.annotation.nowarn

// In here for the Discover import
@nowarn("msg=Unused import")
object Graph extends ExternalModule {
trait GraphModule extends ExternalModule {

import Writers._

Expand All @@ -30,7 +30,4 @@ object Graph extends ExternalModule {
manifests
}

import Discover._
lazy val millDiscover: mill.define.Discover[this.type] =
mill.define.Discover[this.type]
}

0 comments on commit 0c56bb1

Please sign in to comment.