Skip to content

Commit

Permalink
version polacehold
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Nov 20, 2024
1 parent 33aa06d commit 2843192
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions integration/feature/bom/resources/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ object depMgmt extends JavaModule with TestPublishModule {
ivy"com.google.protobuf:protobuf-java:4.28.3"
)
}

object `version-placeholder` extends JavaModule with TestPublishModule {
def ivyDeps = Agg(
ivy"com.google.protobuf:protobuf-java:_"
)
override def dependencyManagement = Agg(
ivy"com.google.protobuf:protobuf-java:4.28.3"
)
}
5 changes: 1 addition & 4 deletions integration/feature/bom/src/BomTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ object BomTests extends UtestIntegrationTestSuite {
test("placeholder") - integrationTest { implicit tester =>
import tester._

compileClasspathContains("version-placeholder", expectedProtobufJarName)

val resolvedCp = publishLocalAndResolve("version-placeholder")
assert(resolvedCp.map(_.last).contains(expectedProtobufJarName))
isInClassPath("version-placeholder", expectedProtobufJarName)
}

test("override") - integrationTest { implicit tester =>
Expand Down
21 changes: 19 additions & 2 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,25 @@ trait JavaModule
val depMgmt = dependencyManagementDict()
if (depMgmt.isEmpty)
depsWithBoms
else
depsWithBoms.map(dep => dep.copy(dep = dep.dep.withOverrides(dep.dep.overrides ++ depMgmt)))
else {
lazy val depMgmtMap = depMgmt.toMap
depsWithBoms.map { dep =>
val versionOverride =
if (dep.dep.version == "_") {
val key = DependencyManagement.Key(
dep.dep.module.organization, dep.dep.module.name, coursier.core.Type.jar, dep.dep.publication.classifier
)
// FIXME Exclusions should be added too
depMgmtMap.get(key).map(_.version)
}
else None
dep.copy(
dep = dep.dep
.withOverrides(dep.dep.overrides ++ depMgmt)
.withVersion(versionOverride.getOrElse(dep.dep.version))
)
}
}
}

/**
Expand Down

0 comments on commit 2843192

Please sign in to comment.