Skip to content

Commit 31b494b

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

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
@@ -75,6 +75,8 @@ object Result {
7575
def map[V](f: T => V): Failure[V] = Result.Failure(msg, value.map(f(_)))
7676
def flatMap[V](f: T => Result[V]): Failure[V] =
7777
Failure(msg, value.flatMap(f(_).asSuccess.map(_.value)))
78+
79+
override def getMessage(): String = msg
7880
}
7981

8082
/**

runner/src/mill/runner/MillBuildRootModule.scala

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

103103
override def runIvyDeps = T {
@@ -232,8 +232,9 @@ class MillBuildRootModule()(implicit
232232
* We exclude them to avoid incompatible or duplicate artifacts on the classpath.
233233
*/
234234
protected def resolveDepsExclusions: T[Seq[(String, String)]] = T {
235-
Lib.millAssemblyEmbeddedDeps.toSeq.map(d =>
236-
(d.dep.module.organization.value, d.dep.module.name.value)
235+
Lib.millAssemblyEmbeddedDeps.toSeq.flatMap(d =>
236+
if d.dep.module.name.value == "scala-library" && scalaVersion().startsWith("3.") then None
237+
else Some((d.dep.module.organization.value, d.dep.module.name.value))
237238
)
238239
}
239240

@@ -246,26 +247,27 @@ class MillBuildRootModule()(implicit
246247
}
247248

248249
override def scalacPluginIvyDeps: T[Agg[Dep]] = Agg(
249-
ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${Versions.millModuledefsVersion}"
250+
// ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${Versions.millModuledefsVersion}"
250251
)
251252

252253
override def scalacOptions: T[Seq[String]] = T {
253254
super.scalacOptions() ++
254255
Seq(
255-
"-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
256+
// "-Xplugin:" + lineNumberPluginClasspath().map(_.path).mkString(","),
256257
"-deprecation",
257258
// Make sure we abort of the plugin is not found, to ensure any
258259
// classpath/plugin-discovery issues are surfaced early rather than
259260
// after hours of debugging
260-
"-Xplugin-require:mill-linenumber-plugin"
261+
// "-Xplugin-require:mill-linenumber-plugin"
261262
)
262263
}
263264

264265
override def scalacPluginClasspath: T[Agg[PathRef]] =
265266
super.scalacPluginClasspath() ++ lineNumberPluginClasspath()
266267

267268
def lineNumberPluginClasspath: T[Agg[PathRef]] = T {
268-
millProjectModule("mill-runner-linenumbers", repositoriesTask())
269+
// millProjectModule("mill-runner-linenumbers", repositoriesTask())
270+
Agg.empty
269271
}
270272

271273
/** 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.rootModules.head,
2121
ev.rootModules.head.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)