Cursor-rules-java 110-java-maven-best-practices
Use when you need to review, improve, or troubleshoot a Maven pom.xml file — including dependency management with BOMs, plugin configuration, version centralization, multi-module project structure, build profiles, or any situation where you want to align your Maven setup with industry best practices. Part of the skills-for-java project
git clone https://github.com/jabrena/cursor-rules-java
T=$(mktemp -d) && git clone --depth=1 https://github.com/jabrena/cursor-rules-java "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/110-java-maven-best-practices" ~/.claude/skills/jabrena-cursor-rules-java-110-java-maven-best-practices && rm -rf "$T"
skills/110-java-maven-best-practices/SKILL.mdMaven Best Practices
Improve Maven POM configuration using industry-standard best practices.
What is covered in this Skill?
- Dependency management via
and BOMs<dependencyManagement> - Standard directory layout (
,src/main/java
)src/test/java - Centralized plugin management
- Build profiles for environment-specific settings
- Readable POM structure with version properties
- Explicit repository declaration
- Version centralization
- Multi-module project structure with proper inheritance
- Cross-module version consistency
- Multi-module scope: After reading the root
, check for apom.xml
section. If present, read every child module's<modules>
before making any recommendations.pom.xml - Check each child for hardcoded versions that duplicate parent
, redundant<dependencyManagement>
blocks, properties that should be centralized, and version drift across sibling modules.<pluginManagement>
Constraints
Before applying Maven best practices recommendations, ensure the project is in a valid state by running Maven validation. This helps identify any existing configuration issues that need to be resolved first. For multi-module projects, scope analysis must cover every child module POM — not just the root.
- MANDATORY: Run
or./mvnw validate
before applying any Maven best practices recommendationsmvn validate - VERIFY: Ensure all validation errors are resolved before proceeding with POM modifications
- SAFETY: If validation fails, do not continue and ask the user to fix the issues before continuing
- MULTI-MODULE DISCOVERY: After reading the root
, check whether it contains apom.xml
section. If it does, read every child module's<modules>
before making any recommendations — analysis scope is the full module tree, not only the rootpom.xml - CROSS-MODULE SCOPE: When child modules exist, check each one for: hardcoded dependency versions that duplicate
in the parent, plugin configurations that duplicate<dependencyManagement>
, properties that should be centralized in the parent, and version drift (same artifact declared at different versions across sibling modules)<pluginManagement> - BEFORE APPLYING: Read the reference for detailed examples, good/bad patterns, and constraints
When to use this skill
- Review pom.xml to improve it
- Apply Maven best practices to pom.xml
- Improve Maven POM configuration
Reference
For detailed guidance, examples, and constraints, see references/110-java-maven-best-practices.md.