Direct answer
A Gradle variant is one consumable face of a component, and attributes are the properties a consumer request and a producer variant carry so Gradle can tell them apart. Before changing a dependency notation, read what the consumer requests, list which producer variants are eligible, and confirm the selected artifact type. The concrete win is a build that selects the intended jar or bundle on purpose instead of by accident. The concrete loss is that a matching variant is a build-time selection, not proof the artifact behaves correctly at runtime. The practical implication is that every dependency notation change needs the intended variant written down first, because a notation that resolves is not the same as the notation that was meant. Ask Claude Code to print the consumer attributes, the eligible producer variants, and the reason one was selected.
Why a wrong variant costs a build cycle
Attributes are invisible in a one-line dependency declaration. A notation that names only a group, module and version says nothing about which variant should arrive, so the selection is decided by the consumer’s configuration and the producer’s attributes. Two builds with the same declaration can resolve different artifacts when their attribute requests differ.
The cost shows up as a classpath that has the wrong jar, a missing sources artifact in an IDE, or a test fixture that never appears where a test expects it. None of these are resolution failures. The graph resolves cleanly and the wrong thing is selected, which is harder to notice than an error.
Evidence and its limits
Official, F027: The Gradle variant model describes matching a consumer’s request to a producer variant through attributes and compatibility rules. The variant pages were not full-page fetched in the research pass, so recheck current terminology and examples before drafting.
Official: The page on variant attributes documents attributes as the mechanism consumers and producers use to describe what they want and what they offer.
Official: Platforms describes platforms as components that carry dependency and version constraints, which interact with variant selection when a platform is consumed.
Official: Declaring dependencies documents the notation forms referenced below.
Official, agent loop: Claude Code best practices recommends pairing an edit with a pass-or-fail check. For variant work that check is a variant report.
Derived, F028: The consumer request inventory and the artifact-type matrix below are an editorial checklist. They do not guarantee runtime compatibility.
No claim here depends on a Gradle release number, a plugin version, or any benchmark.
Consumers and producer variants
A producer component can expose several variants: an API variant, a runtime variant, a sources variant, a test-fixtures variant, and so on. Each variant carries attributes that describe it. A consumer configuration also carries attributes that describe what it wants. Gradle compares the two sets and selects the eligible variant.
| Role | Carries | Example | Decides |
|---|---|---|---|
| Consumer configuration | Requested attributes | A runtime classpath requesting a JVM runtime usage | Which producer variants are eligible |
| Producer variant | Provided attributes | A variant offering a jar for runtime usage | Whether it matches the request |
| Compatibility rule | Relationship between request and offer | A rule that treats a higher Java version as compatible | Whether a near-miss still resolves |
| Artifact | The file a variant publishes | A jar, an aar, a zip of sources | What actually lands on the classpath |
The distinction that trips review is the difference between an attribute and a version. Attributes do not carry version numbers. They describe shape and intent.
Read requested attributes
Start from the consumer side. The attributes a configuration requests are set by the plugin that created it, not by the dependency line.
./gradlew :app:dependencies --configuration runtimeClasspath./gradlew :app:resolveDebugVariantDependenciesRecord three things for the consumer: which configuration you are resolving, which attributes it requests, and which artifact type you expect to see on the classpath. The expected artifact type is the part teams skip and later regret. A request that resolves to a jar when an aar was intended is a selection that succeeded against the wrong target.
Compare producer attributes
With the request recorded, list what each candidate variant offers. The producer’s attributes either match, are compatible under a rule, or are disqualified.
| Producer variant | Usage attribute | Category | Artifact type | Eligible for a runtime request |
|---|---|---|---|---|
apiElements |
JVM runtime API | library | jar | Only via a compatibility rule |
runtimeElements |
JVM runtime | library | jar | Yes |
sourcesElements |
documentation | sources | jar of sources | No |
testFixturesElements |
JVM runtime test-fixtures | library | jar | No |
debugRuntimeElements |
Android runtime, debug | library | aar | Only for an Android request |
A request that matches a sources variant is the classic mistake. The sources artifact is a real jar, resolution succeeds, and the classpath contains files that were never meant to run.
Inspect compatibility rules
Compatibility and disambiguation rules sit between the request and the offer. A compatibility rule can declare a near-miss acceptable, such as a producer built for a slightly different Java target. Disambiguation rules break ties when more than one variant is eligible.
Two review questions follow. Which rules apply to the attributes in play, and would removing a rule change the selection. A rule that quietly widens compatibility is a decision, and it deserves the same review as a version constraint.
Ask Claude Code to name the rules it relied on when proposing a notation change. A proposal that changes selection without naming the rule that allowed it is incomplete.
Check artifact type
The artifact is the end of the chain and the easiest thing to verify. After a notation change, confirm the selected file is the type the consumer expected.
| Expected use | Expected artifact type | Common wrong selection | Symptom |
|---|---|---|---|
| Application runtime | jar or aar per platform | sources jar | Compile succeeds, classes missing at run |
| Test fixtures | fixtures jar | main jar | Fixture classes not found |
| Annotation processor | processor jar | api jar | Processor not invoked |
| Platform consumption | Gradle module metadata | plain pom | Constraints not applied |
An artifact-type mismatch is a selection defect even when the build is green. The variant report is the evidence that the right file was selected.
Review JVM ecosystem conventions
JVM ecosystem conventions give attributes their common values. The Java plugin sets usage attributes for API and runtime configurations. Android variants carry a build-type attribute. Test fixtures carry their own usage. Knowing the convention is what lets a reviewer spot a request that contradicts it.
Read conventions as defaults to verify, not rules to trust. A project that overrides an attribute for a local reason can produce a selection that surprises a new contributor. Record any override next to the notation that depends on it, because the override is the context a future reader will lack.
Explain the variant match
A notation change is complete when a reviewer can answer four questions from the change description.
| Question | Where the answer lives | Pass condition |
|---|---|---|
| What the consumer requests | Consumer attribute list | Recorded per configuration |
| Which variants were eligible | Producer variant comparison | Listed with artifact types |
| Why one was selected | Rule or exact-match explanation | Named explicitly |
| What artifact landed | Variant report output | Matches expected type |
Ask Claude Code to produce all four before editing the notation. The Gradle capability conflicts guide covers what happens when two components claim the same capability, and the Gradle constraints guide covers version policy without graph edges.
A worked walkthrough of one match
Suppose a test module needs a library’s test fixtures. The declaration in the test module is a plain notation naming only the group, module, and version. Configure succeeds, the fixtures classes are missing, and the failure appears at test compile as unresolved symbols.
The instinctive edit is a version change, which is the wrong axis. Fixtures are a variant selected by attributes, so the review starts with the consumer request.
Read the test module’s configuration attributes and compare them against the library’s variants. The main runtime variant offers a usage of JVM runtime and a category of library. The fixtures variant offers a usage of JVM runtime test-fixtures. The test module’s configuration that should receive fixtures does not request the fixtures usage, so the main variant wins and the fixtures jar never lands.
The fix is on the consumer side, not in the notation’s version.
configurations {
testFixturesClasspath {
extendsFrom(testImplementation)
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
}
}
}Run the variant report for the affected configuration and confirm the selected artifact is the fixtures jar rather than the main jar. The report names the selected variant and its artifact, which is the evidence the intended file landed. A build that compiles against the main jar instead would still resolve cleanly, which is exactly why the artifact type check matters.
Record the consumer request and the selected variant in the change description. A reviewer reading the request, the eligible variants, and the report can tell whether the edit does what the author meant without reproducing the selection.
Anti-patterns that look like variant fixes
Four patterns recur around attribute work, and each one hides a decision a reviewer needs to see.
| Pattern | What it looks like | Why it hurts | Do instead |
|---|---|---|---|
| Version bump for a variant problem | Raising the version to change selection | Attributes, not versions, select variants | Fix the attribute request |
| Undocumented attribute override | A local attribute set to make resolution work | Surprises the next contributor | Record the override next to the notation |
| Accepting a sources jar | Resolution succeeds with a sources artifact | Wrong file on the classpath | Check the artifact type in the report |
| Widening a compatibility rule | Loosening a rule to make a near-miss resolve | Silent behavior change | Name the rule and review it |
The compatibility rule is the subtlest. A rule that treats a near-miss as compatible is a decision, and loosening it to unblock a build is a decision nobody made deliberately. Ask which rule allowed the selection and whether removing it would change the outcome.
None of these is a Gradle defect. They are review hazards, and the consumer request plus the variant report are what catch them.
A runbook for the next notation change
The checklist earlier in this post is the pass condition. The runbook below is the sequence to follow before changing a dependency notation.
Record which configuration resolves the dependency and which attributes that configuration requests. The request is the review key, and a notation change without one is a guess about which variant should arrive.
List the producer’s variants with their attributes and artifact types. Note which ones are eligible for the request and which rule, if any, made a near-miss eligible.
Decide the intended artifact type. A request that resolves a sources jar when the runtime jar was meant is a defect even when the build is green.
Run the variant report and confirm the selected artifact matches the intended type. Paste the report excerpt into the change description.
Record any attribute override the project carries for this coordinate, because the override is the context a future reader will lack when the selection surprises them.
The runbook takes minutes and produces the two artifacts a reviewer needs: the consumer request and the variant report. Skipping it produces a one-line change that resolves the wrong file and looks finished.
Where this habit pays across the batch
The request-first habit in this post is the same one the rest of the batch applies to different constructs. Gradle constraints vs dependencies asks for a resolved-graph diff before a version change, and Gradle capability conflicts asks for a component inventory before a resolution strategy. Maven optional dependencies asks for an import scan before a declaration.
The .NET posts apply the same discipline to package versions and generated code. NuGet central package management asks for a props and override inventory before centralizing, and .NET multi-targeting asks for a per-framework build before calling a version supported. C# source generators asks for the generator’s input change before reading its output.
The C++ posts apply it to configure inputs and dependency boundaries. CMake presets asks for the resolved preset inputs before a configure, CMake find_package vs FetchContent asks for a resolution trace before choosing a path, and Conan CMakeDeps asks for the target contract before a layout change.
That consistency is deliberate. The constructs differ, but the shape is the same: read the evidence the tool already produces, then make the smallest change the evidence supports.
The same shape extends to the ecosystems covered in earlier batches. On the Python side, dependency groups versus extras separates local workflow requirements from published optional features, and stub drift audits a package’s declared types against its documented runtime surface. TypedDict boundaries covers separating truly optional keys from missing data before replacing broad dictionary annotations.
On the Go side, module compatibility covers keeping an exported API change inside an import contract, and graph pruning covers why an indirect dependency entry is graph metadata rather than something to delete. Workspace boundaries covers deciding what belongs in go.work versus what stays a module requirement.
On the Rust side, feature unification covers mapping which optional APIs a workspace build actually exposes, and workspace inheritance covers centralizing metadata without hiding crate-local exceptions. Profile boundaries covers separating diagnostic and optimization settings from options that change observable program behavior.
Variant selection has a direct analog in Cargo feature unification, where the same “which surface does this build expose” question applies to features rather than variants. Both are selection questions, and both reward recording the request before predicting the result.
Reading a variant report without guessing
The variant report is the evidence that settles a selection question, and it is worth reading deliberately rather than scanning for a green line. Three parts of the output carry the review.
The selected variant name tells you which face of the component won. Compare it against the variant you intended. A match is the pass condition.
The requested attributes section shows what the consumer asked for. Read it against the attributes you recorded in the inventory, because a request that differs from the recorded one is a configuration change someone made without updating the record.
The artifact listing shows what actually landed on the classpath, including its type. This is the line that catches a sources jar selected in place of a runtime jar, and it is the line a green build does not show you.
| Report section | What it answers | What green does not show |
|---|---|---|
| Selected variant | Which face won | Whether it was the intended face |
| Requested attributes | What the consumer asked for | Whether the request matches the record |
| Artifact listing | What file landed | The artifact type |
A report read this way turns a selection from an assumption into evidence. The same three sections answer the question in the walkthrough above, and they are the artifact to paste into a change description.
Working alongside the review bottleneck
A notation change with a pasted variant report is cheap to review. A change described as “pointed at the right variant” is a reviewer reproducing the work, and reproduction is the expensive part. The Claude Code code review bottleneck covers what happens when generation outpaces the review that has to accept it.
The same reasoning appears in Claude Code cost per verified change, which treats verified work as a separate unit from generated output. A variant report is a verified unit. A “trust me, it selects the right artifact” description is not.
When the review queue is long enough that verification slips, the failure mode is a merge that nobody actually checked. Prevent false success from passing tests covers the case where a green build is the only evidence, and a variant selection is exactly the case where green proves less than it appears to.
The concrete win, loss, and implication
The concrete win is a dependency change where the intended variant is explicit. A reviewer reading the consumer request, the eligible variants and the artifact type can tell whether the edit does what the author meant, without re-deriving the selection from a build failure.
The concrete loss is the gap between selection and behavior. A variant report proves the intended file was chosen. It does not prove the artifact works in the consumer’s runtime, and it does not cover every configuration a project resolves. Those checks are separate work.
The practical implication is that variant selection is a compatibility decision, not a version-number shortcut. Teams that record the consumer request before editing notation resolve fewer “why is this jar here” questions. Teams that edit notation and read the result afterward spend the difference in build cycles.
Related reading on selection and ownership
Selection questions continue across ecosystems. Maven optional dependencies covers which optional libraries a consumer must declare directly. NuGet central package management covers which central version wins, and .NET multi-targeting covers per-framework package versions.
For C++ builds, CMake presets covers making configure inputs explicit, CMake find_package vs FetchContent covers choosing a dependency boundary, and Conan CMakeDeps covers keeping consumer target names stable.
Review and verification habits sit upstream of every notation change. Ask what Claude Code verification requires before calling a selection change done, and prevent false success from passing tests when a green build is the only evidence. A change that reformats build files alongside the selection fix is the pattern the Claude Code overengineering guide warns about.
Checklist before changing a dependency notation
Run this list against the diff. Each row is a pass condition.
| Check | Pass condition | If it fails |
|---|---|---|
| Consumer request | Attributes recorded per configuration | Record the request first |
| Eligible variants | Listed with artifact types | Compare producer variants |
| Selection reason | Exact match or named rule | Name the rule or fix the request |
| Artifact type | Matches the expected use | Correct the request |
| Conventions | No undocumented attribute override | Record the override |
| Variant report | Output pasted into the change | Run the report task |
Working with Claude Code on variant selection
Give the agent the consumer configuration, the expected artifact type, and the dependency whose notation is in question. Ask for the consumer attributes and the eligible producer variants before any edit. The agent session works best when the check is a variant report that returns the selected artifact type.
Ask the agent to report three things when it finishes. The consumer attributes it read. The eligible variants and the reason one was selected, including any rule. The variant report excerpt showing the artifact type that landed. A report that omits the artifact type has not finished, because a selection that resolves the wrong file is still a defect.
Reviewing the intended variant is the reviewer’s job. The agent reads attributes and can run the report, but deciding which artifact the consumer should receive is a design decision. The Claude Code verification guide covers the review questions: what changed, what proves it, and what was not checked.
Data gap and future update
F027 and F028 rest on variant pages that were not full-page fetched in the research pass, so exact attribute names, rule names and DSL forms should be rechecked against current Gradle documentation before a real change. A future update should record, per project, which attributes are overridden and which configurations resolve artifacts of an unusual type.
No benchmark, build-time measurement, or runtime compatibility claim is made here. Whether a selected artifact behaves correctly is out of scope and requires executed evidence.
One AI API Key option for OpenAI-format agents
Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.
OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. It is a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility notes before choosing an agent route, or read the quickstart for the request shape.
FAQ
Are attributes the same as version numbers?
No. Attributes describe what a variant offers and what a consumer wants, such as usage, category and target platform. Version selection is a separate mechanism covered by version constraints and conflict resolution.
Why did resolution pick a sources jar?
Because the consumer request matched that variant under the applicable rules. Resolution succeeded and the wrong file was selected. Check the artifact type in the variant report and correct the consumer request.
Do I need to set attributes on my own components?
Only if something consumes them with an attribute request. The plugins you apply set default attributes for the configurations they create. Overrides are the thing to record, because they are the context a future reader will lack.
Does a matching variant prove runtime compatibility?
No. Variant matching is a build-time selection. A jar that is selected correctly can still fail at runtime, and proving behavior requires executed checks rather than a dependency report.
What is the fastest check after a notation change?
The variant report for the affected configuration. It names the selected variant and its artifact, which is the evidence the intended file landed on the classpath.
Related reading in this batch
This post is one of ten build-system and dependency guides written together. Gradle Constraints vs Dependencies and Gradle Capability Conflicts cover the two neighboring resolution questions. Maven Optional Dependencies covers the consumer side of optional libraries.
The .NET posts cover version and generated-code boundaries: NuGet Central Package Management, .NET Multi-Targeting, and C# Source Generators.
The C++ posts cover build inputs and dependency boundaries: CMake Presets, CMake find_package vs FetchContent, and Conan CMakeDeps.
More from this batch
- Gradle Constraints vs Dependencies: Fix Resolution Without Adding Edges
- Gradle Capability Conflicts: Resolve Competing Components With Claude Code
- Maven Optional Dependencies: Keep Transitive Expectations Explicit
- CMake find_package vs FetchContent: Choose a Dependency Boundary
- Conan CMakeDeps: Keep Consumer Targets Stable for Claude Code
More Claude Code troubleshooting
- Python Protocols vs ABCs: Preserve Interface Contracts With Claude Code
- Cargo Build Scripts: Define Generated-Artifact Contracts for Claude Code
- pnpm Peer Diagnostics: Read Resolution Reports Before Claude Code Pins
- TypeScript Project References: A Claude Code Boundary Guide
- OpenAPI Generator Customization: Keep Templates and Config in Sync
- GraphQL Code Generator Client Presets: Review Generated Boundaries
- Protocol Buffer Reserved Fields: A Claude Code Wire Compatibility Guide
- sqlc Query Annotations: Align SQL and Generated Types With Claude Code
- Django Deprecation Runway: Plan Framework Maintenance With Claude Code
- Rails Upgrade Sequence: Order Major Changes With Claude Code
- Angular Update Guide: Build a Migration Plan With Claude Code
Sources
- Official: Gradle: Variant Model, supporting F027 on consumer-to-producer matching through attributes and rules.
- Official: Gradle: Variant Attributes, attributes as the description mechanism.
- Official: Gradle: Platforms, platforms and their interaction with selection.
- Official: Gradle: Declaring Dependencies, notation forms.
- Official: Claude Code Docs: Best Practices, supporting the pass-or-fail variant report check.