Skip to content

Commit

Permalink
Add doc, plus fixes / guards
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Dec 18, 2024
1 parent 1a8a3d2 commit c6c8a7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
7 changes: 7 additions & 0 deletions main/util/src/mill/util/CoursierSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ trait CoursierSupport {
ctx.fold(cache)(c => cache.withLogger(new TickerResolutionLogger(c)))
}

/**
* A `coursier.Repository` that exposes modules with hard-coded artifact list
*
* Used in Mill tests. This exposes internal workers for example, so that these
* come from the build and not from remote repositories or ~/.ivy2/local. See
* `MillJavaModule#{testTransitiveDeps,writeLocalTestOverrides}` in the Mill build.
*/
private class TestOverridesRepo(root: os.ResourcePath) extends Repository {

private def listFor(mod: Module): Either[os.ResourceNotFoundException, String] = {
Expand Down
23 changes: 12 additions & 11 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,10 @@ trait JavaModule
// We pull their compile scope when our compile scope is asked,
// and pull their runtime scope when our runtime scope is asked.
Seq(
(cs.Configuration.compile, modDep.coursierDependency),
(
cs.Configuration.compile,
modDep.coursierDependency.withConfiguration(cs.Configuration.compile)
),
(
cs.Configuration.runtime,
modDep.coursierDependency.withConfiguration(cs.Configuration.runtime)
Expand All @@ -481,17 +484,17 @@ trait JavaModule
compileModuleDepsChecked.map { modDep =>
// Compile-only (aka provided) dependencies
// We pull their compile scope when our provided scope is asked (see scopes above)
(cs.Configuration.provided, modDep.coursierDependency)
(
cs.Configuration.provided,
modDep.coursierDependency.withConfiguration(cs.Configuration.compile)
)
} ++
runModuleDepsChecked.map { modDep =>
// Runtime dependencies
// We pull their runtime scope when our runtime scope is pulled
(
cs.Configuration.runtime,
modDep.coursierDependency.withConfiguration(
if (modDep.coursierDependency.configuration.isEmpty) cs.Configuration.runtime
else modDep.coursierDependency.configuration
)
modDep.coursierDependency.withConfiguration(cs.Configuration.runtime)
)
}

Expand All @@ -502,23 +505,21 @@ trait JavaModule
// We pull their compile scope when our compile scope is asked,
// and pull their runtime scope when our runtime scope is asked.
Seq(
(cs.Configuration.compile, dep),
(cs.Configuration.compile, dep.withConfiguration(cs.Configuration.compile)),
(cs.Configuration.runtime, dep.withConfiguration(cs.Configuration.runtime))
)
} ++
compileIvyDeps().map(bindDependency()).map(_.dep).map { dep =>
// Compile-only (aka provided) dependencies, like above
// We pull their compile scope when our provided scope is asked (see scopes above)
(cs.Configuration.provided, dep)
(cs.Configuration.provided, dep.withConfiguration(cs.Configuration.compile))
} ++
runIvyDeps().map(bindDependency()).map(_.dep).map { dep =>
// Runtime dependencies, like above
// We pull their runtime scope when our runtime scope is pulled
(
cs.Configuration.runtime,
dep.withConfiguration(
if (dep.configuration.isEmpty) cs.Configuration.runtime else dep.configuration
)
dep.withConfiguration(cs.Configuration.runtime)
)
} ++
allBomDeps().map { bomDep =>
Expand Down

0 comments on commit c6c8a7e

Please sign in to comment.