Skip to content

Commit

Permalink
Rename JavaModule#bomDeps to bomIvyDeps (#4081)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Dec 7, 2024
1 parent 3f504c0 commit 7f1b618
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Pass an external BOM to a `JavaModule` / `ScalaModule` / `KotlinModule` with `bomDeps`, like
// Pass an external BOM to a `JavaModule` / `ScalaModule` / `KotlinModule` with `bomIvyDeps`, like

//// SNIPPET:BUILD1
package build
import mill._, javalib._

object foo extends JavaModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.cloud:libraries-bom:26.50.0"
)
def ivyDeps = Agg(
Expand All @@ -20,6 +20,6 @@ object foo extends JavaModule {
// But the BOM specifies another version for that dependency, `4.28.3`, so
// protobuf-java `4.28.3` ends up being pulled here.
//
// Several BOMs can be passed to `bomDeps`. If several specify a version for a dependency,
// the version from the first one in the `bomDeps` list is used. If several specify exclusions
// Several BOMs can be passed to `bomIvyDeps`. If several specify a version for a dependency,
// the version from the first one in the `bomIvyDeps` list is used. If several specify exclusions
// for a dependency, all exclusions are added to that dependency.
10 changes: 5 additions & 5 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ trait JavaModule
* Any BOM dependencies you want to add to this Module, in the format
* ivy"org:name:version"
*/
def bomDeps: T[Agg[Dep]] = Task { Agg.empty[Dep] }
def bomIvyDeps: T[Agg[Dep]] = Task { Agg.empty[Dep] }

def allBomDeps: Task[Agg[BomDependency]] = Task.Anon {
val modVerOrMalformed =
bomDeps().map(bindDependency()).map { bomDep =>
bomIvyDeps().map(bindDependency()).map { bomDep =>
val fromModVer = coursier.core.Dependency(bomDep.dep.module, bomDep.dep.version)
if (fromModVer == bomDep.dep)
Right(bomDep.dep.asBomDependency)
Expand Down Expand Up @@ -210,7 +210,7 @@ trait JavaModule
def depManagement: T[Agg[Dep]] = Task { Agg.empty[Dep] }

private def addBoms(
bomDeps: Seq[coursier.core.BomDependency],
bomIvyDeps: Seq[coursier.core.BomDependency],
depMgmt: Seq[(DependencyManagement.Key, DependencyManagement.Values)],
overrideVersions: Boolean
): coursier.core.Dependency => coursier.core.Dependency = {
Expand All @@ -229,8 +229,8 @@ trait JavaModule
dep
// add BOM coordinates - coursier will handle the rest
.addBomDependencies(
if (overrideVersions) bomDeps.map(_.withForceOverrideVersions(overrideVersions))
else bomDeps
if (overrideVersions) bomIvyDeps.map(_.withForceOverrideVersions(overrideVersions))
else bomIvyDeps
)
// add dependency management ourselves:
// - overrides meant to apply to transitive dependencies
Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/PublishModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ trait PublishModule extends JavaModule { outer =>
* BOM dependency to specify in the POM
*/
def publishXmlBomDeps: Task[Agg[Dependency]] = Task.Anon {
bomDeps().map(resolvePublishDependency.apply().apply(_))
bomIvyDeps().map(resolvePublishDependency.apply().apply(_))
}

/**
Expand Down
18 changes: 9 additions & 9 deletions scalalib/test/src/mill/scalalib/BomTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object BomTests extends TestSuite {
object modules extends TestBaseModule {
object bom extends Module {
object placeholder extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.cloud:libraries-bom:26.50.0"
)
def ivyDeps = Agg(
Expand All @@ -51,7 +51,7 @@ object BomTests extends TestSuite {
}

object versionOverride extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.cloud:libraries-bom:26.50.0"
)
def ivyDeps = Agg(
Expand Down Expand Up @@ -79,7 +79,7 @@ object BomTests extends TestSuite {

object invalid extends TestBaseModule {
object exclude extends JavaModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.cloud:libraries-bom:26.50.0".exclude(("foo", "thing"))
)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ object BomTests extends TestSuite {

object precedence extends Module {
object higher extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.protobuf:protobuf-bom:4.28.1"
)
def depManagement = Agg(
Expand All @@ -185,7 +185,7 @@ object BomTests extends TestSuite {
}

object higherTransitive extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.protobuf:protobuf-bom:4.28.1"
)
def depManagement = Agg(
Expand All @@ -198,7 +198,7 @@ object BomTests extends TestSuite {
}

object lower extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.protobuf:protobuf-bom:4.28.1"
)
def depManagement = Agg(
Expand All @@ -211,7 +211,7 @@ object BomTests extends TestSuite {
}

object lowerTransitive extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.protobuf:protobuf-bom:4.28.1"
)
def depManagement = Agg(
Expand All @@ -224,7 +224,7 @@ object BomTests extends TestSuite {
}

object addExclude extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.protobuf:protobuf-bom:4.28.3"
)
def depManagement = Agg(
Expand Down Expand Up @@ -278,7 +278,7 @@ object BomTests extends TestSuite {
)

object dependee extends JavaModule with TestPublishModule {
def bomDeps = Agg(
def bomIvyDeps = Agg(
ivy"com.google.cloud:libraries-bom:26.50.0"
)
def moduleDeps = Seq(bomOnModuleDependency)
Expand Down

0 comments on commit 7f1b618

Please sign in to comment.