Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for Java 8 rather than Java 7. #2744

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Maven:

### Requirements
#### Minimum Java version
- Gson 2.9.0 and newer: Java 7
- Gson 2.12.0 and newer: Java 8
- Gson 2.9.0 to 2.11.0: Java 7
- Gson 2.8.9 and older: Java 6

Despite supporting older Java versions, Gson also provides a JPMS module descriptor (module name `com.google.gson`) for users of Java 9 or newer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ public void testExports() {

@Test
public void testRequireCapability() {
// When building with JDK >= 21, the minimum target version is Java 8
String expectedJavaVersion = Runtime.version().feature() < 21 ? "1.7" : "1.8";
String expectedJavaVersion = "1.8";

// Defines the minimum required Java version
assertThat(getAttribute("Require-Capability"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class JavaVersionTest {

@Test
public void testGetMajorJavaVersion() {
// Gson currently requires at least Java 7
assertThat(JavaVersion.getMajorJavaVersion()).isAtLeast(7);
// Gson currently requires at least Java 8
assertThat(JavaVersion.getMajorJavaVersion()).isAtLeast(8);
}

@Test
Expand Down
16 changes: 1 addition & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>7</maven.compiler.release>
<maven.compiler.release>8</maven.compiler.release>
<maven.compiler.testRelease>11</maven.compiler.testRelease>

<!-- Make the build reproducible, see https://maven.apache.org/guides/mini/guide-reproducible-builds.html -->
Expand Down Expand Up @@ -556,20 +556,6 @@
</build>
</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>
<id>release</id>
Expand Down