Gradle-mcp running_gradle_builds
install
source · Clone the upstream repo
git clone https://github.com/rnett/gradle-mcp
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/rnett/gradle-mcp "$T" && mkdir -p ~/.claude/skills && cp -r "$T/src/main/skills/running_gradle_builds" ~/.claude/skills/rnett-gradle-mcp-running-gradle-builds && rm -rf "$T"
manifest:
src/main/skills/running_gradle_builds/SKILL.mdsource content
Authoritative Gradle Build Execution & Orchestration
Executes Gradle builds with managed background orchestration and surgical failure diagnostics.
Constitution
- ALWAYS use the
tool instead ofgradle
via shell../gradlew - ALWAYS provide absolute paths for
.projectRoot - NEVER use
unless investigating project-wide cache-specific corruption; prioritize Gradle's native caching. Prefer--rerun-tasks
for individual tasks to ensure they are executed even if up-to-date.--rerun - ALWAYS prefer foreground execution (default) unless the task is persistent (e.g., servers) or extremely long-running (>2 minutes).
- ALWAYS use
when you need the isolated output of a specific task (e.g.,captureTaskOutput
,help
).dependencies - ALWAYS check the build dashboard (
) to manage active processes and historical results.inspect_build() - STRONGLY PREFERRED: Use
for all diagnostics. It is more token-efficient than reading raw console logs and provides structured access to failures.inspect_build - NEVER leave background builds running; use
to release resources when finished.stopBuildId
Surgical Inspection with inspect_build
inspect_buildThe
inspect_build tool is your primary window into build results. Use it to move from high-level summaries to deep-dive diagnostics.
1. Build Dashboard (No Arguments)
Call
inspect_build() without arguments to see the Build Dashboard. This shows active background builds and recently completed builds with their BuildId, status, and failure counts.
- Example:
inspect_build()
2. Build Summary
Provide a
buildId to get a summary of that specific build, including failures, problems, and test results. This summary also contains a guide on how to inspect specific details.
- Example:
inspect_build(buildId="ID")
3. Detailed Inspection (mode="details"
)
mode="details"To get exhaustive information, ALWAYS use
mode="details" combined with a specific target:
- Individual Tests:
,testName="FullTestName"
(REQUIRED for full output/stack trace).mode="details"- Prefix Support: Both
andtestName
support unique prefix matching. Providing a unique prefix (e.g.,taskPath
ortestName="com.example.MyTest"
) will automatically select the item if it's unambiguous.taskPath=":app:compile"
- Prefix Support: Both
- Task Outputs:
,taskPath=":path:to:task"
.mode="details" - Build Failures:
,failureId="ID"
(find IDs in the build summary).mode="details" - Problems/Errors:
,problemId="ID"
(find IDs in the build summary).mode="details" - Console Logs:
(last N lines) orconsoleTail=true
(first N lines).consoleTail=false
4. Progress Monitoring
Use
timeout, waitFor, or waitForTask to block until a condition is met in a background build.
- Example:
inspect_build(buildId="ID", timeout=60, waitFor="Started Application") - Wait for completion: If
is set without a wait condition (timeout
/waitFor
), the tool waits for the build to finish.waitForTask
5. Monitoring Test Progress
While a build is running, the progress notification (and the
inspect_build summary) provides real-time counts of passed, failed, and skipped tests. This gives immediate feedback on the health of the test suite.
- Example: Call
repeatedly to see updated test counts:inspect_build(buildId="ID", mode="summary")
.(5 passed, 1 failed)
Directives
- ALWAYS use foreground for authoritative builds: If you intend to wait for a result, ALWAYS use foreground execution. It provides superior progressive disclosure and simpler control flow than starting a background build only to
immediately call
.inspect_build(timeout=...) - Background ONLY for persistent tasks: Use
ONLY for tasks that must remain active (e.g.,background: true
,bootRun
builds) or when you explicitly intend to perform independent research while the build proceeds.continuous - Monitor with
: Useinspect_build
to check the status of background builds or to perform deep-dives into any historical build started by the server.inspect_build - Provide absolute
: ProvideprojectRoot
as an absolute file system path to all Gradle MCP tools. Relative paths are not supported.projectRoot - Manage resources via dashboard: Frequently call
without arguments to view the build dashboard and ensure no orphaned background builds are consuming system resources.inspect_build
Authoritative Task Path Syntax
Gradle utilizes two primary ways to identify tasks from the command line. Precision here prevents running redundant tasks in multi-project builds.
1. Task Selectors (Recursive Execution)
Providing a task name without a leading colon (e.g.,
test, build) acts as a selector. Gradle will execute that task in every project (root and all subprojects) that contains a task with that name.
- Example:
-> Executesgradle(commandLine=["test"])
in all projects.test
2. Absolute Task Paths (Targeted Execution)
Providing a task path with a leading colon (e.g.,
:test, :app:test) targets a single specific project.
- Root Project Only: Use a single leading colon.
- Example:
-> Executesgradle(commandLine=[":test"])
in the root project ONLY.test
- Example:
- Subproject Only: Use the subproject name(s) separated by colons.
- Example:
-> Executesgradle(commandLine=[":app:test"])
in the 'app' subproject ONLY.test
- Example:
When to Use
- Core Lifecycle Execution: When you need to execute standard Gradle tasks like
,build
, orassemble
with maximum reliability and clean, parseable output.clean - Persistent Development Processes: When starting development servers (e.g.,
) or continuous builds where background management and real-time log monitoring are required.bootRun - Surgical Build Troubleshooting: When a build has failed and you need to perform deep-dive analysis of task failures or console logs using the
diagnostic suite. For test failures, ALWAYS useinspect_build
withtestName
.mode="details" - Task-Specific Information Retrieval: When you need to extract isolated output from a single task (like
orhelp
) without the noise of the full build log.properties
Workflows
Running a Foreground Build
- Identify the task(s) to run (e.g.,
).["clean", "build"] - Call
with thegradle
.commandLine - If the build fails, the tool will return a high-signal failure summary. Use
with theinspect_build
for deeper diagnostics.buildId
Orchestrating Background Jobs
- Start the build with
to receive abackground: true
.BuildId - Use
to block until a specific state or log pattern is reached.inspect_build(buildId=ID, timeout=..., waitFor=...) - Call
(no arguments) to manage active jobs in the dashboard.inspect_build() - Stop the job using
once its utility is complete.gradle(stopBuildId=ID)
Examples
Run build in all projects
{ "commandLine": ["build"] } // Reasoning: Using a task selector to verify build health across the entire multi-project structure.
Run test only in a specific subproject
{ "commandLine": [":app:test"] } // Reasoning: Using an absolute path to target a specific module, minimizing execution time and context usage.
Inspect Help Output for a Specific Task
{ "commandLine": [":app:help", "--task", "test"], "captureTaskOutput": ":app:help" } // Reasoning: Using captureTaskOutput to retrieve clean, isolated documentation for the 'test' task without Gradle's general console noise.
Start a Dev Server and Wait for Readiness
// 1. Start the server in the background { "commandLine": [":app:bootRun"], "background": true } // Response: { "buildId": "build_123" } // 2. Wait for the 'Started Application' log pattern { "buildId": "build_123", "timeout": 60, "waitFor": "Started Application" } // Reasoning: Using background orchestration to allow the server to remain active while waiting for a specific readiness signal.
Troubleshooting
- Build Not Found: If a
is not recognized, it may have expired from the recent history cache. Check the dashboard (BuildId
) for valid active and historical IDs.inspect_build() - Task Output Not Captured: Ensure the path provided to
matches exactly one of the tasks in thecaptureTaskOutput
.commandLine - Missing environment variables: Set
if Gradle cannot find expected env vars (e.g.,invocationArguments: { envSource: "SHELL" }
).JAVA_HOME