Skip to content

Commit b5aff87

Browse files
authored
feature: add profile to skip Gradle tests when Maven tests are skipped. Use same java version for the gradle task as for the maven (#23253)
* feature: add profile to skip Gradle tests when Maven tests are skipped. Use same java version for the gradle task as for the maven * feature: add profile to skip Gradle tests when Maven tests are skipped * feature: update Gradle build configuration to exclude tests while preserving quality checks
1 parent 41e861a commit b5aff87

File tree

1 file changed

+85
-1
lines changed
  • modules/openapi-generator-gradle-plugin

1 file changed

+85
-1
lines changed

modules/openapi-generator-gradle-plugin/pom.xml

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,24 @@
9999
<arg>-Psigning.secretKeyRingFile=${env.TRAVIS_BUILD_DIR}/sec.gpg</arg>
100100
-->
101101
</args>
102+
<!-- Force the Gradle daemon to use the same JVM Maven is running with.
103+
This prevents Gradle from picking up a system-level JDK (e.g. JDK 25)
104+
when Maven is configured to run on a different JDK (e.g. JDK 21). -->
105+
<jvmArgs>
106+
<jvmArg>-Dorg.gradle.java.home=${java.home}</jvmArg>
107+
</jvmArgs>
102108
</configuration>
103109
<executions>
104110
<execution>
111+
<id>gradle-build</id>
105112
<phase>install</phase>
106113
<goals>
107114
<!-- goal must be "invoke" -->
108115
<goal>invoke</goal>
109116
</goals>
110117
<configuration>
111118
<tasks>
112-
<!-- calls "clean assemble install" -->
119+
<!-- calls "clean build publishToMavenLocal" (build includes tests) -->
113120
<task>clean</task>
114121
<task>build</task>
115122
<task>publishToMavenLocal</task>
@@ -122,6 +129,83 @@
122129
</build>
123130

124131
<profiles>
132+
<profile>
133+
<id>skip-gradle-tests</id>
134+
<activation>
135+
<property>
136+
<name>maven.test.skip</name>
137+
<value>true</value>
138+
</property>
139+
</activation>
140+
<build>
141+
<plugins>
142+
<plugin>
143+
<groupId>org.fortasoft</groupId>
144+
<artifactId>gradle-maven-plugin</artifactId>
145+
<executions>
146+
<!-- Override the gradle-build execution: keep `build` (so checkstyle,
147+
spotbugs, and other check-lifecycle tasks still run) but add
148+
`-x test` to exclude only the Gradle test task, mirroring
149+
Maven's maven.test.skip behaviour which does not skip quality checks. -->
150+
<execution>
151+
<id>gradle-build</id>
152+
<configuration>
153+
<args combine.children="append">
154+
<arg>-x</arg>
155+
<arg>test</arg>
156+
</args>
157+
<tasks>
158+
<task>clean</task>
159+
<task>build</task>
160+
<task>publishToMavenLocal</task>
161+
</tasks>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
</profile>
169+
<profile>
170+
<id>skip-gradle-tests-skipTests</id>
171+
<activation>
172+
<property>
173+
<name>skipTests</name>
174+
<!-- Maven maps bare -DskipTests to the string "true", so this matches
175+
both -DskipTests and -DskipTests=true but NOT -DskipTests=false. -->
176+
<value>true</value>
177+
</property>
178+
</activation>
179+
<build>
180+
<plugins>
181+
<plugin>
182+
<groupId>org.fortasoft</groupId>
183+
<artifactId>gradle-maven-plugin</artifactId>
184+
<executions>
185+
<!-- Override the gradle-build execution: keep `build` (so checkstyle,
186+
spotbugs, and other check-lifecycle tasks still run) but add
187+
`-x test` to exclude only the Gradle test task.
188+
combine.children="append" appends to the plugin-level <args>
189+
instead of replacing them, preserving -P openApiGeneratorVersion. -->
190+
<execution>
191+
<id>gradle-build</id>
192+
<configuration>
193+
<args combine.children="append">
194+
<arg>-x</arg>
195+
<arg>test</arg>
196+
</args>
197+
<tasks>
198+
<task>clean</task>
199+
<task>build</task>
200+
<task>publishToMavenLocal</task>
201+
</tasks>
202+
</configuration>
203+
</execution>
204+
</executions>
205+
</plugin>
206+
</plugins>
207+
</build>
208+
</profile>
125209
<profile>
126210
<id>static-analysis</id>
127211
<build>

0 commit comments

Comments
 (0)