maven-build-lifecycle
Use when reproducing and repairing Maven CI build failures, especially legacy multi-module builds and Maven Invoker integration tests.
- 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, especially legacy multi-module builds and Maven Invoker integration tests.
03 SKILL.md 正文
Maven Build Lifecycle — Legacy CI Repair Workflow
Toolchain + failure reproduction (do this before editing)
cd /home/travis/build/failed/<repo>/<id>- Pick the build entrypoint consistently:
- If
./mvnwexists and.mvn/wrapper/maven-wrapper.jaris present, use./mvnw. - Otherwise use system Maven:
mvn.
- If
- Record the toolchain in your notes (
mvn -vandjava -version). This catches “works on JDK8 but not JDK11” class of failures early. - Reproduce using a CI-like lifecycle goal:
mvn -e verify(or./mvnw -e verify).- Prefer passing flags on the command line while diagnosing. Do not “fix” builds by committing
-o(offline mode) into.mvn/maven.config; it can introduce new resolution failures if artifacts are not already cached.
- Prefer passing flags on the command line while diagnosing. Do not “fix” builds by committing
Only after you have the first concrete failure should you change code/config. 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. Re-run the same mvn -e verify 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:
- 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(orgrep -RInifrgis unavailable)
- Update the POM so Java 9+ builds do not try to resolve
tools.jar:- Prefer removing the system-scoped
com.sun:toolsdependency when the build runs on a full JDK. - If Java 8 support is still needed, gate the
tools.jardependency 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.
- Prefer removing the system-scoped
- Re-run
mvn -e verifyto 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:
- Locate the exact integration-test POM named by the Invoker.
- Read the corresponding Invoker
build.logor the surrounding CI output. - Identify the first concrete compiler/test error inside that nested build.
- Inspect the nested POM's direct dependencies and versions.
- 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.jarsystem 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:
If the Invoker log shows missing Guava/Truth APIs, synchronize that functional-test POM as one coherent dependency repair rather than piecemeal edits:value/src/it/functional/pom.xmlcom.google.code.findbugs:jsr305->3.0.0(provided);junit:junit->4.12(test);- add a direct
com.google.guava:guava:19.0test 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:
- Write
/home/travis/build/failed/failed_reasons.txtwith: toolchain (mvn -v/java -version), the exact command used to reproduce, the first real error, and the minimal root cause. - 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. - Apply that patch to the failed repository (e.g.,
git apply patch_1.diff). - Check
git diff/git status, then rerun the same Maven command and ensure the original failure is gone (ideallyBUILD SUCCESS).
Minimal diagnostic sequence
cd /home/travis/build/failed/<repo>/<id>
# Reproduce with a CI-like lifecycle goal.
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
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms