Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using "_" to mean empty version / version to read in BOM #4082

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object Deps {
val asmTree = ivy"org.ow2.asm:asm-tree:9.7.1"
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"

val coursierVersion = "2.1.20"
val coursierVersion = "2.1.21"
val coursier = ivy"io.get-coursier::coursier:$coursierVersion"
val coursierInterface = ivy"io.get-coursier:interface:1.0.26"
val coursierJvm = ivy"io.get-coursier::coursier-jvm:$coursierVersion"
Expand Down
10 changes: 5 additions & 5 deletions scalalib/src/mill/scalalib/CoursierModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ object CoursierModule {
/**
* Processes dependencies and BOMs with coursier
*
* This makes coursier read and process BOM dependencies, and fill version placeholders
* This makes coursier read and process BOM dependencies, and fill empty versions
* in dependencies with the BOMs.
*
* Note that this doesn't throw when a version placeholder cannot be filled, and just leaves
* the placeholder behind.
* Note that this doesn't throw when an empty version cannot be filled, and just leaves
* the empty version behind.
*
* @param deps dependencies that might have placeholder versions ("_" as version)
* @param deps dependencies that might have empty versions
* @param resolutionParams coursier resolution parameters
* @return dependencies with version placeholder filled
* @return dependencies with empty version filled
*/
def processDeps[T: CoursierModule.Resolvable](
deps: IterableOnce[T],
Expand Down
4 changes: 2 additions & 2 deletions scalalib/src/mill/scalalib/Dep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ object Dep {
}

(module.split(':') match {
case Array(a, b) => Dep(a, b, "_", cross = empty(platformed = false))
case Array(a, "", b) => Dep(a, b, "_", cross = Binary(platformed = false))
case Array(a, b) => Dep(a, b, "", cross = empty(platformed = false))
case Array(a, "", b) => Dep(a, b, "", cross = Binary(platformed = false))
case Array(a, b, c) => Dep(a, b, c, cross = empty(platformed = false))
case Array(a, b, "", c) => Dep(a, b, c, cross = empty(platformed = true))
case Array(a, "", b, c) => Dep(a, b, c, cross = Binary(platformed = false))
Expand Down
6 changes: 3 additions & 3 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ trait JavaModule
dep.publication.classifier
)
val versionOverrideOpt =
if (dep.version == "_") depMgmtMap.get(depMgmtKey).map(_.version).filter(_.nonEmpty)
if (dep.version.isEmpty)
depMgmtMap.get(depMgmtKey).map(_.version).filter(_.nonEmpty)
else None
val extraExclusions = depMgmtMap.get(depMgmtKey).map(_.minimizedExclusions)
dep
Expand Down Expand Up @@ -270,8 +271,7 @@ trait JavaModule
)
val values = DependencyManagement.Values(
Configuration.empty,
if (depMgmt.version == "_") "" // shouldn't be needed with future coursier versions
else depMgmt.version,
depMgmt.version,
depMgmt.minimizedExclusions,
depMgmt.optional
)
Expand Down
4 changes: 2 additions & 2 deletions scalalib/src/mill/scalalib/PublishModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ trait PublishModule extends JavaModule { outer =>
def ivy: T[PathRef] = Task {
val (rootDepVersions, bomDepMgmt) = bomDetails()
val publishXmlDeps0 = publishXmlDeps().map { dep =>
if (dep.artifact.version == "_")
if (dep.artifact.version.isEmpty)
dep.copy(
artifact = dep.artifact.copy(
version = rootDepVersions.getOrElse(
Expand All @@ -168,7 +168,7 @@ trait PublishModule extends JavaModule { outer =>
depManagement().toSeq
.map(bindDependency())
.map(_.dep)
.filter(depMgmt => depMgmt.version.nonEmpty && depMgmt.version != "_")
.filter(_.version.nonEmpty)
)
val entries = coursier.core.DependencyManagement.add(
Map.empty,
Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/publish/Pom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ object Pom {
val optional = if (d.optional) <optional>true</optional> else NodeSeq.Empty

val version =
if (d.artifact.version == "_") NodeSeq.Empty
if (d.artifact.version.isEmpty) NodeSeq.Empty
else <version>{d.artifact.version}</version>

if (d.exclusions.isEmpty)
Expand Down
2 changes: 1 addition & 1 deletion scalalib/test/src/mill/scalalib/BomTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ object BomTests extends TestSuite {
val res = eval(modules.bom.placeholder.check.compileClasspath)
assert(
res.left.exists(_.toString.contains(
"not found: https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/_/protobuf-java-_.pom"
"not found: https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java//protobuf-java-.pom"
))
)
}
Expand Down
Loading