Skip to content

Commit 2c6bb61

Browse files
committed
fix: Add maven enforcer rule for JDK version, as 12+ fails
Before: ``` [ERROR] Tests run: 8, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.040 s <<< FAILURE! -- in cz.habarta.typescript.generator.NamingTest [ERROR] cz.habarta.typescript.generator.NamingTest.testCombinations -- Time elapsed: 0.032 s <<< ERROR! java.lang.NoSuchMethodError: 'void sun.misc.Unsafe.ensureClassInitialized(java.lang.Class)' at com.oracle.truffle.api.library.LibraryFactory.ensureLibraryInitialized(LibraryFactory.java:384) ``` Now, if you are not running Java 11: ``` [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.5.0:enforce (enforce-java-version) on project typescript-generator: [ERROR] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message: [ERROR] Detected JDK version 23.0.1 (JAVA_HOME=/opt/homebrew/Cellar/openjdk/23.0.1/libexec/openjdk.jdk/Contents/Home) is not in the allowed range [11,12). ``` Fixing it by appending the correct `JAVA_HOME`: ``` ➤ JAVA_HOME=(/usr/libexec/java_home --version 11) mvn clean install ... [INFO] BUILD SUCCESS ... ```
1 parent 80ad439 commit 2c6bb61

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,30 @@
160160
<build>
161161

162162
<plugins>
163+
<plugin>
164+
<groupId>org.apache.maven.plugins</groupId>
165+
<artifactId>maven-enforcer-plugin</artifactId>
166+
<version>3.5.0</version>
167+
<executions>
168+
<execution>
169+
<id>enforce-java-version</id>
170+
<goals>
171+
<goal>enforce</goal>
172+
</goals>
173+
<phase>validate</phase>
174+
</execution>
175+
</executions>
176+
<configuration>
177+
<rules>
178+
<requireMavenVersion>
179+
<version>[3,4]</version>
180+
</requireMavenVersion>
181+
<requireJavaVersion>
182+
<version>[11,12)</version>
183+
</requireJavaVersion>
184+
</rules>
185+
</configuration>
186+
</plugin>
163187
<plugin>
164188
<groupId>org.apache.maven.plugins</groupId>
165189
<artifactId>maven-compiler-plugin</artifactId>

0 commit comments

Comments
 (0)