Skip to content

Commit de0605b

Browse files
authored
Merge pull request opentripplanner#7116 from entur/fix-prettier-double-execution
Reorganize Maven project to prevent double execution of prettier
2 parents 697f9d1 + 8c7851a commit de0605b

File tree

6 files changed

+68
-38
lines changed

6 files changed

+68
-38
lines changed

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ mvn prettier:check
4848

4949
# Spotless removes unused imports
5050
# Runs automatically during build (validate phase)
51+
52+
# OpenRewrite for code refactoring and modernization
53+
# Run with the -Prewrite (or -Drw shortcut):
54+
mvn validate -Prewrite
5155
```
5256

5357
## Running OTP
@@ -257,3 +261,4 @@ Features not yet part of core OTP can be developed as Sandbox extensions. These
257261
- Use feature flags (disabled by default)
258262
- Have conditional code blocks in core OTP
259263
- See: http://docs.opentripplanner.org/en/latest/SandboxExtension/
264+
- Use comments sparingly. Only comment complex code.

application/pom.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,12 @@
520520
<groupId>com.hubspot.maven.plugins</groupId>
521521
<artifactId>prettier-maven-plugin</artifactId>
522522
<configuration>
523-
<inputGlobs>
524-
<inputGlob>src/main/java/**/*.java</inputGlob>
523+
<inputGlobs combine.children="append">
524+
<!-- Additional patterns specific to the application module -->
525525
<inputGlob>src/ext/java/**/*.java</inputGlob>
526-
<inputGlob>src/test/java/**/*.java</inputGlob>
527-
<inputGlob>src/test-fixtures/java/**/*.java</inputGlob>
528526
<inputGlob>src/ext-test/java/**/*.java</inputGlob>
529527
<inputGlob>src/**/*.json</inputGlob>
530528
<inputGlob>src/test/resources/org/opentripplanner/apis/**/*.graphql</inputGlob>
531-
<!-- Ignore patterns. -->
532529
<inputGlob>!src/test/resources/org/opentripplanner/apis/vectortiles/style.json</inputGlob>
533530
</inputGlobs>
534531
</configuration>

astar/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
<name>OpenTripPlanner - A*</name>
1414

1515
<build>
16-
<plugins/>
16+
<plugins>
17+
<plugin>
18+
<groupId>com.hubspot.maven.plugins</groupId>
19+
<artifactId>prettier-maven-plugin</artifactId>
20+
</plugin>
21+
</plugins>
1722
</build>
1823

1924
<dependencies>

pom.xml

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@
117117
<groupId>com.hubspot.maven.plugins</groupId>
118118
<artifactId>prettier-maven-plugin</artifactId>
119119
<version>${plugin.prettier.version}</version>
120+
<configuration>
121+
<skip>${plugin.prettier.skip}</skip>
122+
<prettierJavaVersion>2.6.8</prettierJavaVersion>
123+
<inputGlobs>
124+
<inputGlob>src/main/java/**/*.java</inputGlob>
125+
<inputGlob>src/test/java/**/*.java</inputGlob>
126+
<inputGlob>src/test-fixtures/java/**/*.java</inputGlob>
127+
</inputGlobs>
128+
</configuration>
129+
<executions>
130+
<execution>
131+
<id>prettier-format</id>
132+
<phase>validate</phase>
133+
<goals>
134+
<goal>${plugin.prettier.goal}</goal>
135+
</goals>
136+
</execution>
137+
</executions>
120138
</plugin>
121139
</plugins>
122140
</pluginManagement>
@@ -334,14 +352,6 @@
334352
<version>2.22.0</version>
335353
</dependency>
336354
</dependencies>
337-
<executions>
338-
<execution>
339-
<phase>validate</phase>
340-
<goals>
341-
<goal>run</goal>
342-
</goals>
343-
</execution>
344-
</executions>
345355
</plugin>
346356
<plugin>
347357
<groupId>org.apache.maven.plugins</groupId>
@@ -376,28 +386,6 @@
376386
</execution>
377387
</executions>
378388
</plugin>
379-
380-
<plugin>
381-
<groupId>com.hubspot.maven.plugins</groupId>
382-
<artifactId>prettier-maven-plugin</artifactId>
383-
<configuration>
384-
<skip>${plugin.prettier.skip}</skip>
385-
<prettierJavaVersion>2.6.8</prettierJavaVersion>
386-
<inputGlobs>
387-
<inputGlob>src/main/java/**/*.java</inputGlob>
388-
<inputGlob>src/test/java/**/*.java</inputGlob>
389-
<inputGlob>src/test-fixtures/java/**/*.java</inputGlob>
390-
</inputGlobs>
391-
</configuration>
392-
<executions>
393-
<execution>
394-
<phase>validate</phase>
395-
<goals>
396-
<goal>${plugin.prettier.goal}</goal>
397-
</goals>
398-
</execution>
399-
</executions>
400-
</plugin>
401389
<plugin>
402390
<groupId>com.google.cloud.tools</groupId>
403391
<artifactId>jib-maven-plugin</artifactId>
@@ -630,8 +618,8 @@
630618
<activation>
631619
<property>
632620
<!--
633-
This works as a short alias to enable this from the command line. To skip
634-
rewrite, set the 'rw' system property with the '-D rw' parameter.
621+
This works as a short alias to enable this from the command line.
622+
To run rewrite, set the 'rw' system property with the '-Drw' parameter.
635623
-->
636624
<name>rw</name>
637625
<value/>
@@ -641,6 +629,23 @@
641629
<plugin.rewrite.skip>false</plugin.rewrite.skip>
642630
<plugin.checkstyle.skip>true</plugin.checkstyle.skip>
643631
</properties>
632+
<build>
633+
<plugins>
634+
<plugin>
635+
<groupId>org.openrewrite.maven</groupId>
636+
<artifactId>rewrite-maven-plugin</artifactId>
637+
<executions>
638+
<execution>
639+
<id>rewrite-run</id>
640+
<phase>validate</phase>
641+
<goals>
642+
<goal>run</goal>
643+
</goals>
644+
</execution>
645+
</executions>
646+
</plugin>
647+
</plugins>
648+
</build>
644649
</profile>
645650
<profile>
646651
<id>clean-test-snapshots</id>

raptor/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
<artifactId>raptor</artifactId>
1313
<name>OpenTripPlanner - Raptor</name>
1414

15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>com.hubspot.maven.plugins</groupId>
19+
<artifactId>prettier-maven-plugin</artifactId>
20+
</plugin>
21+
</plugins>
22+
</build>
23+
1524
<dependencies>
1625
<!-- project dependencies -->
1726

utils/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
<artifactId>utils</artifactId>
1313
<name>OpenTripPlanner - Utils</name>
1414

15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>com.hubspot.maven.plugins</groupId>
19+
<artifactId>prettier-maven-plugin</artifactId>
20+
</plugin>
21+
</plugins>
22+
</build>
23+
1524
<dependencies>
1625
<!-- This is the ONLY allowed dependency -->
1726
<dependency>

0 commit comments

Comments
 (0)