--- name: 112-java-maven-plugins-profile-static-analysis description: Static analysis profile guidance for SpotBugs and PMD. license: Apache-2.0 metadata: author: Juan Antonio BreƱa Moral version: 0.19.0 --- # Maven Plugins: pom.xml Configuration Best Practices ## Role You are a Senior software engineer with extensive experience in Java software development. ## Tone Treat the user as a knowledgeable partner. Preserve existing Maven configuration, explain trade-offs, and apply this reference only when the SKILL.md question flow selected this plugin or profile. ## Goal Configure static analysis profile only when selected by the user in `112-java-maven-plugins`. Read this reference after the SKILL.md orchestration has validated the Maven project, analyzed existing plugins/properties/profiles, and collected the user's plugin/profile selections. ## Constraints Apply only the selected static analysis profile configuration and preserve existing project configuration. - Read this reference only when the user selected the corresponding Maven plugin or profile in the centralized question flow. - Before adding configuration, check whether the plugin, property, reporting entry, support file, or profile already exists. - Never remove or replace existing Maven configuration without explicit user confirmation. - Add only the Maven properties, plugin configuration, profile configuration, and support files required by this reference. ## Steps ### Step 1: Add selected Maven properties Add only the properties needed for this selected plugin/profile. If a property already exists, preserve the current value unless the user explicitly confirms a change. ```xml UTF-8 UTF-8 3.9.10 [USER_SELECTED_JAVA_VERSION] 3.28.0 4.9.3.0 ``` ### Step 2: Static Code Analysis Profile Configuration **Purpose**: Configure SpotBugs and PMD static analysis profile to detect potential bugs and code quality issues. **Dependencies**: Only execute if user selected "Static code analysis (SpotBugs, PMD)" in the SKILL.md question flow. Requires completion of the SKILL.md orchestration steps and selected property handling. **CRITICAL PRESERVATION RULE**: Only ADD this profile if it doesn't already exist. Never REPLACE or REMOVE existing profiles. ## Pre-Implementation Check **BEFORE adding Static Analysis profile, check if it already exists in the pom.xml:** If `` section with `find-bugs` profile already exists: Ask user "Static analysis profile already exists. Do you want to enhance the existing configuration? (y/n)" If user says "n": Skip this step entirely. If user says "y": Proceed with adding missing configuration elements only. **CONDITIONAL EXECUTION**: Only execute this step if user selected "Static code analysis (SpotBugs, PMD)" in the SKILL.md question flow. ## Static Analysis Profile Configuration **ADD this profile to the `` section in pom.xml ONLY if it doesn't already exist:** ```xml find-bugs false org.apache.maven.plugins maven-pmd-plugin ${maven-plugin-pmd.version} com.github.spotbugs spotbugs-maven-plugin ${maven-plugin-spotbugs.version} Max Low true com.github.spotbugs spotbugs-maven-plugin ${maven-plugin-spotbugs.version} Max Low src/main/spotbugs/spotbugs-include.xml src/main/spotbugs/spotbugs-exclude.xml org.apache.maven.plugins maven-pmd-plugin ${maven-plugin-pmd.version} ``` ## Usage Examples ```bash # Run static analysis ./mvnw clean verify -Pfind-bugs # Generate reports ./mvnw site -Pfind-bugs # View reports open target/site/spotbugs.html open target/site/pmd.html ``` ## Validation After adding this profile, verify the configuration: ```bash # Test Static Analysis profile ./mvnw clean verify -Pfind-bugs ``` #### Step Constraints - **MUST** only add Static Analysis profile if static analysis was selected in the SKILL.md question flow - **MUST** check if profile already exists before adding - **MUST** ask user permission before modifying existing profile configuration - **MUST** use selected version properties for plugin versions - **MUST** skip this step entirely if static analysis was not selected