|
23 | 23 | </system-characterization> |
24 | 24 |
|
25 | 25 | <description> |
26 | | - Effective Maven usage involves robust dependency management via `<dependencyManagement>` and BOMs, adherence to the standard directory layout, and centralized plugin management. Build profiles should be used for environment-specific configurations. POMs must be kept readable and maintainable with logical structure and properties for versions. Custom repositories should be declared explicitly and their use minimized, preferably managed via a central repository manager. |
| 26 | + <![CDATA[ |
| 27 | + Effective Maven usage involves robust dependency management via `<dependencyManagement>` and BOMs, adherence to the standard directory layout, and centralized plugin management. Build profiles should be used for environment-specific configurations. POMs must be kept readable and maintainable with logical structure and properties for versions. Custom repositories should be declared explicitly and their use minimized, preferably managed via a central repository manager. |
| 28 | + ]]> |
27 | 29 | </description> |
28 | 30 |
|
29 | 31 | <toc auto-generate="true"/> |
|
35 | 37 | <rule-subtitle>Manage Dependencies Effectively using `dependencyManagement` and BOMs</rule-subtitle> |
36 | 38 | </rule-header> |
37 | 39 | <rule-description> |
38 | | - Use the `<dependencyManagement>` section in parent POMs or import Bill of Materials (BOMs) to centralize and control dependency versions. This helps avoid version conflicts and ensures consistency across multi-module projects. Avoid hardcoding versions directly in `<dependencies>` when managed elsewhere. |
| 40 | + <![CDATA[ |
| 41 | + Use the `<dependencyManagement>` section in parent POMs or import Bill of Materials (BOMs) to centralize and control dependency versions. This helps avoid version conflicts and ensures consistency across multi-module projects. Avoid hardcoding versions directly in `<dependencies>` when managed elsewhere. |
| 42 | + ]]> |
39 | 43 | </rule-description> |
40 | 44 | <code-examples> |
41 | 45 | <good-example> |
|
133 | 137 | <rule-subtitle>Adhere to the Standard Directory Layout</rule-subtitle> |
134 | 138 | </rule-header> |
135 | 139 | <rule-description> |
136 | | - Follow Maven's convention for directory structure (`src/main/java`, `src/main/resources`, `src/test/java`, `src/test/resources`, etc.). This makes projects easier to understand and build, as Maven relies on these defaults. |
| 140 | + <![CDATA[Follow Maven's convention for directory structure (`src/main/java`, `src/main/resources`, `src/test/java`, `src/test/resources`, etc.). This makes projects easier to understand and build, as Maven relies on these defaults.]]> |
137 | 141 | </rule-description> |
138 | 142 | <code-examples> |
139 | 143 | <good-example> |
140 | | - <code-block>my-app/ |
| 144 | + <code-block language="text"><![CDATA[ |
| 145 | +my-app/ |
141 | 146 | ├── pom.xml |
142 | 147 | └── src/ |
143 | 148 | ├── main/ |
|
149 | 154 | ├── java/ |
150 | 155 | │ └── com/example/myapp/AppTest.java |
151 | 156 | └── resources/ |
152 | | - └── test-data.xml</code-block> |
| 157 | + └── test-data.xml |
| 158 | + ]]></code-block> |
153 | 159 | </good-example> |
154 | 160 | <bad-example> |
155 | | - <code-block>my-app/ |
| 161 | + <code-block language="text"><![CDATA[ |
| 162 | +my-app/ |
156 | 163 | ├── pom.xml |
157 | | -├── sources/ <!-- Non-standard --> |
| 164 | +├── sources/ <!-- Non-standard --> |
158 | 165 | │ └── com/example/myapp/App.java |
159 | | -├── res/ <!-- Non-standard --> |
| 166 | +├── res/ <!-- Non-standard --> |
160 | 167 | │ └── config.properties |
161 | | -└── tests/ <!-- Non-standard --> |
| 168 | +└── tests/ <!-- Non-standard --> |
162 | 169 | └── com/example/myapp/AppTest.java |
163 | | -<!-- This would require explicit configuration in pom.xml to specify source/resource directories --></code-block> |
| 170 | +<!-- This would require explicit configuration in pom.xml to specify source/resource directories --> |
| 171 | + ]]></code-block> |
164 | 172 | </bad-example> |
165 | 173 | </code-examples> |
166 | 174 | </rule-section> |
|
171 | 179 | <rule-subtitle>Manage Plugin Versions and Configurations Centrally</rule-subtitle> |
172 | 180 | </rule-header> |
173 | 181 | <rule-description> |
174 | | - Use `<pluginManagement>` in a parent POM to define plugin versions and common configurations. Child POMs can then use the plugins without specifying versions, ensuring consistency. Override configurations in child POMs only when necessary. |
| 182 | + <![CDATA[Use `<pluginManagement>` in a parent POM to define plugin versions and common configurations. Child POMs can then use the plugins without specifying versions, ensuring consistency. Override configurations in child POMs only when necessary.]]> |
175 | 183 | </rule-description> |
176 | 184 | <code-examples> |
177 | 185 | <good-example> |
|
237 | 245 | <rule-subtitle>Employ Build Profiles for Environment-Specific Settings</rule-subtitle> |
238 | 246 | </rule-header> |
239 | 247 | <rule-description> |
240 | | - Use Maven profiles to customize build settings for different environments (e.g., dev, test, prod) or other conditional scenarios. This can include different dependencies, plugin configurations, or properties. Activate profiles via command line, OS, JDK, or file presence. |
| 248 | + <![CDATA[Use Maven profiles to customize build settings for different environments (e.g., dev, test, prod) or other conditional scenarios. This can include different dependencies, plugin configurations, or properties. Activate profiles via command line, OS, JDK, or file presence.]]> |
241 | 249 | </rule-description> |
242 | 250 | <code-examples> |
243 | 251 | <good-example> |
|
306 | 314 | <rule-subtitle>Structure POMs Logically for Readability</rule-subtitle> |
307 | 315 | </rule-header> |
308 | 316 | <rule-description> |
309 | | - Organize your `pom.xml` sections in a consistent order (e.g., project coordinates, parent, properties, dependencyManagement, dependencies, build, profiles, repositories). Use properties for recurring versions or values. Add comments for complex configurations. |
| 317 | + <![CDATA[Organize your `pom.xml` sections in a consistent order (e.g., project coordinates, parent, properties, dependencyManagement, dependencies, build, profiles, repositories). Use properties for recurring versions or values. Add comments for complex configurations.]]> |
310 | 318 | </rule-description> |
311 | 319 | <code-examples> |
312 | 320 | <good-example> |
|
393 | 401 | <rule-subtitle>Declare Custom Repositories Explicitly and Minimize Their Use</rule-subtitle> |
394 | 402 | </rule-header> |
395 | 403 | <rule-description> |
396 | | - Prefer dependencies from Maven Central. If custom repositories are necessary, declare them in the `<repositories>` section and `<pluginRepositories>` for plugins. It's often better to manage these in a company-wide Nexus/Artifactory instance configured in `settings.xml` rather than per-project POMs. Avoid relying on transitive repositories. |
| 404 | + <![CDATA[Prefer dependencies from Maven Central. If custom repositories are necessary, declare them in the `<repositories>` section and `<pluginRepositories>` for plugins. It's often better to manage these in a company-wide Nexus/Artifactory instance configured in `settings.xml` rather than per-project POMs. Avoid relying on transitive repositories.]]> |
397 | 405 | </rule-description> |
398 | 406 | <code-examples> |
399 | 407 | <good-example> |
|
441 | 449 | <rule-subtitle>Use Properties to Manage Dependency and Plugin Versions</rule-subtitle> |
442 | 450 | </rule-header> |
443 | 451 | <rule-description> |
444 | | - Define all dependency and plugin versions in the `<properties>` section rather than hardcoding them throughout the POM. This centralizes version management, makes updates easier, reduces duplication, and helps maintain consistency across related dependencies. Use consistent property naming conventions: `maven-plugin-[name].version` for Maven plugins, simple names like `[library].version` for dependencies, and descriptive names for quality thresholds like `coverage.level`. |
| 452 | + <![CDATA[Define all dependency and plugin versions in the `<properties>` section rather than hardcoding them throughout the POM. This centralizes version management, makes updates easier, reduces duplication, and helps maintain consistency across related dependencies. Use consistent property naming conventions: `maven-plugin-[name].version` for Maven plugins, simple names like `[library].version` for dependencies, and descriptive names for quality thresholds like `coverage.level`.]]> |
445 | 453 | </rule-description> |
446 | 454 | <code-examples> |
447 | 455 | <good-example> |
|
0 commit comments