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

Use Wildcard When jvm_exclude Artifact is None #20802

Merged
merged 3 commits into from
May 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/notes/2.22.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ docs [here](https://www.pantsbuild.org/2.22/docs/sql).
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