Skip to content

Commit fbf8ab0

Browse files
committed
feature: add profile to skip Gradle tests when Maven tests are skipped. Use same java version for the gradle task as for the maven
1 parent 0c31459 commit fbf8ab0

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

  • modules/openapi-generator-gradle-plugin

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

Lines changed: 39 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,37 @@
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: swap `build` (assemble + test)
147+
for `assemble` (no tests) when -Dmaven.test.skip=true is set. -->
148+
<execution>
149+
<id>gradle-build</id>
150+
<configuration>
151+
<tasks>
152+
<task>clean</task>
153+
<task>assemble</task>
154+
<task>publishToMavenLocal</task>
155+
</tasks>
156+
</configuration>
157+
</execution>
158+
</executions>
159+
</plugin>
160+
</plugins>
161+
</build>
162+
</profile>
125163
<profile>
126164
<id>static-analysis</id>
127165
<build>

0 commit comments

Comments
 (0)