Skip to content

Handle Gradle metadata pom-only artifacts#1575

Draft
shs96c wants to merge 2 commits into
bazel-contrib:masterfrom
shs96c:shs/gradle-gmm-pom-only-artifacts
Draft

Handle Gradle metadata pom-only artifacts#1575
shs96c wants to merge 2 commits into
bazel-contrib:masterfrom
shs96c:shs/gradle-gmm-pom-only-artifacts

Conversation

@shs96c

@shs96c shs96c commented May 19, 2026

Copy link
Copy Markdown
Collaborator

🤖 Generated by my AI agent.

Why

Gradle metadata can resolve a component as a metadata wrapper without a binary artifact for that coordinate. The resolver should not hash a POM as that binary, and lockfile materialization should not emit deps to targets that were never resolved.

What

  • Treat known POM paths for non-POM coordinates as no-binary wrapper targets
  • Skip missing artifact entries during resolved-artifact hash calculation with warnings
  • Filter lockfile materialization deps to artifact keys that can produce targets
  • Add Java resolver/downloader tests and Starlark v3 lockfile unit tests

Risk Assessment

Medium — this changes Gradle resolver lockfile handling for unusual metadata-only or platform-specific artifacts, but the behavior is covered by focused tests and only removes invalid target edges.

References

  • Targeted tests: bazel test --java_runtime_version=remotejdk_17 //tests/com/github/bazelbuild/rules_jvm_external/resolver/gradle:GradleResolverTest //tests/com/github/bazelbuild/rules_jvm_external/resolver/maven:DownloaderTest //tests/com/github/bazelbuild/rules_jvm_external/resolver/lockfile:V3LockFileTest //tests/unit:v3_lock_file_tests_test_0 //tests/unit:v3_lock_file_tests_test_1

Generated with Codex

shs96c and others added 2 commits June 9, 2026 13:02
Replace the `Map<Coordinates, Path>` side-channel on `ResolutionResult`
with a `Map<Coordinates, ResolvedArtifact>` that has an entry for every
node in the resolved graph. Each `ResolvedArtifact` holds its coordinates
and an optional path, so "this node has no known binary" is represented
explicitly rather than inferred from an absent map entry.

This is a pure refactoring: the Maven and Gradle resolvers populate the
new shape from exactly the information they already had, the downloader
still receives the same set of known paths, and the lock file, its
format, and the resolved-artifact hashes are all unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A Gradle Module Metadata "umbrella" coordinate (and likewise a
`<packaging>pom</packaging>` aggregator or an `available-at` redirect)
publishes a POM but no binary of its own. The Gradle resolver's path
fallback used to associate such a node's POM with it as if the POM were
the module's JAR, so the downloader hashed the POM in the JAR's place
and the lock file recorded a bogus artifact hash.

Decide "no binary" upstream in the resolver instead: a node whose only
file is a POM is recorded as an aggregator on its ResolvedArtifact, and
any stale POM path is dropped so it is never handed to the downloader.
The downloader honours the explicit aggregator signal by returning a
binary-less result -- keeping the POM's repositories so the lock file
can still locate the coordinate -- rather than throwing
UriNotFoundException. An empty path alone cannot carry this meaning
because Maven reports empty paths for everything it still has to fetch,
so the signal must be explicit.

Builds on "refactor: carry a ResolvedArtifact for every resolution node".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@shs96c
shs96c force-pushed the shs/gradle-gmm-pom-only-artifacts branch from afcd86b to 8cfae04 Compare June 9, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant