clankerguru/opsx/gradle-providers-properties
Claude Code and agent skill by clankerguru/opsx
- community
Checking that the SKILL.md file is still in the repository.
Gradle lazy API — Provider, Property, ListProperty, file properties, conventions, finalization, providers from external sources.
Install
npx vskill@latest install clankerguru/opsx/gradle-providers-propertiesSKILL.md
The same SKILL.md was published earlier as clankerguru/opsx/gradle-providers-properties.
Gradle Providers & Properties — Lazy Configuration
Gradle's lazy API is how modern plugins wire values. Provider<T> is the read-only view; Property<T> is the writable cell. Everything (task inputs, extension fields, plugin outputs) flows through these so Gradle can delay evaluation, enforce input declarations, and serialise the configuration cache.
Source:
- https://docs.gradle.org/current/userguide/lazy_configuration.html
- https://docs.gradle.org/current/userguide/properties_providers.html
1. Mental model
Eager assignment:
Lazy wiring:
The second form never realises jar at configuration time. It resolves on demand, during execution, and plays well with the configuration cache.
Rule of thumb: if you're writing .get() during configuration, you're doing it wrong unless you're writing a test assertion.
2. Type hierarchy
| Type | Read? | Write? | Backing | |
|---|---|---|---|---|
Provider<T> | yes | no | any computation | |
Property<T> | yes | yes | single value | |
ListProperty<T> | yes | yes | ordered list | |
SetProperty<T> | yes | yes | unordered set | |
MapProperty<K,V> | yes | yes | keyed map | |
RegularFileProperty | yes | yes | RegularFile | |
DirectoryProperty | yes | yes | Directory | |
ConfigurableFileCollection | yes | yes | file collection |
All extend Provider<T> (or Provider<Collection<T>>) — a Property<String> IS a Provider<String>.
3. Provider<T> methods
map/flatMap/zip return new providers — nothing is computed until something calls get().
4. Property<T> additions
Ordering matters:
set(...)overridesconvention(...).convention(...)afterset(...)is ignored — the explicit set wins.- This asymmetry is what lets a plugin supply a default that a user can override without the plugin clobbering back.
5. Collection properties
MapProperty<K,V>:
6. File properties
Setting:
Deriving:
ConfigurableFileCollection.from(...) accepts: File, Path, String, FileCollection, Task / TaskProvider (uses its outputs), or a Provider<...> of any of those. Order matters for @Classpath.
7. ObjectFactory
Creates managed instances. Inject via @Inject:
For an abstract class with abstract val, Gradle injects these automatically — ObjectFactory is only needed when you want to call newInstance(...) to compose nested types.
8. ProviderFactory — providers from external sources
Inject @Inject ProviderFactory or access via project.providers.
These are configuration-cache-safe: Gradle serialises the source (the env var name, the file path) and re-reads on cache hit.
Do NOT do this:
9. layout — project/build paths
Always prefer layout.buildDirectory.dir(...) over file("$buildDir/...") — the latter uses the deprecated buildDir getter and breaks custom build directories.
10. Wiring across tasks
When a task's input is a provider derived from another task's output, Gradle infers dependsOn automatically — no need to declare it.
11. zip and map vs flatMap
map { T -> U }— pure transform.flatMap { T -> Provider<U> }— flatten; use when the transform itself produces a provider.zip(Provider<U>) { t, u -> ... }— combine two providers.
Chains compose — you can build complex pipelines without triggering configuration.
12. Finalisation and safety
Finalisation is how a plugin author says "after I read this, you can't change it." This is what Gradle's own task properties use internally — once a task starts executing, its inputs are frozen.
| Method | Effect | |
|---|---|---|
finalizeValue() | Freezes now. | |
finalizeValueOnRead() | Freezes on next get(). | |
disallowChanges() | set(...) fails from now on; provider wiring preserved. |
13. Configuration-cache implications
The CC serialises task state between builds. All Property/Provider values must be:
- Serialisable (primitives, strings,
File, other providers). - Computed from tracked sources (use
providers.gradleProperty, notSystem.getenv). - Free of
Projectreferences at execution time.
Things that break CC:
task.project.property("x")indoLast→ use@Input+ a providers chain.- Capturing
projectin a lambda stored on a task. providers.execwithout declaring it as an input if its output changes — Gradle tracks the provider source, not the command result, unless you write the result to an input.
14. Kotlin DSL sugar
The assignment form works when the Kotlin DSL accessor exposes value as var — which abstract Property<T> does when the plugin defines it that way. For plain extension fields it's just a var.
15. Anti-patterns
.get()at configuration time — defeats laziness; use.map/.flatMapand wire to a task input.Property<File>— useRegularFileProperty.- Setting a property from
System.getenvorSystem.getProperty— invisible to CC; useproviders.environmentVariable/systemProperty. - Storing values in a
valfield and using them in a task action — breaks CC; wrap in aProviderand declare as@Input. - Passing a
ListProperty<File>— useConfigurableFileCollectionfor files. convention(...)thenset(...)in the same plugin code — you're just overwriting; drop the convention.- Reading
buildDir/project.buildDir— deprecated; uselayout.buildDirectory.
16. Cheat sheet
17. Sub-skill cross-reference
- Task input/output annotations →
/gradle-tasks - Plugin extensions using Property →
/gradle-custom-plugins - Services injected via
@Inject→/gradle-dependency-injection
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcli/src/main/resources/content/skills/gradle-providers-properties/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/clankerguru/opsx/gradle-providers-properties)