Skip to content

Commit 720a8ad

Browse files
committed
Part 5 - use mill-moduledefs 0.11.0-M1 (with scala 3 port)
- clean up classpath, resolve scala-library
1 parent 061a9ba commit 720a8ad

File tree

8 files changed

+26
-98
lines changed

8 files changed

+26
-98
lines changed

build.mill

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,20 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
400400
else Seq("-P:acyclic:force")
401401
)
402402

403-
def scalacPluginIvyDeps =
403+
def scalacPluginIvyDeps = T {
404+
def sv = scalaVersion()
405+
def hasModuleDefs = sv.startsWith("2.13.") || sv.startsWith("3.")
404406
super.scalacPluginIvyDeps() ++
405-
Agg.when(!scalaVersion().startsWith("3."))(Deps.acyclic) ++
406-
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefsPlugin)
407+
Agg.when(!sv.startsWith("3."))(Deps.acyclic) ++
408+
Agg.when(hasModuleDefs)(Deps.millModuledefsPlugin)
409+
}
407410

408-
def mandatoryIvyDeps =
411+
def mandatoryIvyDeps = T {
412+
def sv = scalaVersion()
413+
def hasModuleDefs = sv.startsWith("2.13.") || sv.startsWith("3.")
409414
super.mandatoryIvyDeps() ++
410-
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefs)
415+
Agg.when(hasModuleDefs)(Deps.millModuledefs)
416+
}
411417

412418
/** Default tests module. */
413419
lazy val test: MillScalaTests = new MillScalaTests {}

contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ trait BuildInfo extends JavaModule {
3535
*/
3636
def buildInfoMembers: T[Seq[BuildInfo.Value]] = Seq.empty[BuildInfo.Value]
3737

38-
// TODO: remove override when mill-moduledefs is ported to Scala 3
39-
override def resources: T[Seq[PathRef]] =
38+
def resources: T[Seq[PathRef]] =
4039
if (buildInfoStaticCompiled) super.resources
4140
else Task.Sources { super.resources() ++ Seq(buildInfoResources()) }
4241

main/define/src/mill/moduledefs/Cacher.scala

Lines changed: 0 additions & 68 deletions
This file was deleted.

main/define/src/mill/moduledefs/Scaladoc.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

main/util/src/mill/util/Util.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ object Util {
7979
repositories: Seq[Repository],
8080
resolveFilter: os.Path => Boolean = _ => true,
8181
// this should correspond to the mill runtime Scala version
82-
artifactSuffix: String = "_2.13"
82+
artifactSuffix: String = "_3"
8383
): Result[Agg[PathRef]] = {
8484

8585
mill.util.Jvm.resolveDependencies(

runner/src/mill/runner/MillBuildRootModule.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ abstract class MillBuildRootModule()(implicit
222222
* We exclude them to avoid incompatible or duplicate artifacts on the classpath.
223223
*/
224224
protected def resolveDepsExclusions: T[Seq[(String, String)]] = Task {
225-
Lib.millAssemblyEmbeddedDeps.toSeq.map(d =>
226-
(d.dep.module.organization.value, d.dep.module.name.value)
225+
Lib.millAssemblyEmbeddedDeps.toSeq.flatMap(d =>
226+
if d.dep.module.name.value == "scala-library" && scalaVersion().startsWith("3.") then None
227+
else Some((d.dep.module.organization.value, d.dep.module.name.value))
227228
)
228229
}
229230

@@ -242,20 +243,21 @@ abstract class MillBuildRootModule()(implicit
242243
override def scalacOptions: T[Seq[String]] = Task {
243244
super.scalacOptions() ++
244245
Seq(
245-
"-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
246+
// "-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
246247
"-deprecation",
247248
// Make sure we abort of the plugin is not found, to ensure any
248249
// classpath/plugin-discovery issues are surfaced early rather than
249250
// after hours of debugging
250-
"-Xplugin-require:mill-linenumber-plugin"
251+
// "-Xplugin-require:mill-linenumber-plugin"
251252
)
252253
}
253254

254255
override def scalacPluginClasspath: T[Agg[PathRef]] =
255256
super.scalacPluginClasspath() ++ lineNumberPluginClasspath()
256257

257258
def lineNumberPluginClasspath: T[Agg[PathRef]] = Task {
258-
millProjectModule("mill-runner-linenumbers", repositoriesTask())
259+
// millProjectModule("mill-runner-linenumbers", repositoriesTask())
260+
Agg.empty
259261
}
260262

261263
/** Used in BSP IntelliJ, which can only work with directories */

scalalib/src/mill/scalalib/Dependency.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Dependency extends ExternalModule {
1616
Task.Command {
1717
DependencyUpdatesImpl(
1818
ev,
19-
???,// implicitly,
19+
implicitly,
2020
ev.rootModule,
2121
ev.rootModule.millDiscover,
2222
allowPreRelease

scalalib/src/mill/scalalib/JavaModule.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ trait JavaModule
9696
* If none is specified, the classpath is searched for an appropriate main
9797
* class to use if one exists
9898
*/
99-
override def mainClass: T[Option[String]] = None // TODO: remove override with mill-moduledefs
99+
def mainClass: T[Option[String]] = None
100100

101-
override def finalMainClassOpt: T[Either[String, String]] = Task { // TODO: remove override with mill-moduledefs
101+
def finalMainClassOpt: T[Either[String, String]] = Task {
102102
mainClass() match {
103103
case Some(m) => Right(m)
104104
case None =>
@@ -115,7 +115,7 @@ trait JavaModule
115115
}
116116
}
117117

118-
override def finalMainClass: T[String] = Task { // TODO: remove override with mill-moduledefs
118+
def finalMainClass: T[String] = Task {
119119
finalMainClassOpt() match {
120120
case Right(main) => Result.Success(main)
121121
case Left(msg) => Result.Failure(msg)
@@ -133,7 +133,7 @@ trait JavaModule
133133
* ivy"org::name:version" for Scala dependencies or ivy"org:name:version"
134134
* for Java dependencies
135135
*/
136-
override def ivyDeps: T[Agg[Dep]] = Task { Agg.empty[Dep] } // TODO: remove override with mill-moduledefs
136+
def ivyDeps: T[Agg[Dep]] = Task { Agg.empty[Dep] }
137137

138138
/**
139139
* Aggregation of mandatoryIvyDeps and ivyDeps.
@@ -369,8 +369,7 @@ trait JavaModule
369369
* The folders where the resource files for this module live.
370370
* If you need resources to be seen by the compiler, use [[compileResources]].
371371
*/
372-
// TODO: remove override when mill-moduledefs is ported to scala 3
373-
override def resources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "resources" }
372+
def resources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "resources" }
374373

375374
/**
376375
* The folders where the compile time resource files for this module live.

0 commit comments

Comments
 (0)