Add CI build using JDK 21 (#2552)
* Add CI build using JDK 21 This is mainly to make sure that besides the known JDK 21 build incompatibilities Gson can be built and run using JDK 21. * Update ProGuard * Update Protobuf 3.25.1 is actually newer than 4.0.0-rc-2
This commit is contained in:
parent
6f1a18af52
commit
4197bb6545
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -11,6 +11,12 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [ 11, 17 ]
|
java: [ 11, 17 ]
|
||||||
|
# Custom JDK 21 configuration
|
||||||
|
include:
|
||||||
|
- java: 21
|
||||||
|
# Disable Enforcer check which (intentionally) prevents using JDK 21 for building
|
||||||
|
# Exclude 'shrinker-test' module because R8 does not support JDK 21 yet
|
||||||
|
extra-mvn-args: -Denforcer.fail=false --projects '!:shrinker-test'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -23,7 +29,7 @@ jobs:
|
|||||||
cache: 'maven'
|
cache: 'maven'
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
# This also runs javadoc:jar to detect any issues with the Javadoc generated during release
|
# This also runs javadoc:jar to detect any issues with the Javadoc generated during release
|
||||||
run: mvn --batch-mode --no-transfer-progress verify javadoc:jar
|
run: mvn --batch-mode --no-transfer-progress verify javadoc:jar ${{ matrix.extra-mvn-args || '' }}
|
||||||
|
|
||||||
native-image-test:
|
native-image-test:
|
||||||
name: "GraalVM Native Image test"
|
name: "GraalVM Native Image test"
|
||||||
|
13
gson/pom.xml
13
gson/pom.xml
@ -191,6 +191,19 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<!-- Upgrades ProGuard to version newer than the one included by plugin by default -->
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.guardsquare</groupId>
|
||||||
|
<artifactId>proguard-base</artifactId>
|
||||||
|
<version>7.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.guardsquare</groupId>
|
||||||
|
<artifactId>proguard-core</artifactId>
|
||||||
|
<version>9.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<configuration>
|
<configuration>
|
||||||
<obfuscate>true</obfuscate>
|
<obfuscate>true</obfuscate>
|
||||||
<injar>test-classes-obfuscated-injar</injar>
|
<injar>test-classes-obfuscated-injar</injar>
|
||||||
|
@ -18,6 +18,7 @@ package com.google.gson.functional;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
@ -52,6 +53,9 @@ public class ReflectionAccessTest {
|
|||||||
@SuppressWarnings("removal") // java.lang.SecurityManager deprecation in Java 17
|
@SuppressWarnings("removal") // java.lang.SecurityManager deprecation in Java 17
|
||||||
@Test
|
@Test
|
||||||
public void testRestrictiveSecurityManager() throws Exception {
|
public void testRestrictiveSecurityManager() throws Exception {
|
||||||
|
// Skip for newer Java versions where `System.setSecurityManager` is unsupported
|
||||||
|
assumeTrue(Runtime.version().feature() <= 17);
|
||||||
|
|
||||||
// Must use separate class loader, otherwise permission is not checked, see
|
// Must use separate class loader, otherwise permission is not checked, see
|
||||||
// Class.getDeclaredFields()
|
// Class.getDeclaredFields()
|
||||||
Class<?> clazz = loadClassWithDifferentClassLoader(ClassWithPrivateMembers.class);
|
Class<?> clazz = loadClassWithDifferentClassLoader(ClassWithPrivateMembers.class);
|
||||||
|
14
pom.xml
14
pom.xml
@ -463,6 +463,20 @@
|
|||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
<!-- Slightly adjust build to support building with JDK >= 21
|
||||||
|
However, by default this will intentionally be blocked by the Maven Enforcer Plugin defined above
|
||||||
|
and must be explicitly circumvented to avoid building non-release Gson artifacts by accident -->
|
||||||
|
<profile>
|
||||||
|
<id>jdk21+</id>
|
||||||
|
<activation>
|
||||||
|
<jdk>[21,)</jdk>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<!-- JDK 21 does not support Java 7 as release, must use at least Java 8 -->
|
||||||
|
<maven.compiler.release>8</maven.compiler.release>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
|
||||||
<!-- Profile defining additional plugins to be executed for release -->
|
<!-- Profile defining additional plugins to be executed for release -->
|
||||||
<profile>
|
<profile>
|
||||||
<id>release</id>
|
<id>release</id>
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
<!-- Make the build reproducible, see root `pom.xml` -->
|
<!-- Make the build reproducible, see root `pom.xml` -->
|
||||||
<!-- This is duplicated here because that is recommended by `artifact:check-buildplan` -->
|
<!-- This is duplicated here because that is recommended by `artifact:check-buildplan` -->
|
||||||
<project.build.outputTimestamp>2023-01-01T00:00:00Z</project.build.outputTimestamp>
|
<project.build.outputTimestamp>2023-01-01T00:00:00Z</project.build.outputTimestamp>
|
||||||
|
|
||||||
|
<protobufVersion>3.25.1</protobufVersion>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
@ -50,7 +52,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.protobuf</groupId>
|
<groupId>com.google.protobuf</groupId>
|
||||||
<artifactId>protobuf-java</artifactId>
|
<artifactId>protobuf-java</artifactId>
|
||||||
<version>4.0.0-rc-2</version>
|
<version>${protobufVersion}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -89,7 +91,7 @@
|
|||||||
<artifactId>protobuf-maven-plugin</artifactId>
|
<artifactId>protobuf-maven-plugin</artifactId>
|
||||||
<version>0.6.1</version>
|
<version>0.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<protocArtifact>com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier}</protocArtifact>
|
<protocArtifact>com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}</protocArtifact>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -104,6 +104,19 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
<!-- Upgrades ProGuard to version newer than the one included by plugin by default -->
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.guardsquare</groupId>
|
||||||
|
<artifactId>proguard-base</artifactId>
|
||||||
|
<version>7.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.guardsquare</groupId>
|
||||||
|
<artifactId>proguard-core</artifactId>
|
||||||
|
<version>9.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<configuration>
|
<configuration>
|
||||||
<obfuscate>true</obfuscate>
|
<obfuscate>true</obfuscate>
|
||||||
<proguardInclude>${project.basedir}/proguard.pro</proguardInclude>
|
<proguardInclude>${project.basedir}/proguard.pro</proguardInclude>
|
||||||
@ -205,6 +218,7 @@
|
|||||||
but it appears that can be ignored -->
|
but it appears that can be ignored -->
|
||||||
<groupId>com.android.tools</groupId>
|
<groupId>com.android.tools</groupId>
|
||||||
<artifactId>r8</artifactId>
|
<artifactId>r8</artifactId>
|
||||||
|
<!-- TODO: When updating to a version which supports JDK 21, remove 'shrinker-test' exclusion from build.yml workflow -->
|
||||||
<version>8.1.72</version>
|
<version>8.1.72</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Loading…
Reference in New Issue
Block a user