Skip to content

Commit

Permalink
Use Wildcard When jvm_exclude Artifact is None (#20802)
Browse files Browse the repository at this point in the history
Fixes #20794

Update `to_coord_str` method to append `*` to the artifact coordinate
string when a `jvm_exclude` artifact is `None`.

---------

Co-authored-by: Nicholas Gustafson <nicholas.gustafson@rakuten.com>
  • Loading branch information
NGustafson and Nicholas Gustafson committed May 15, 2024
1 parent 8ba6ea2 commit 9e02d42
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/notes/2.22.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The default version of the [hikaru](https://github.com/haxsaw/hikaru) packages u
for [`jvm_artifacts`](https://www.pantsbuild.org/2.22/reference/targets/jvm_artifacts)
targets generator from `pom.xml`.

Exclusions for `jvm_artifact` and `scala_artifact` now correctly handle a `jvm_exclude` with only the group defined.

##### Scala

Setting the `orphan_files_behaviour = "ignore"` option for [`pants.backend.experimental.scala.lint.scalafix`](https://www.pantsbuild.org/2.22/reference/subsystems/scalafix#orphan_files_behavior) or [`pants.backend.experimental.scala.lint.scalafmt`](https://www.pantsbuild.org/2.22/reference/subsystems/scalafmt#orphan_files_behavior) backend is now properly silent. It previously showed spurious warnings.
Expand Down
25 changes: 24 additions & 1 deletion src/python/pants/jvm/resolve/coursier_fetch_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
from pants.jvm.resolve.coordinate import Coordinate, Coordinates
from pants.jvm.resolve.coursier_fetch import CoursierLockfileEntry, CoursierResolvedLockfile
from pants.jvm.resolve.coursier_fetch import rules as coursier_fetch_rules
from pants.jvm.target_types import JvmArtifactJarSourceField, JvmArtifactTarget
from pants.jvm.target_types import (
JvmArtifactExclusion,
JvmArtifactJarSourceField,
JvmArtifactTarget,
)
from pants.jvm.testutil import maybe_skip_jdk_test
from pants.jvm.util_rules import ExtractFileDigest
from pants.jvm.util_rules import rules as util_rules
Expand Down Expand Up @@ -662,6 +666,25 @@ def test_transitive_excludes(rule_runner: RuleRunner) -> None:
assert not any(i for i in entries if i.coord.artifact == "jackson-core")


@maybe_skip_jdk_test
def test_transitive_group_only_excludes(rule_runner: RuleRunner) -> None:
group_only_excludes = JvmArtifactExclusion(group="com.fasterxml.jackson.core", artifact=None)

requirement = ArtifactRequirement(
coordinate=Coordinate(
group="com.fasterxml.jackson.module",
artifact="jackson-module-jaxb-annotations",
version="2.17.1",
),
excludes=frozenset([group_only_excludes.to_coord_str()]),
)

resolve = rule_runner.request(CoursierResolvedLockfile, [ArtifactRequirements([requirement])])

entries = resolve.entries
assert not any(i for i in entries if i.coord.group == "com.fasterxml.jackson.core")


@maybe_skip_jdk_test
def test_missing_entry_for_transitive_dependency(rule_runner: RuleRunner) -> None:
requirement = ArtifactRequirement(
Expand Down
2 changes: 2 additions & 0 deletions src/python/pants/jvm/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def to_coord_str(self) -> str:
result = self.group
if self.artifact:
result += f":{self.artifact}"
else:
result += ":*"
return result


Expand Down

0 comments on commit 9e02d42

Please sign in to comment.