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 正文
Steps
-
Locate and enter the real checkout (
/home/travis/build/failed/<repo>/<id>) and choose Maven without wrapper downloads- If
<repo>/<id>aren’t explicitly known, discover them by listing down from the failed workspace until you reach the leaf directory that contains the build root (pom.xml,.git,mvnw):ls -la /home/travis/build/failed→ pick<repo>ls -la /home/travis/build/failed/<repo>→ pick<id>
cd /home/travis/build/failed/<repo>/<id>and confirm you’re at the reactor root:pwd; ls -la; test -f pom.xml.- Prefer system Maven (
mvn -v). If./mvnwexists, use it only when./mvnw -vsucceeds immediately (no Maven distribution download); otherwise stick withmvn.
- If
-
Create the required note file immediately and capture toolchain context
- Ensure
/home/travis/build/failed/failed_reasons.txtexists from the start (then keep updating it as you learn more):
: > /home/travis/build/failed/failed_reasons.txt - Capture context that commonly explains CI-only failures:
java -versionjavac -versionecho "$JAVA_HOME"mvn -vor./mvnw -v(records the Java used to run Maven, which is what${java.home}points at)- repo path:
pwd
- Ensure
-
Reproduce the failure with the CI-equivalent Maven command (then iterate on the failing module)
- Prefer the project’s CI command when it exists (commonly
.travis.yml, GitHub Actions workflows, etc.); run that exact Maven goal/options from the reactor root. - If no explicit CI command is found, start with
mvn -B -e verify(ortestwhen the project clearly has no integration-test phase). - Use
-e(and-Xonly when needed) so logs contain actionable stack traces and the first real error. - If the build is slow, iterate with the failing module to avoid timeouts:
mvn -B -e -pl <failing-module> -am verify(still do a final full reactorverifyat the end). - If you see dependency/plugin download/transfer failures (network blocked, flaky, or you need to rely on a pre-warmed cache):
- First check the pre-populated Maven user cache (e.g.,
/home/travis/.m2/repository/...); don’t assume any system Maven repo includes core plugins. - Prefer pinning Maven to that cache without forcing offline mode:
- add
-Dmaven.repo.local=/home/travis/.m2/repositoryon the command line, or - put only that flag in repo-root
.mvn/maven.configso all Maven runs (including nested invoker runs) reuse the cache.
- add
- Use offline mode (
-o) only when you have verified the missing coordinates exist as JARs in the cache (both*.pomand*.jar, including plugin transitive dependencies). If the cache has only a*.pom(no*.jar), offline builds will fail immediately; at that point the fix is to remove/replace the missing dependency/plugin (or allow downloads), not to “skip” it and keep-oenabled.
- First check the pre-populated Maven user cache (e.g.,
- Prefer the project’s CI command when it exists (commonly
-
Update
failed_reasons.txtwith the first fatal error + a concrete fix plan- In
/home/travis/build/failed/failed_reasons.txt, record:- the exact failing Maven command you ran,
- the first fatal error (copy the key lines),
- whether it’s primarily code vs build configuration/dependency/toolchain,
- which module(s) / phase(s) fail,
- a concrete fix plan and how you’ll verify it (final Maven command to run).
- In
-
Scope the failure correctly (root vs module vs nested invoker projects)
- Use the reactor summary to identify which module triggers the failure.
- If the build uses Maven Invoker / nested test projects, locate the source nested
pom.xmlunder typical invoker directories (e.g.,src/it/**/pom.xml), not generated copies undertarget/**. Those projects resolve dependencies independently and may require parallel fixes (parent/version alignment, dependency exclusions) and/or explicit repo-local settings passed through the invoker configuration.
-
Diagnose dependency/parent/plugin problems using reliable discovery (no brittle path guesses)
- For missing parent / offline-only failures: inspect the root
pom.xml<parent>and every module’s<parent>(including anysrc/it/**project POMs); if an external parent is unavailable offline, remove/replace it and align all modules to an in-repo parent/version (don’t fix just one POM). When you switch parents, ensure the<relativePath>resolves to the in-repo parent so Maven doesn’t try to download it. - For transitive dependency or inherited build logic failures:
- Use
mvn dependency:treefiltering to the problematic coordinate (add-pl <module> -amto focus), and when needed inspect the resolved POMs in the local repository (/home/travis/.m2/repository/.../*.pom) to find the true source stanza (parent POM, imported BOM, dependency POM). Treat.m2files as read-only: make overrides in the repo POM(s) viadependencyManagement, exclusions, or parent changes. - For build plugins, inspect the resolved plugin POM and (when helpful) the plugin descriptor under
.../META-INF/maven/plugin.xmlto confirm supported parameters (e.g., whether askipflag exists) and to see the plugin’s transitive dependencies you must have available offline.
- Use
- For repository-wide searches, enumerate/target real POMs instead of typing paths from memory (
git ls-files '**/pom.xml'orfind . -name pom.xml -not -path '*/target/*'), then search withrg -n(orgrep -R --line-number). - Run searches independently; avoid
cmd1 && cmd2chains where a no-match (exit code 1) prevents subsequent searches and can hide additional occurrences.
- For missing parent / offline-only failures: inspect the root
-
Apply fixes consistently across the whole build (multi-module + nested test projects)
- If a dependency/plugin configuration is present in multiple modules, either:
- centralize the fix in the shared parent (
dependencyManagement/pluginManagement), or - apply the same change to every module POM (and any nested invoker project POMs) that declares it.
- centralize the fix in the shared parent (
- Handle unresolvable plugins (common in cache-only/offline builds) structurally:
- If Maven fails while resolving/loading a plugin (e.g., “could not be resolved” / “failed to create plugin realm”), flags like
-D<plugin>.skipor-Denforcer.skip=truewon’t help unless the plugin and its dependencies can already be resolved. - Fix by ensuring the required plugin artifacts (and their transitive JARs) are available in the chosen local repo or by changing the POM so the plugin is not part of the default lifecycle (remove/override the inherited execution, or move it behind an opt-in profile).
- If Maven fails while resolving/loading a plugin (e.g., “could not be resolved” / “failed to create plugin realm”), flags like
- Handle JDK9+
tools.jar/com.sun:toolsfailures end-to-end:- Locate the declaring POM (repo search for
com.sun:tools,tools.jar, and/or<systemPath>, plusmvn -pl <module> -am dependency:tree -Dincludes=com.sun:toolsto identify the introducer). - If declared in this repo, remove it from the default dependency set and make it JDK8-and-earlier only (e.g., move it into a profile activated for
<jdk>[1.0,1.9)</jdk>), since JDK9+ has notools.jar. (Changingmaven-compiler-plugin’sjavacexecutable does not change${java.home}used by system-scopedtools.jardependencies.) - If it comes from a third-party dependency, prefer upgrading that dependency to a JDK9+ compatible version; otherwise exclude
com.sun:toolswhere it is brought in and, if compilation/tests still need compiler classes, add the necessary JDK9+ module flags via plugin configuration (commonly--add-modules jdk.compiler). - Apply the fix anywhere it can bite: all reactor modules and any
src/it/**invoker project POMs.
- Locate the declaring POM (repo search for
- After editing, re-run the same repo-wide search to confirm there are no remaining unpatched declarations.
- If a dependency/plugin configuration is present in multiple modules, either:
-
Implement fixes via
patch_*.diff(edit → refresh patch → reset/apply → build)- Work in small batches: after each batch of edits, immediately write/refresh the required unified diff file(s) in the repo root so the changes aren’t “only in the working tree”:
git status --porcelainandgit diff --stat- for each untracked new file, run
git add -N <path>sogit diffcaptures it git diff > patch_1.diffthen confirm it’s non-empty:test -s patch_1.diff- Open the patch and sanity-check it (paths, intent, no accidental noise):
sed -n '1,200p' patch_1.diff
- To satisfy the required workflow (diff first, then apply) and to ensure you’re testing exactly what you’ll submit, apply patches from a clean tree before verification builds:
git reset --hardgit clean -fd -e 'patch_*.diff'git apply patch_*.diff
- Re-run the Maven command used to reproduce the failure (use
-pl <module> -amto iterate fast if needed), then run a final full-reactorverifyonce it’s green. - If further edits are needed, repeat the loop and overwrite
patch_1.diff(or addpatch_2.diff, etc.) so the patch files always match the current intended state. - Final sanity:
ls -l patch_*.difftest -s /home/travis/build/failed/failed_reasons.txtgit statusshows only intended project-file changes (plus untracked patch file(s)).
- Work in small batches: after each batch of edits, immediately write/refresh the required unified diff file(s) in the repo root so the changes aren’t “only in the working tree”:
Expected Result
You can (1) reproduce the original Maven failure, (2) document a clear root cause + plan in failed_reasons.txt, (3) implement fixes that cover all affected modules/nested test projects, (4) generate patch_{i}.diff files that fully capture the changes, and (5) apply those patches and pass the final Maven build.
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