AGENT SKILL

maven-build-lifecycle

Use when reproducing and repairing Maven CI build failures (legacy multi-module + Maven Invoker), while producing the required benchmark artifacts: `/home/travis/build/failed/failed_reasons.txt` and `/home/travis/build/failed/<repo>/<id>/patch_*.diff`.

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 0
Forks
1

01 前言 Front Matter

name
maven-build-lifecycle
description
Use when reproducing and repairing Maven CI build failures (legacy multi-module + Maven Invoker), while producing the required benchmark artifacts: `/home/travis/build/failed/failed_reasons.txt` and `/home/travis/build/failed/<repo>/<id>/patch_*.diff`.

03 SKILL.md 正文

Maven Build Lifecycle — Legacy CI Repair Workflow

Toolchain + failure reproduction (do this before editing)

  1. Resolve the concrete checkout directory under /home/travis/build/failed and cd into the checkout root (the leaf directory under /home/travis/build/failed/... where you will write patch_*.diff):
    • ls -la /home/travis/build/failed
    • ls -la /home/travis/build/failed/<repo-or-org> (e.g. google)
    • ls -la /home/travis/build/failed/<repo-or-org>/<repo-or-id> (e.g. auto)
    • If there is one more leaf directory level (often the <id>), ls -la /home/travis/build/failed/<repo-or-org>/<repo-or-id>/<id> then cd into it; otherwise cd /home/travis/build/failed/<repo-or-org>/<repo-or-id>.
    • From the directory you cd into, confirm where the reactor/root pom.xml lives:
      • If pom.xml is in the checkout root, use it.
      • If not, locate it without guessing: find . -maxdepth 4 -name pom.xml -print and choose the root/aggregator pom.xml (usually the one closest to the checkout root). Either cd into that directory, or plan to run Maven with -f path/to/root/pom.xml.
    • Record the absolute checkout path (pwd) because patch_*.diff must be written inside this directory (per benchmark path contract).
  2. Pick the Maven entrypoint consistently (use the same one for -v, builds, and re-runs):
    • If ./mvnw exists (in the checkout root), run chmod +x ./mvnw and use ./mvnw.
    • Otherwise use system Maven: mvn.
  3. Create/update /home/travis/build/failed/failed_reasons.txt before attempting fixes (so the artifact exists from the start) and record the toolchain + context:
    • repo path (pwd)
    • Maven info (./mvnw -v or mvn -v)
    • Java info (java -version)
  4. Reproduce the failure using the project’s CI build command when possible:
    • First look for the Maven goals/profiles in .travis.yml, .github/workflows/*.yml, Jenkinsfile, or README; use that command as your reproduction command.
    • If no CI command is discoverable, default to a CI-like lifecycle goal: ./mvnw -e verify (or mvn -e verify; add -f <path/to/root/pom.xml> if the root POM is not in the checkout root).
    • After the run, immediately add to /home/travis/build/failed/failed_reasons.txt:
      • the exact command used,
      • the first concrete failure (copy the relevant log excerpt),
      • whether it’s code vs build config,
      • your minimal fix plan.
    • Prefer passing flags on the command line while diagnosing. If Maven fails to transfer from remote repos (e.g., HTTP 403/401/timeouts) and a seeded cache exists at /home/travis/.m2/repository, try -Dmaven.repo.local=/home/travis/.m2/repository to confirm it’s an environment/repo-local issue; only use -o after verifying required artifacts are already present.

Only after you have the first concrete failure should you change code/config (and as you edit, keep the change as a git diff you’ll save to patch_1.diff). Avoid broad edits (e.g., removing parents, upgrading unrelated dependencies) until you can tie them directly to that first failure.

If Maven fails before compilation/tests: fix dependency resolution first

If the log fails during dependency resolution (no compilation has started yet), stop and repair the specific POM/dependency/plugin configuration causing that resolution error.

For transfer failures (HTTP 403/401/timeouts), first check whether the “missing” coordinates already exist under /home/travis/.m2/repository and whether Maven is using a different local repo; if pointing Maven at the seeded cache via -Dmaven.repo.local=/home/travis/.m2/repository fixes it, make that change reproducible (e.g., add it to .mvn/maven.config) and include it in your patch.

Re-run the same Maven command you used to reproduce afterward to ensure you moved past the original failure.

Java 9+ compatibility: tools.jar / com.sun:tools system dependency

If you see an error like:

Could not find artifact com.sun:tools:jar:… at specified path …/lib/tools.jar

that’s almost always a Java 9+ incompatibility: tools.jar existed in JDK 8 but was removed starting Java 9, so any <scope>system</scope> dependency pointing at ${java.home}/../lib/tools.jar will break on Java 11+.

Repair workflow:

  1. Locate the declaration(s) by copying the coordinates/path from the Maven error and searching (avoid hand-typed guesses):
    • rg -n "com\.sun:tools|tools\.jar" pom.xml **/pom.xml (or grep -RIn if rg is unavailable)
  2. Update the POM so Java 9+ builds do not try to resolve tools.jar:
    • Prefer removing the system-scoped com.sun:tools dependency when the build runs on a full JDK.
    • If Java 8 support is still needed, gate the tools.jar dependency behind a JDK-8-only Maven profile (e.g., activate only for [1.8,1.9)), so Java 11 doesn’t attempt to resolve it.
  3. Re-run the same Maven command you used to reproduce to confirm dependency resolution proceeds past the original error.

