Skip to content

Commit

Permalink
Merge pull request #84 from eed3si9n/wip/direct
Browse files Browse the repository at this point in the history
Make direct forced win over transitives
  • Loading branch information
eed3si9n authored May 19, 2021
2 parents ae58318 + 201a01b commit 6db5552
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ final case class ResolutionIndex(
mutable.LinkedHashSet.empty
)
val extractedVersion = thirdparty.versionExtractorByModule(d.module)(d.version)
val version = VersionConfig(d.version, Version(extractedVersion), config.force)
val direct = config.coursierModule(thirdparty.scala) == d.module
// weaken the transitive dependencies
val version = VersionConfig(d.version, Version(extractedVersion), config.force && direct)
buf += d -> version
}
result
Expand Down
33 changes: 9 additions & 24 deletions tests/src/test/scala/tests/commands/ExportCommandSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,7 @@ class ExportCommandSuite extends tests.BaseSuite with tests.ConfigSyntax {
| versionScheme: pvp
| - dependency: com.lihaoyi:pprint_2.12:0.5.9
|${scalaLibrary("MyApp.scala", "object MyApp { val x = 42 }")}
|""".stripMargin,
arguments = exportCommand :+ "--no-fail-on-evicted-declared",
expectedOutput = """|/workingDirectory/3rdparty.yaml:3:16 warning: Declared third party dependency 'com.lihaoyi:fansi_2.12:0.2.8' is evicted in favor of 'com.lihaoyi:fansi_2.12:0.2.9'.
|Update the third party declaration to use version '0.2.9' instead of '0.2.8' to reflect the effective dependency graph.
| - dependency: com.lihaoyi:fansi_2.12:0.2.8
| ^
|/workingDirectory/3rdparty.yaml:5:16 warning: Declared third party dependency 'com.lihaoyi:sourcecode_2.12:0.2.0' is evicted in favor of 'com.lihaoyi:sourcecode_2.12:0.2.1'.
|Update the third party declaration to use version '0.2.1' instead of '0.2.0' to reflect the effective dependency graph.
| - dependency: com.lihaoyi:sourcecode_2.12:0.2.0
| ^
|warning: 2 declared dependencies were evicted.
|""".stripMargin + defaultExpectedOutput
|""".stripMargin
)

checkDeps(
Expand Down Expand Up @@ -608,19 +597,15 @@ class ExportCommandSuite extends tests.BaseSuite with tests.ConfigSyntax {
)

checkDeps(
"report evicted declared dependencies",
"direct force wins over higher transitive dependencies",
deps(
dep("org.apache.thrift:libthrift:0.10.0")
.target("libthrift"),
dep("org.slf4j:slf4j-api:1.7.10")
.target("slf4j")
),
expectedExit = 1,
expectedOutput =
"""|/workingDirectory/3rdparty.yaml:14:16 error: Declared third party dependency 'org.slf4j:slf4j-api:1.7.10' is evicted in favor of 'org.slf4j:slf4j-api:1.7.12'.
|Update the third party declaration to use version '1.7.12' instead of '1.7.10' to reflect the effective dependency graph.
| - dependency: org.slf4j:slf4j-api:1.7.10
| ^""".stripMargin
dep("com.google.cloud:pubsublite-kafka:0.1.1")
.target("pubsublite-kafka")
.force(true),
dep("com.fasterxml.jackson.core:jackson-core:2.11.0")
.target("jackson-core")
.force(true)
)
)

checkDeps(
Expand Down

0 comments on commit 6db5552

Please sign in to comment.