Skip to content

Commit f65e57e

Browse files
committed
Adding examples
1 parent 1bc0c6b commit f65e57e

File tree

24 files changed

+647
-85
lines changed

24 files changed

+647
-85
lines changed

.cursor/rules/111-java-maven-deps-and-plugins.mdc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ This rule provides a comprehensive, conversational approach to updating Maven po
7878
- **Question 2**: [Java Version](mdc:.cursor/rules/templates/java-maven-questions-template.md#2-java-version) (single selection from the template)
7979
- **Question 3**: [Build and Quality Aspects](mdc:.cursor/rules/templates/java-maven-questions-template.md#3-build-and-quality-aspects) (multiple selection allowed from the template)
8080
- **Question 4**: [Coverage Threshold](mdc:.cursor/rules/templates/java-maven-questions-template.md#4-coverage-threshold) (conditional - only if coverage selected)
81+
- **Question 5**: [Sonar Configuration](mdc:.cursor/rules/templates/java-maven-questions-template.md#5-sonar-configuration-conditional) (conditional - only if static analysis with Sonar selected)
82+
- **Question 6**: [Sonar Host Configuration](mdc:.cursor/rules/templates/java-maven-questions-template.md#6-sonar-host-configuration-conditional) (conditional - only if Sonar configuration enabled)
8183

8284
4. **VALIDATION CHECKPOINT:**
8385
- **STOP** and verify all applicable questions have been answered
@@ -150,7 +152,7 @@ After getting answers, implement the configuration following this order:
150152
- **Code Coverage**: jacoco-maven-plugin (in profile)
151153
- **Mutation Testing**: pitest-maven (in profile)
152154
- **Security Scanning**: dependency-check-maven (in profile)
153-
- **Static Analysis**: spotbugs-maven-plugin, maven-pmd-plugin (in profile)
155+
- **Static Analysis**: spotbugs-maven-plugin, maven-pmd-plugin (in profile) & sonar (in profile)
154156
- **Version Management**: versions-maven-plugin
155157
- **Build Info**: git-commit-id-plugin
156158
- **Library Publishing**: flatten-maven-plugin
@@ -205,8 +207,13 @@ Only provide examples for the features that were actually added based on user se
205207
4. **Follow the order**: Questions → Properties → Dependencies → Plugins → Profiles
206208
5. **Customize package names**: Update package structure to match the actual project
207209
6. **Adjust thresholds**: Use the coverage levels specified by the user
208-
7. **Validate configuration**: Always run validation after changes
209-
8. **Provide relevant examples**: Only show usage examples for added features
210+
7. **Configure Sonar parameters**: Replace template placeholders with user-provided values:
211+
- Replace `YOUR_GITHUB_USER` with the provided organization identifier
212+
- Replace `YOUR_GITHUB_USER_REPOSITORY_NAME` with the provided project key
213+
- Replace `YOUR_PROJECT_NAME` with the provided project display name
214+
- Set `sonar.host.url` based on the selected Sonar service (SonarCloud or custom SonarQube)
215+
8. **Validate configuration**: Always run validation after changes
216+
9. **Provide relevant examples**: Only show usage examples for added features
210217

211218
## Conversation Flow Example
212219

.cursor/rules/templates/java-checklist-template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Use the following process to improve the java development in some areas if requi
88

99
| Activity | Done | Prompt | Notes |
1010
|----------|------|--------|-------|
11-
| Review your pom.xml and Maven project | [ ] | `Help me to review the pom.xml following the best practices for dependency management and directory structure use the cursor rule @110-java-maven-best-practices` | |
12-
| Improve the Maven project with plugins & dependencies | [ ] | `Can you improve the pom.xml using the cursor rule @101-java-maven-deps-and-plugins.mdc` | Conversational approach |
11+
| Review your pom.xml and Maven project | [ ] | `Help me to review the pom.xml following the best practices for dependency management and directory structure use the cursor rule @110-java-maven-best-practices` | Add in the context the `pom.xml` which you want to generate the documentation |
12+
| Improve the Maven project with plugins & dependencies | [ ] | `Can you improve the pom.xml using the cursor rule @101-java-maven-deps-and-plugins.mdc` | Add in the context the `pom.xml` which you want to generate the documentation. Conversational approach |
1313
| Create documentation about Maven`s usage | [ ] | `Generate developer documentation with essential Maven commands using @112-java-maven-documentation.mdc` | Add in the context the `pom.xml` which you want to generate the documentation |
1414

1515
### Step 2: Design Principles
@@ -32,7 +32,7 @@ Use the following process to improve the java development in some areas if requi
3232

3333
| Activity | Done | Prompt | Notes |
3434
|----------|------|--------|-------|
35-
| Unit Testing | [ ] | `Help me write unit tests using the cursor rule @131-java-unit-testing` | |
35+
| Unit Testing | [ ] | `Can improve the unit tests using the cursor rule @131-java-unit-testing` | |
3636
| Integration Testing | [ ] | `Help me write integration tests using the cursor rule @132-java-integration-testing` | If required |
3737

3838
### Step 5: Refactoring

.cursor/rules/templates/java-maven-plugins-template.md

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This template provides Maven plugin configurations that should be added conditio
66

77
## Core Plugins
88

9-
### Add maven-plugins-enforcer (Enhanced)
9+
### Add maven-plugin-enforcer (Enhanced)
1010

1111
**When to use**: Always recommended for build consistency and dependency management.
1212
**User question**: "Do you want enhanced dependency validation and build enforcement? (y/n)"
@@ -20,7 +20,7 @@ Update the pom.xml with this enhanced enforcer plugin:
2020
<plugin>
2121
<groupId>org.codehaus.mojo</groupId>
2222
<artifactId>flatten-maven-plugin</artifactId>
23-
<version>${maven-plugins-flatten.version}</version>
23+
<version>${maven-plugin-flatten.version}</version>
2424
<configuration>
2525
</configuration>
2626
<executions>
@@ -42,7 +42,7 @@ Update the pom.xml with this enhanced enforcer plugin:
4242
</plugin>
4343
```
4444

45-
## Add maven-plugins-enforcer
45+
## Add maven-plugin-enforcer
4646

4747
Nature: General
4848
Category: Build
@@ -53,7 +53,7 @@ Update the pom.xml with this new plugin:
5353
<plugin>
5454
<groupId>org.apache.maven.plugins</groupId>
5555
<artifactId>maven-enforcer-plugin</artifactId>
56-
<version>${maven-plugins-enforcer.version}</version>
56+
<version>${maven-plugin-enforcer.version}</version>
5757
<dependencies>
5858
<dependency>
5959
<groupId>org.codehaus.mojo</groupId>
@@ -73,7 +73,7 @@ Update the pom.xml with this new plugin:
7373
<version>${maven.version}</version>
7474
</requireMavenVersion>
7575
<requireJavaVersion>
76-
<version>[${maven.compiler.release},)</version>
76+
<version>${java.version}</version>
7777
</requireJavaVersion>
7878
<bannedDependencies>
7979
<excludes>
@@ -91,7 +91,7 @@ Update the pom.xml with this new plugin:
9191
</plugin>
9292
```
9393

94-
### Add maven-plugins-compiler (Enhanced)
94+
### Add maven-plugin-compiler (Enhanced)
9595

9696
**When to use**: Always included, but ask about enhancement level.
9797
**User question**: "Do you want enhanced code analysis with Error Prone and NullAway? (y/n)"
@@ -120,7 +120,7 @@ Update the pom.xml with this new plugin:
120120
<plugin>
121121
<groupId>org.apache.maven.plugins</groupId>
122122
<artifactId>maven-compiler-plugin</artifactId>
123-
<version>${maven-plugins-compiler.version}</version>
123+
<version>${maven-plugin-compiler.version}</version>
124124
<configuration>
125125
<release>${java.version}</release>
126126
<compilerArgs>
@@ -171,7 +171,7 @@ Update the pom.xml with this plugin:
171171
<plugin>
172172
<groupId>org.codehaus.mojo</groupId>
173173
<artifactId>flatten-maven-plugin</artifactId>
174-
<version>${maven-plugins-flatten.version}</version>
174+
<version>${maven-plugin-flatten.version}</version>
175175
<configuration>
176176
</configuration>
177177
<executions>
@@ -207,7 +207,7 @@ Update the pom.xml with this plugin:
207207
<plugin>
208208
<groupId>org.codehaus.mojo</groupId>
209209
<artifactId>versions-maven-plugin</artifactId>
210-
<version>${maven-plugins-versions.version}</version>
210+
<version>${maven-plugin-versions.version}</version>
211211
<configuration>
212212
<allowSnapshots>false</allowSnapshots>
213213
</configuration>
@@ -228,7 +228,7 @@ Update the pom.xml with this plugin:
228228
<plugin>
229229
<groupId>pl.project13.maven</groupId>
230230
<artifactId>git-commit-id-plugin</artifactId>
231-
<version>${maven-plugins-git-commit-id.version}</version>
231+
<version>${maven-plugin-git-commit-id.version}</version>
232232
<executions>
233233
<execution>
234234
<id>get-the-git-infos</id>
@@ -248,7 +248,7 @@ Update the pom.xml with this plugin:
248248

249249
## Testing Plugins
250250

251-
### Add maven-plugins-surefire
251+
### Add maven-plugin-surefire
252252

253253
**When to use**: Always included for unit testing.
254254
**User question**: Automatically included with testing framework selection.
@@ -262,7 +262,7 @@ Update the pom.xml with this plugin:
262262
<plugin>
263263
<groupId>org.apache.maven.plugins</groupId>
264264
<artifactId>maven-surefire-plugin</artifactId>
265-
<version>${maven-plugins-surefire.version}</version>
265+
<version>${maven-plugin-surefire.version}</version>
266266
<configuration>
267267
<skipAfterFailureCount>1</skipAfterFailureCount>
268268
<includes>
@@ -289,7 +289,7 @@ Update the pom.xml with this plugin:
289289
<plugin>
290290
<groupId>org.apache.maven.plugins</groupId>
291291
<artifactId>maven-failsafe-plugin</artifactId>
292-
<version>${maven-plugins-failsafe.version}</version>
292+
<version>${maven-plugin-failsafe.version}</version>
293293
<configuration>
294294
<includes>
295295
<include>**/*IT.java</include>
@@ -325,7 +325,7 @@ Update the pom.xml with this reporting section:
325325
<plugin>
326326
<groupId>org.apache.maven.plugins</groupId>
327327
<artifactId>maven-surefire-report-plugin</artifactId>
328-
<version>${maven-plugins-surefire.version}</version>
328+
<version>${maven-plugin-surefire.version}</version>
329329
<configuration>
330330
<outputName>junit-report</outputName>
331331
<showSuccess>true</showSuccess>
@@ -336,7 +336,7 @@ Update the pom.xml with this reporting section:
336336
<plugin>
337337
<groupId>org.apache.maven.plugins</groupId>
338338
<artifactId>maven-jxr-plugin</artifactId>
339-
<version>${maven-plugins-jxr.version}</version>
339+
<version>${maven-plugin-jxr.version}</version>
340340
</plugin>
341341
</plugins>
342342
</reporting>
@@ -366,7 +366,7 @@ Update the pom.xml with this profile to run jacoco:
366366
<plugin>
367367
<groupId>org.jacoco</groupId>
368368
<artifactId>jacoco-maven-plugin</artifactId>
369-
<version>${maven-plugins-jacoco.version}</version>
369+
<version>${maven-plugin-jacoco.version}</version>
370370
<executions>
371371
<execution>
372372
<id>prepare-agent</id>
@@ -436,7 +436,7 @@ Update the pom.xml with this profile to execute Mutation testing in order to ana
436436
<plugin>
437437
<groupId>org.pitest</groupId>
438438
<artifactId>pitest-maven</artifactId>
439-
<version>${maven-plugins-pitest.version}</version>
439+
<version>${maven-plugin-pitest.version}</version>
440440
<configuration>
441441
<targetClasses>
442442
<param>info.jab.cli.*</param>
@@ -457,7 +457,7 @@ Update the pom.xml with this profile to execute Mutation testing in order to ana
457457
<dependency>
458458
<groupId>org.pitest</groupId>
459459
<artifactId>pitest-junit5-plugin</artifactId>
460-
<version>${maven-plugins-pitest-junit5.version}</version>
460+
<version>${maven-plugin-pitest-junit5.version}</version>
461461
</dependency>
462462
</dependencies>
463463
<executions>
@@ -496,7 +496,7 @@ Update the pom.xml with this profile
496496
<plugin>
497497
<groupId>org.owasp</groupId>
498498
<artifactId>dependency-check-maven</artifactId>
499-
<version>${maven-plugins-dependency-check.version}</version>
499+
<version>${maven-plugin-dependency-check.version}</version>
500500
<configuration>
501501
<outputDirectory>${project.build.directory}/dependency-check</outputDirectory>
502502
<format>ALL</format>
@@ -549,12 +549,12 @@ Update the pom.xml with this profile
549549
<plugin>
550550
<groupId>org.apache.maven.plugins</groupId>
551551
<artifactId>maven-pmd-plugin</artifactId>
552-
<version>${maven-plugins-pmd.version}</version>
552+
<version>${maven-plugin-pmd.version}</version>
553553
</plugin>
554554
<plugin>
555555
<groupId>com.github.spotbugs</groupId>
556556
<artifactId>spotbugs-maven-plugin</artifactId>
557-
<version>${maven-plugins-spotbugs.version}</version>
557+
<version>${maven-plugin-spotbugs.version}</version>
558558
<configuration>
559559
<effort>Max</effort>
560560
<threshold>Low</threshold>
@@ -569,7 +569,7 @@ Update the pom.xml with this profile
569569
<plugin>
570570
<groupId>com.github.spotbugs</groupId>
571571
<artifactId>spotbugs-maven-plugin</artifactId>
572-
<version>${maven-plugins-spotbugs.version}</version>
572+
<version>${maven-plugin-spotbugs.version}</version>
573573
<configuration>
574574
<effort>Max</effort>
575575
<threshold>Low</threshold>
@@ -580,10 +580,48 @@ Update the pom.xml with this profile
580580
<plugin>
581581
<groupId>org.apache.maven.plugins</groupId>
582582
<artifactId>maven-pmd-plugin</artifactId>
583-
<version>${maven-plugins-pmd.version}</version>
583+
<version>${maven-plugin-pmd.version}</version>
584584
</plugin>
585585
</plugins>
586586
</reporting>
587587
</profile>
588588
```
589589

590+
### Add sonar profile to execute sonar
591+
592+
Nature: General
593+
Category: Quality
594+
595+
```xml
596+
<profile>
597+
<id>sonar</id>
598+
<activation>
599+
<activeByDefault>false</activeByDefault>
600+
</activation>
601+
<properties>
602+
<!-- SonarCloud configuration -->
603+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
604+
<sonar.organization>YOUR_GITHUB_USER</sonar.organization>
605+
<sonar.projectKey>YOUR_GITHUB_USER_REPOSITORY_NAME</sonar.projectKey>
606+
<sonar.projectName>YOUR_PROJECT_NAME</sonar.projectName>
607+
<sonar.projectVersion>${project.version}</sonar.projectVersion>
608+
<sonar.sources>src/main/java</sonar.sources>
609+
<sonar.tests>src/test/java</sonar.tests>
610+
<sonar.java.binaries>target/classes</sonar.java.binaries>
611+
<sonar.java.test.binaries>target/test-classes</sonar.java.test.binaries>
612+
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
613+
<sonar.junit.reportPaths>target/surefire-reports</sonar.junit.reportPaths>
614+
<sonar.coverage.exclusions>**/*Test.java,**/*IT.java</sonar.coverage.exclusions>
615+
<sonar.java.source>${java.version}</sonar.java.source>
616+
</properties>
617+
<build>
618+
<plugins>
619+
<plugin>
620+
<groupId>org.sonarsource.scanner.maven</groupId>
621+
<artifactId>sonar-maven-plugin</artifactId>
622+
<version>${maven-plugin-sonar.version}</version>
623+
</plugin>
624+
</plugins>
625+
</build>
626+
</profile>
627+
```

0 commit comments

Comments
 (0)