Skip to content

Commit d840a3b

Browse files
iamsanjaydsmiley
andauthored
Bump up Java version to 21 (#2682)
* The minimum Java version for the main branch is 21, except for the SolrJ main package, which requires version 17. --------- Co-authored-by: David Smiley <[email protected]>
1 parent 457ca36 commit d840a3b

File tree

29 files changed

+105
-108
lines changed

29 files changed

+105
-108
lines changed

.github/workflows/bin-solr-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
steps:
2525
# Setup
2626
- uses: actions/checkout@v4
27-
- name: Set up JDK 11
27+
- name: Set up JDK
2828
uses: actions/setup-java@v4
2929
with:
3030
distribution: 'temurin'
31-
java-version: 11
31+
java-version: 21
3232
java-package: jdk
3333
- name: Setup Gradle
3434
uses: gradle/actions/setup-gradle@v4

.github/workflows/docker-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
steps:
2727
# Setup
2828
- uses: actions/checkout@v4
29-
- name: Set up JDK 11
29+
- name: Set up JDK 21
3030
uses: actions/setup-java@v4
3131
with:
3232
distribution: 'temurin'
33-
java-version: 11
33+
java-version: 21
3434
java-package: jdk
3535
- name: Setup Gradle
3636
uses: gradle/actions/setup-gradle@v4

.github/workflows/gradle-precommit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
name: gradle check w/ Java 11
11+
name: gradle check
1212

1313
runs-on: ubuntu-latest
1414

@@ -19,11 +19,11 @@ jobs:
1919
# Setup
2020
- uses: actions/checkout@v4
2121

22-
- name: Set up JDK 11
22+
- name: Set up JDK
2323
uses: actions/setup-java@v4
2424
with:
2525
distribution: 'temurin'
26-
java-version: 11
26+
java-version: 21
2727
java-package: jdk
2828

2929
- name: Setup Gradle

.github/workflows/solrj-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
steps:
2222
# Setup
2323
- uses: actions/checkout@v4
24-
- name: Set up JDK 11
24+
- name: Set up JDK 21
2525
uses: actions/setup-java@v4
2626
with:
2727
distribution: 'temurin'
28-
java-version: 11
28+
java-version: 21
2929
java-package: jdk
3030
- name: Setup Gradle
3131
uses: gradle/actions/setup-gradle@v4

build-tools/scriptDepVersions.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
ext {
2323
scriptDepVersions = [
24-
"min-java-version": "11",
24+
"min-java-version": "21",
25+
"min-solrj-java-version" : "17",
2526
"apache-rat": "0.15",
2627
"commons-codec": "1.16.0",
27-
"ecj": "3.33.0",
28+
"ecj": "3.36.0",
2829
"javacc": "7.0.12",
2930
"jgit": "6.7.0.202309050840-r",
3031
"flexmark": "0.64.8",

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ apply from: file('build-tools/scriptDepVersions.gradle')
3535

3636
// Declare default Java versions for the entire project and for SolrJ separately
3737
rootProject.ext.minJavaVersionDefault = JavaVersion.toVersion(scriptDepVersions['min-java-version'])
38-
rootProject.ext.minJavaVersionSolrJ = JavaVersion.toVersion(scriptDepVersions['min-java-version'])
38+
rootProject.ext.minJavaVersionSolrJ = JavaVersion.toVersion(scriptDepVersions['min-solrj-java-version'])
3939

4040
apply from: file('gradle/globals.gradle')
4141

crave.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Solr:
2+
image: "accupara/openjdk:21"

dev-docs/solr-source-code.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Building Solr from Source
44

5-
Download the Java 11 JDK (Java Development Kit) or later.
5+
Download the Java 21 JDK (Java Development Kit) or later.
66
We recommend the OpenJDK distribution Eclipse Temurin available from https://adoptium.net/.
77
You will need the JDK installed, and the $JAVA_HOME/bin (Windows: %JAVA_HOME%\bin) folder included on your command path.
8-
To test this, issue a "java -version" command from your shell (command prompt) and verify that the Java version is 11 or later.
8+
To test this, issue a "java -version" command from your shell (command prompt) and verify that the Java version is 21 or later.
99
See the xref:jvms.adoc[JVM developer doc] for more information on Gradle and JVMs.
1010

1111
Clone the latest Apache Solr source code directly from the Git repository: <https://solr.apache.org/community.html#version-control>.

gradle/globals.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,6 @@ allprojects {
173173
// Assign different java version for client-side modules 'api' and 'solrj*'
174174
var isSolrJ = project.name.matches("^(solrj.*|api)\$")
175175
minJavaVersion = isSolrJ ? rootProject.minJavaVersionSolrJ : rootProject.minJavaVersionDefault
176+
minJavaTestVersion = rootProject.minJavaVersionDefault
176177
}
177178
}

gradle/java/javac.gradle

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919

2020
allprojects {
2121
plugins.withType(JavaPlugin) {
22-
sourceCompatibility = project.minJavaVersion
23-
targetCompatibility = project.minJavaVersion
24-
25-
// Use 'release' flag instead of 'source' and 'target'
26-
tasks.withType(JavaCompile) {
27-
options.compilerArgs += ["--release", project.minJavaVersion.toString()]
28-
}
29-
22+
// Use 'release' flag instead of 'source' and 'target'
23+
tasks.withType(JavaCompile) {
24+
compileTestJava {
25+
sourceCompatibility = project.minJavaTestVersion
26+
targetCompatibility = project.minJavaTestVersion
27+
options.compilerArgs += ["--release", project.minJavaTestVersion.toString()]
28+
}
29+
compileJava {
30+
sourceCompatibility = project.minJavaVersion
31+
targetCompatibility = project.minJavaVersion
32+
options.compilerArgs += ["--release", project.minJavaVersion.toString()]
33+
}
34+
}
3035
// Configure warnings.
3136
tasks.withType(JavaCompile) {
3237
options.encoding = "UTF-8"
@@ -51,22 +56,12 @@ allprojects {
5156
"-Xdoclint:all/protected",
5257
"-Xdoclint:-missing",
5358
"-Xdoclint:-accessibility",
59+
"-Xlint:synchronization",
60+
"-Xlint:text-blocks",
5461
"-proc:none", // proc:none was added because of LOG4J2-1925 / JDK-8186647
62+
"-Xlint:removal"
5563
]
5664

57-
// enable some warnings only relevant to newer language features
58-
if (rootProject.runtimeJavaVersion >= JavaVersion.VERSION_15) {
59-
options.compilerArgs += [
60-
"-Xlint:text-blocks",
61-
]
62-
}
63-
64-
if (rootProject.runtimeJavaVersion >= JavaVersion.VERSION_16) {
65-
options.compilerArgs += [
66-
"-Xlint:synchronization",
67-
]
68-
}
69-
7065
if (propertyOrDefault("javac.failOnWarnings", true).toBoolean()) {
7166
options.compilerArgs += "-Werror"
7267
}

0 commit comments

Comments
 (0)