Skip to content

Commit d85280a

Browse files
committed
WIP 42 - clean up classpath where plugins are unavailable, resolve scala-library
1 parent abebd6f commit d85280a

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

main/api/src/mill/api/Result.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ object Result {
7676
def map[V](f: T => V): Failure[V] = Result.Failure(msg, value.map(f(_)))
7777
def flatMap[V](f: T => Result[V]): Failure[V] =
7878
Failure(msg, value.flatMap(f(_).asSuccess.map(_.value)))
79+
80+
override def getMessage(): String = msg
7981
}
8082

8183
/**

runner/src/mill/runner/MillBuildRootModule.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ class MillBuildRootModule()(implicit
9191
Agg.from(
9292
MillIvy.processMillIvyDepSignature(parseBuildFiles().ivyDeps)
9393
.map(mill.scalalib.Dep.parse)
94-
) ++
95-
Agg(ivy"com.lihaoyi::mill-moduledefs:${Versions.millModuledefsVersion}")
94+
) /*++
95+
Agg(ivy"com.lihaoyi::mill-moduledefs:${Versions.millModuledefsVersion}")*/
9696
}
9797

9898
override def runIvyDeps = T {
@@ -219,8 +219,9 @@ class MillBuildRootModule()(implicit
219219
* We exclude them to avoid incompatible or duplicate artifacts on the classpath.
220220
*/
221221
protected def resolveDepsExclusions: T[Seq[(String, String)]] = T {
222-
Lib.millAssemblyEmbeddedDeps.toSeq.map(d =>
223-
(d.dep.module.organization.value, d.dep.module.name.value)
222+
Lib.millAssemblyEmbeddedDeps.toSeq.flatMap(d =>
223+
if d.dep.module.name.value == "scala-library" && scalaVersion().startsWith("3.") then None
224+
else Some((d.dep.module.organization.value, d.dep.module.name.value))
224225
)
225226
}
226227

@@ -233,26 +234,27 @@ class MillBuildRootModule()(implicit
233234
}
234235

235236
override def scalacPluginIvyDeps: T[Agg[Dep]] = Agg(
236-
ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${Versions.millModuledefsVersion}"
237+
// ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${Versions.millModuledefsVersion}"
237238
)
238239

239240
override def scalacOptions: T[Seq[String]] = T {
240241
super.scalacOptions() ++
241242
Seq(
242-
"-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
243+
// "-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
243244
"-deprecation",
244245
// Make sure we abort of the plugin is not found, to ensure any
245246
// classpath/plugin-discovery issues are surfaced early rather than
246247
// after hours of debugging
247-
"-Xplugin-require:mill-linenumber-plugin"
248+
// "-Xplugin-require:mill-linenumber-plugin"
248249
)
249250
}
250251

251252
override def scalacPluginClasspath: T[Agg[PathRef]] =
252253
super.scalacPluginClasspath() ++ lineNumberPluginClasspath()
253254

254255
def lineNumberPluginClasspath: T[Agg[PathRef]] = T {
255-
millProjectModule("mill-runner-linenumbers", repositoriesTask())
256+
// millProjectModule("mill-runner-linenumbers", repositoriesTask())
257+
Agg.empty
256258
}
257259

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

scalalib/src/mill/scalalib/CoursierModule.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import coursier.cache.FileCache
44
import coursier.{Dependency, Repository, Resolve}
55
import coursier.core.Resolution
66
import mill.T
7+
import mill.api.Result
78
import mill.define.Task
89
import mill.api.PathRef
910

@@ -137,6 +138,15 @@ object CoursierModule {
137138
deps: IterableOnce[T],
138139
sources: Boolean = false
139140
): Agg[PathRef] = {
141+
// TODO: `getOrThrow` swallows error messages when Failure is returned.
142+
// so I introduced resolveDeps0 where it makes sense to propagate the error message
143+
resolveDeps0(deps, sources).getOrThrow
144+
}
145+
146+
def resolveDeps0[T: CoursierModule.Resolvable](
147+
deps: IterableOnce[T],
148+
sources: Boolean = false
149+
): Result[Agg[PathRef]] = {
140150
Lib.resolveDependencies(
141151
repositories = repositories,
142152
deps = deps.map(implicitly[CoursierModule.Resolvable[T]].bind(_, bind)),
@@ -145,7 +155,7 @@ object CoursierModule {
145155
customizer = customizer,
146156
coursierCacheCustomizer = coursierCacheCustomizer,
147157
ctx = ctx
148-
).getOrThrow
158+
)
149159
}
150160
}
151161

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
T.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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ trait JavaModule
533533
* Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]].
534534
*/
535535
def resolvedIvyDeps: T[Agg[PathRef]] = T {
536-
defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps())
536+
defaultResolver().resolveDeps0(transitiveCompileIvyDeps() ++ transitiveIvyDeps())
537537
}
538538

539539
/**
@@ -545,7 +545,7 @@ trait JavaModule
545545
}
546546

547547
def resolvedRunIvyDeps: T[Agg[PathRef]] = T {
548-
defaultResolver().resolveDeps(runIvyDeps().map(bindDependency()) ++ transitiveIvyDeps())
548+
defaultResolver().resolveDeps0(runIvyDeps().map(bindDependency()) ++ transitiveIvyDeps())
549549
}
550550

551551
/**

scalalib/src/mill/scalalib/ScalaModule.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer =>
259259
* Classpath of the Scala Compiler & any compiler plugins
260260
*/
261261
def scalaCompilerClasspath: T[Agg[PathRef]] = T {
262-
defaultResolver().resolveDeps(
262+
defaultResolver().resolveDeps0(
263263
Lib.scalaCompilerIvyDeps(scalaOrganization(), scalaVersion()) ++
264264
scalaLibraryIvyDeps()
265265
)

scalalib/src/mill/scalalib/ZincWorkerModule.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object ZincWorkerModule extends ExternalModule with ZincWorkerModule with Coursi
2424
trait ZincWorkerModule extends mill.Module with OfflineSupportModule { self: CoursierModule =>
2525

2626
def classpath: T[Agg[PathRef]] = T {
27-
millProjectModule("mill-scalalib-worker", repositoriesTask())
27+
millProjectModule("mill-scalalib-worker", repositoriesTask(), artifactSuffix = "_3")
2828
}
2929

3030
def scalalibClasspath: T[Agg[PathRef]] = T {

0 commit comments

Comments
 (0)