Maven Invoker failures: debug the nested project, not just the reactor

maven-invoker-plugin can launch independent Maven builds from files such as src/it/*/pom.xml. Those nested builds have their own dependency mediation and can fail even when the parent module's normal unit tests pass.

If Maven reports output similar to:

The following builds failed:
*  functional/pom.xml

then:

  1. Locate the exact integration-test POM named by the Invoker.
  2. Read the corresponding Invoker build.log or the surrounding CI output.
  3. Identify the first concrete compiler/test error inside that nested build.
  4. Inspect the nested POM's direct dependencies and versions.
  5. Repair the nested dependency/configuration drift instead of broad-editing unrelated top-level modules.

Do not assume versions declared in the parent module automatically govern an Invoker integration-test POM. An integration-test POM copied or synchronized separately can become stale.

Missing library classes usually indicate dependency-version drift

For a compiler error such as:

cannot find symbol: class MoreObjects
location: package com.google.common.base

first ask which Guava version the failing nested build actually selected. MoreObjects is an API-version signal: a stale/transitively selected Guava can make valid test source fail even though the main reactor uses a newer Guava.

For test libraries that are designed to be version-coupled (for example guava and guava-testlib), prefer an explicit, synchronized dependency set. Do not "fix" valid source by rewriting it to avoid the missing API unless the source itself is demonstrated to be wrong.

Repository-specific checkpoint: Google Auto / AutoValue

In this Google Auto snapshot, common CI breakages tend to be:

  • Early failure on Java 11+: com.sun:tools / tools.jar system dependency in a root/module POM (fix using the Java 9+ workflow above).
  • Later Invoker failure (only after the main build runs far enough to execute Invoker): AutoValue functional integration test rooted at:
    value/src/it/functional/pom.xml
    
    If the Invoker log shows missing Guava/Truth APIs, synchronize that functional-test POM as one coherent dependency repair rather than piecemeal edits:
    • com.google.code.findbugs:jsr305 -> 3.0.0 (provided);
    • junit:junit -> 4.12 (test);
    • add a direct com.google.guava:guava:19.0 test dependency;
    • com.google.guava:guava-testlib -> 19.0 (test);
    • com.google.truth:truth -> 0.28 (test).

Build-repair artifact contract

This benchmark requires both a diagnosis artifact and an applicable patch. Before finishing:

  1. Ensure /home/travis/build/failed/failed_reasons.txt exists and includes: toolchain (mvn -v/java -version), the exact command used to reproduce, the first real error, and the minimal root cause + plan.
  2. Create at least one non-empty standard unified diff at /home/travis/build/failed/<repo>/<id>/patch_1.diff (or higher {i}) containing the intended source/configuration change:
    • Make the edit(s), then (from the checkout root) generate the patch artifact in its own shell invocation: git diff > patch_1.diff
    • Confirm the benchmark artifact is present and non-empty: test -s patch_1.diff
  3. Apply that patch to the failed repository (e.g., from the checkout root: git apply patch_1.diff). If you generated the patch from local edits, you can make the diff the source-of-truth by doing: git reset --hard (keeps patch_1.diff) → git apply patch_1.diff.
  4. Check git diff/git status, then rerun the same Maven command and ensure the original failure is gone (ideally BUILD SUCCESS).

Minimal diagnostic sequence

# Locate the checkout (example org/repo layout).
ls -la /home/travis/build/failed
ls -la /home/travis/build/failed/<org>
ls -la /home/travis/build/failed/<org>/<repo>
cd /home/travis/build/failed/<org>/<repo>/<id>

# Reproduce with a CI-like lifecycle goal (use ./mvnw if present).
mvn -e verify

# If you see a tools.jar/com.sun:tools resolution error, locate it in POMs.
rg -n "com\.sun:tools|tools\.jar" pom.xml **/pom.xml

# If Invoker reports a failing src/it POM, inspect that nested POM + build logs.
sed -n '1,220p' value/src/it/functional/pom.xml
find . -path '*target/it*' -name build.log -print

General Maven lifecycle reminders

  • In multi-module projects, use the reactor summary to identify the first genuinely failing module, then inspect that module's own integration steps.

04 同仓库更多 Skills