gradle-dependency-injection

Inject Gradle services into tasks, plugins, and extensions for configuration-cache-safe builds.

Updated Apr 8, 2026
One-click install
npx skills add https://github.com/ClankerGuru/opsx --skill gradle-dependency-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gradle-dependency-injection
Source: https://github.com/ClankerGuru/opsx/tree/main/cli/src/main/resources/content/skills/gradle-dependency-injection
Command: npx skills add https://github.com/ClankerGuru/opsx --skill gradle-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Gradle's DI container enables tasks, plugins, extensions, and build services to receive services like ExecOperations and ObjectFactory through injection. This eliminates the need to reach into the Project at execution time, improving configuration-cache compatibility and making builds more deterministic.

Core Features & Use Cases

  • @Inject-based injection: Inject core services into tasks and extensions to decouple code from the Project and promote CC-safe patterns.
  • Service catalog exposure: Provide access to common services (ObjectFactory, ProjectLayout, ExecOperations, FileSystemOperations, BuildService) across tasks and plugins to simplify configuration.
  • Build-service patterns: Use BuildService and related registries to share state and resources across a build in a safe, CC-friendly way.

Quick Start

Configure a simple Gradle task that receives ExecOperations via @Inject and uses it to run a shell command.

Frequently Asked Questions about gradle-dependency-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make Gradle tasks configuration-cache safe?

Use Gradle dependency injection to receive services like ExecOperations and ObjectFactory via @Inject. This decouples tasks from the Project and makes builds configuration-cache safe.

What is Gradle dependency injection used for?

Gradle dependency injection is used to provide services like ObjectFactory, ProjectLayout, and BuildService to tasks and plugins. It eliminates direct Project access, improving build determinism and configuration-cache compatibility.

How do I inject ExecOperations into a Gradle task?

Inject ExecOperations into a Gradle task using the @Inject annotation on an abstract property. This allows the task to run shell commands safely without violating configuration-cache requirements.

Does Gradle configuration cache support BuildService injection?

Yes, the Gradle configuration cache fully supports BuildService injection. Using BuildService registries allows you to share state and resources across tasks in a configuration-cache-friendly manner.

Why is accessing Project at execution time not configuration-cache safe?

Accessing the Project at execution time breaks configuration-cache compatibility because it introduces mutable state. Injecting core services instead enforces proper CC-safe usage and avoids unsafe system property access.