Skip to content

Commit

Permalink
Build for Java 8 rather than Java 7. (#2744)
Browse files Browse the repository at this point in the history
* Build for Java 8 rather than Java 7.

Part of #2743.

* Further adjustments to remove traces of Java 7.
  • Loading branch information
eamonnmcmanus authored Sep 23, 2024
1 parent 3ce6eb8 commit 58eaac3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
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

0 comments on commit 58eaac3

Please sign in to comment.