Skip to content

Commit e51a658

Browse files
committed
Tested spotless
1 parent fc5c0ea commit e51a658

File tree

8 files changed

+63
-16
lines changed

8 files changed

+63
-16
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ Start with essential build properties that every project needs (use the Java ver
5757

5858
**Only add plugin version properties for selected features**:
5959

60+
### Static Analysis
61+
**If Format source code selected**:
62+
```xml
63+
<maven-plugin-spotless.version>2.44.5</maven-plugin-spotless.version>
64+
```
65+
6066
### Integration Testing
6167
**If Integration Testing selected**:
6268
```xml

examples/maven-demo/README-DEV.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# Clean and package in one command
1717
./mvnw clean package
1818

19+
#Format source code
20+
./mvnw spotless:apply
21+
1922
# Run integration tests
2023
./mvnw verify
2124

examples/maven-demo/pom.xml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>
12+
<java.version>21</java.version>
13+
<maven.version>3.9.10</maven.version>
1214
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<maven.compiler.release>17</maven.compiler.release>
15+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
16+
<maven.compiler.release>${java.version}</maven.compiler.release>
1417

18+
<!-- Dependency versions -->
1519
<assertj.version>3.27.3</assertj.version>
20+
21+
<!-- Plugin versions -->
22+
<maven-plugin-spotless.version>2.44.5</maven-plugin-spotless.version>
23+
1624
</properties>
1725

1826
<dependencyManagement>
@@ -49,5 +57,35 @@
4957
</dependencies>
5058

5159
<build>
60+
<plugins>
61+
<plugin>
62+
<groupId>com.diffplug.spotless</groupId>
63+
<artifactId>spotless-maven-plugin</artifactId>
64+
<version>${maven-plugin-spotless.version}</version>
65+
<configuration>
66+
<encoding>UTF-8</encoding>
67+
<java>
68+
<removeUnusedImports />
69+
<importOrder>
70+
<order>,\#</order>
71+
</importOrder>
72+
<endWithNewline />
73+
<trimTrailingWhitespace />
74+
<indent>
75+
<spaces>true</spaces>
76+
<spacesPerTab>4</spacesPerTab>
77+
</indent>
78+
</java>
79+
</configuration>
80+
<executions>
81+
<execution>
82+
<goals>
83+
<goal>check</goal>
84+
</goals>
85+
<phase>process-sources</phase>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
</plugins>
5290
</build>
5391
</project>

examples/maven-demo/src/main/java/info/jab/demo/EulerProblem01.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ public class EulerProblem01 implements IEuler<Integer, Integer> {
55
/**
66
* Multiples of 3 or 5
77
* https://projecteuler.net/problem=1
8-
*
8+
*
99
* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3,5,6 and 9. The sum of these multiples is 23.
1010
* Find the sum of all the multiples of 3 or 5 below the provided parameter.
11-
*
11+
*
1212
* @param limit
1313
* @return
1414
*/
@@ -25,4 +25,4 @@ public Integer solution(Integer limit) {
2525

2626
return sum;
2727
}
28-
}
28+
}

examples/maven-demo/src/main/java/info/jab/demo/EulerProblem02.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ private static List<Long> fibonacci(Long limit) {
2727
/**
2828
* Even Fibonacci numbers
2929
* https://projecteuler.net/problem=2
30-
*
31-
* Each new term in the Fibonacci sequence is generated by adding the previous two terms.
30+
*
31+
* Each new term in the Fibonacci sequence is generated by adding the previous two terms.
3232
* By starting with 1 and 2, the first 10 terms will be:
3333
* 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
34-
*
35-
* By considering the terms in the Fibonacci sequence whose values do not exceed four million,
34+
*
35+
* By considering the terms in the Fibonacci sequence whose values do not exceed four million,
3636
* find the sum of the even-valued terms.
37-
*
37+
*
3838
* @param limit
3939
* @return
4040
*/

examples/maven-demo/src/test/java/info/jab/demo/EulerProblem01Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package info.jab.demo;
22

3-
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
4-
5-
import org.junit.jupiter.api.Test;
63
import info.jab.demo.utils.EulerAnswersLoader;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
77

88
class EulerProblem01Test {
99

examples/maven-demo/src/test/java/info/jab/demo/EulerProblem02Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package info.jab.demo;
22

3-
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
4-
5-
import org.junit.jupiter.api.Test;
63
import info.jab.demo.utils.EulerAnswersLoader;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
77

88
public class EulerProblem02Test {
99

examples/maven-demo/src/test/java/info/jab/demo/utils/EulerAnswersLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class EulerAnswersLoader {
1111
private List<String> loadFile() {
1212
try (var inputStream = getClass().getClassLoader().getResourceAsStream("euler/answers.txt");
1313
var reader = new BufferedReader(new InputStreamReader(inputStream))) {
14-
14+
1515
return reader.lines().toList();
1616
} catch (IOException e) {
1717
e.printStackTrace();

0 commit comments

Comments
 (0)