|
| 1 | +--- |
| 2 | +name: Maven standards |
| 3 | +description: Conventions to use in Maven files, mostly the `pom.xml` files |
| 4 | +--- |
| 5 | + |
| 6 | +## 1. Make sure dependencies that are supposed to be of scope `test`, remain test dependencies |
| 7 | + |
| 8 | +In most cases, test dependencies should be of scope `test`. If you find any dependencies that are supposed to be of scope `test` but are not, you should add the `<scope>test</scope>` element to them. This ensures that the dependencies are only included in the test classpath and not in the production classpath. |
| 9 | +For these cases, the following are the dependencies that supposed to be of scope `test`: |
| 10 | + |
| 11 | +```xml |
| 12 | + <dependency> |
| 13 | + <groupId>com.fasterxml.jackson.dataformat</groupId> |
| 14 | + <artifactId>jackson-dataformat-xml</artifactId> |
| 15 | + </dependency> |
| 16 | + <dependency> |
| 17 | + <groupId>io.mockk</groupId> |
| 18 | + <artifactId>mockk-jvm</artifactId> |
| 19 | + <scope>test</scope> |
| 20 | + </dependency> |
| 21 | + <dependency> |
| 22 | + <groupId>com.ninja-squad</groupId> |
| 23 | + <artifactId>springmockk</artifactId> |
| 24 | + <scope>test</scope> |
| 25 | + </dependency> |
| 26 | + <dependency> |
| 27 | + <groupId>io.kotest</groupId> |
| 28 | + <artifactId>kotest-assertions-core-jvm</artifactId> |
| 29 | + <scope>test</scope> |
| 30 | + </dependency> |
| 31 | + <dependency> |
| 32 | + <groupId>org.springframework.boot</groupId> |
| 33 | + <artifactId>spring-boot-starter-test</artifactId> |
| 34 | + <scope>test</scope> |
| 35 | + </dependency> |
| 36 | +``` |
| 37 | + |
| 38 | +In some cases, the test dependencies may be used for production code in test modules. Those cases are not always easy to determine. |
| 39 | +However, if you see that the module, where these dependencies are found to be used, is being used as a test dependency of other modules in the same project, then leave the dependency as is. |
| 40 | + |
| 41 | +## 2. Excessive declarations of the maven compiler |
| 42 | + |
| 43 | +As a common practice, the `maven-compiler-plugin` was declared in the parent module, but also in many submodules. |
| 44 | +The repetition is unnecessary, but may still prevail. |
| 45 | +Please remove all `maven-compiler-plugin` declarations from all modules and submodules. |
| 46 | +Keep only one at the top level. |
| 47 | +All the other `maven-compiler-plugin` declarations can be removed |
| 48 | + |
| 49 | +## 3. Excessive declarations of maven surefire and maven failsafe |
| 50 | + |
| 51 | +As a common practice, the `maven-surefire-plugin` and the `maven-failsafe-plugin` were declared in the parent module, but also in many submodules. |
| 52 | +Please remove all `maven-surefire-plugin` and the `maven-failsafe-plugin` declarations from all modules and submodules. |
| 53 | +Keep them only at the top level. |
| 54 | +All the other `maven-surefire-plugin` and the `maven-failsafe-plugin` declarations can be removed |
0 commit comments