Skip to content

Commit 7183fe1

Browse files
committed
improving syntax
1 parent df37ca3 commit 7183fe1

6 files changed

Lines changed: 240 additions & 479 deletions

File tree

.cursor/rules/110-java-maven-best-practices.mdc

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,27 @@ alwaysApply: false
55
---
66
# Maven Best Practices
77

8-
## System prompt characterization
9-
10-
Role definition: You are a Senior software engineer with extensive experience in Java software development
11-
12-
## Description
13-
14-
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.
8+
## Instructions for AI
159

16-
## Table of contents
10+
Update the pom.xml based on the following rules about Maven best practices.
1711

18-
- Rule 1: Effective Dependency Management
19-
- Rule 2: Standard Directory Layout
20-
- Rule 3: Plugin Management and Configuration
21-
- Rule 4: Use Build Profiles for Environment-Specific Configurations
22-
- Rule 5: Keep POMs Readable and Maintainable
23-
- Rule 6: Manage Repositories Explicitly
24-
- Rule 7: Centralize Version Management with Properties
12+
## Role
2513

14+
You are a Senior software engineer with extensive experience in Java software development
2615

27-
## Instructions for AI
16+
## Examples
2817

29-
Update the pom.xml based on the following rules about Maven best practices.
18+
### Table of contents
3019

20+
- Example 1: Effective Dependency Management
21+
- Example 2: Standard Directory Layout
22+
- Example 3: Plugin Management and Configuration
23+
- Example 4: Use Build Profiles for Environment-Specific Configurations
24+
- Example 5: Keep POMs Readable and Maintainable
25+
- Example 6: Manage Repositories Explicitly
26+
- Example 7: Centralize Version Management with Properties
3127

32-
## Rule 1: Effective Dependency Management
28+
### Example 1: Effective Dependency Management
3329

3430
Title: Manage Dependencies Effectively using `dependencyManagement` and BOMs
3531
Description: 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.
@@ -128,7 +124,7 @@ Description: Use the `<dependencyManagement>` section in parent POMs or import B
128124

129125
```
130126

131-
## Rule 2: Standard Directory Layout
127+
### Example 2: Standard Directory Layout
132128

133129
Title: Adhere to the Standard Directory Layout
134130
Description: 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.
@@ -167,7 +163,7 @@ my-app/
167163

168164
```
169165

170-
## Rule 3: Plugin Management and Configuration
166+
### Example 3: Plugin Management and Configuration
171167

172168
Title: Manage Plugin Versions and Configurations Centrally
173169
Description: 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.
@@ -234,7 +230,7 @@ Description: Use `<pluginManagement>` in a parent POM to define plugin versions
234230

235231
```
236232

237-
## Rule 4: Use Build Profiles for Environment-Specific Configurations
233+
### Example 4: Use Build Profiles for Environment-Specific Configurations
238234

239235
Title: Employ Build Profiles for Environment-Specific Settings
240236
Description: 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.
@@ -301,7 +297,7 @@ Description: Use Maven profiles to customize build settings for different enviro
301297

302298
```
303299

304-
## Rule 5: Keep POMs Readable and Maintainable
300+
### Example 5: Keep POMs Readable and Maintainable
305301

306302
Title: Structure POMs Logically for Readability
307303
Description: 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.
@@ -387,7 +383,7 @@ Description: Organize your `pom.xml` sections in a consistent order (e.g., proje
387383

388384
```
389385

390-
## Rule 6: Manage Repositories Explicitly
386+
### Example 6: Manage Repositories Explicitly
391387

392388
Title: Declare Custom Repositories Explicitly and Minimize Their Use
393389
Description: 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.
@@ -434,7 +430,7 @@ Description: Prefer dependencies from Maven Central. If custom repositories are
434430

435431
```
436432

437-
## Rule 7: Centralize Version Management with Properties
433+
### Example 7: Centralize Version Management with Properties
438434

439435
Title: Use Properties to Manage Dependency and Plugin Versions
440436
Description: 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`.
@@ -589,8 +585,7 @@ Description: Define all dependency and plugin versions in the `<properties>` sec
589585

590586
```
591587

592-
593588
## Output Requirements
594589

595590
- Update the file pom.xml if something is not correct
596-
- verify changes with the command: `mvn validate`
591+
- verify changes with the command: `mvn validate`

0 commit comments

Comments
 (0)