Skip to content

Commit 0276deb

Browse files
authored
Drop support for Java 11 and modernize (#934)
1 parent b2b652b commit 0276deb

61 files changed

Lines changed: 606 additions & 802 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
common --java_language_version=17
2+
common --tool_java_language_version=17
3+
common --java_runtime_version=remotejdk_21
4+
common --tool_java_runtime_version=remotejdk_21

.github/workflows/nix.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
java: [11, 17, 21]
42+
java: [17, 21]
4343
steps:
4444
- uses: actions/checkout@v4
4545

@@ -150,7 +150,7 @@ jobs:
150150
strategy:
151151
fail-fast: false
152152
matrix:
153-
java: [11, 17, 21]
153+
java: [17, 21]
154154
steps:
155155
- uses: actions/checkout@v4
156156

.github/workflows/repos.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ jobs:
5656
fail-fast: false
5757
matrix:
5858
include:
59-
- name: gradle-java11-pusher
60-
repository: pusher/pusher-http-java
61-
ref: 94f25a2848e5939cf27dafad8ed25aeaa2d83274
62-
directory: .
63-
build_tool: gradle
64-
build_command: ""
65-
java: 11
66-
bazel_version: ""
67-
covers: Gradle, Java project target 11, Java 11 runtime
68-
6959
- name: maven-java17-spring-boot
7060
repository: spring-guides/gs-spring-boot
7161
ref: 2ffad4f418c3052b534184228a45d062f566096f
@@ -76,16 +66,6 @@ jobs:
7666
bazel_version: ""
7767
covers: Maven, Java project target 17, Java 17 runtime
7868

79-
- name: maven-java11-wagon-multimodule
80-
repository: apache/maven-wagon
81-
ref: 20b847446bb60f49af0428d592eadee774b5bff2
82-
directory: .
83-
build_tool: maven
84-
build_command: "-DskipTests compile"
85-
java: 11
86-
bazel_version: ""
87-
covers: Maven, multi-module Java, Java 11 runtime
88-
8969
- name: maven-kotlin-json-kotlin-maven
9070
repository: pwall567/json-kotlin-maven
9171
ref: 523f4fd624c3abca4a083c96be596d6f4799b705
@@ -108,16 +88,6 @@ jobs:
10888
bazel_version: ""
10989
covers: Gradle, Java project target 21, Java 21 runtime
11090

111-
- name: gradle-java11-mapstruct-lombok
112-
repository: mapstruct/mapstruct-examples
113-
ref: 3f9fd5ffe9e2272b6219a4216e842f8c009d1005
114-
directory: mapstruct-lombok
115-
build_tool: gradle
116-
build_command: "compileJava"
117-
java: 11
118-
bazel_version: ""
119-
covers: Gradle, Java annotation processors, Lombok, MapStruct, generated sources, Java 11 runtime
120-
12191
- name: gradle-kotlin-okio
12292
repository: square/okio
12393
ref: parent-3.16.0

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ scip-snapshots/META-INF/
7979
# writes META-INF/scip/sources/Test.kt.scip relative to the test
8080
# cwd.
8181
scip-kotlinc/META-INF/
82+
83+
/.kotlin/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The recommended way to get a working development environment is via
99
[Nix](https://nixos.org/download) and the provided [flake](https://github.com/sourcegraph/scip-java/blob/main/flake.nix):
1010

1111
```sh
12-
nix develop # default shell (JDK 11)
12+
nix develop # default shell (JDK 17)
1313
nix develop .#jdk17 # JDK 17
1414
nix develop .#jdk21 # JDK 21
1515
```
@@ -19,7 +19,7 @@ This drops you into a shell with `gradle`, `maven`, `bazelisk`, `nodejs`,
1919

2020
If you'd rather install tools manually, you'll need at least:
2121

22-
- `java`: any version should work
22+
- `java`: JDK 17 or newer
2323
- `git`: any version should work
2424
- `gradle`: `brew install gradle`, or see
2525
[general installation guide](https://gradle.org/install/).

bin/docker-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rm gradle.zip
1616
mv /opt/gradle/*/* /opt/gradle
1717

1818
# pre-install JDK for all major versions
19-
for JVM_VERSION in 21 17 11
19+
for JVM_VERSION in 21 17
2020
do
2121
coursier java --jvm $JVM_VERSION --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json -- -version
2222
done

bin/scip-java-docker-script.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# version. It assumes that `coursier` is available on the `$PATH` and that the
44
# `scip-java` binary is already installed at `/app/scip-java/bin/scip-java`.
55
set -eu
6-
JVM_VERSION="${JVM_VERSION:-21,17,11,8}"
6+
JVM_VERSION="${JVM_VERSION:-21,17}"
77
FILE="$PWD/lsif-java.json"
88
if test -f "$FILE"; then
99
FROM_CONFIG=$(jq -r '.jvm' "$FILE")
@@ -12,6 +12,13 @@ if test -f "$FILE"; then
1212
fi
1313
fi
1414

15+
# scip-java requires JDK 17+, all of which need these --add-exports to reach
16+
# internal javac APIs, so apply them unconditionally. The build derives them
17+
# from gradle/javac-internals.properties (the single source of truth) and ships
18+
# them ready-to-use in the distribution.
19+
JAVA_OPTS=$(cat /app/scip-java/javac-jvm-options)
20+
export JAVA_OPTS
21+
1522
JVM_VERSIONS=$(echo "$JVM_VERSION" | tr "," "\n")
1623

1724
LAST_CODE="-1"
@@ -21,11 +28,6 @@ do
2128
if [ "$LAST_CODE" != "0" ]; then
2229
echo "Using JVM version '$JVM_VERSION'"
2330

24-
if [ "$JVM_VERSION" = "17" ] || [ "$JVM_VERSION" = "21" ]; then
25-
export JAVA_OPTS="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
26-
else
27-
export JAVA_OPTS=""
28-
fi
2931
eval "$(coursier java --jvm "$JVM_VERSION" --env --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json)"
3032

3133
java -version

build.gradle.kts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ subprojects {
5757

5858
plugins.withType<JavaPlugin> {
5959
extensions.configure<JavaPluginExtension> {
60-
sourceCompatibility = JavaVersion.VERSION_11
61-
targetCompatibility = JavaVersion.VERSION_11
60+
sourceCompatibility = JavaVersion.VERSION_17
61+
targetCompatibility = JavaVersion.VERSION_17
6262
}
6363

6464
tasks.withType<JavaCompile>().configureEach {
6565
options.encoding = "UTF-8"
66-
options.release.set(11)
66+
options.release.set(17)
6767
}
6868

6969
tasks.withType<Javadoc>().configureEach {
@@ -81,7 +81,7 @@ subprojects {
8181

8282
plugins.withId("org.jetbrains.kotlin.jvm") {
8383
tasks.withType<KotlinCompile>().configureEach {
84-
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
84+
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
8585
}
8686
}
8787
}
@@ -342,10 +342,26 @@ project(":scip-java") {
342342
}
343343
}
344344

345+
// Emit the javac --add-exports flags as a ready-to-use, space-separated
346+
// string so the Docker wrapper script can read them with a plain `cat`,
347+
// keeping gradle/javac-internals.properties the single source of truth.
348+
val generateJavacJvmOptions = tasks.register("generateJavacJvmOptions") {
349+
val output = layout.buildDirectory.file("generated/distribution/javac-jvm-options")
350+
val options = javacJvmOptions.joinToString(" ")
351+
inputs.property("options", options)
352+
outputs.file(output)
353+
doLast {
354+
val file = output.get().asFile
355+
file.parentFile.mkdirs()
356+
file.writeText("$options\n")
357+
}
358+
}
359+
345360
extensions.configure<DistributionContainer> {
346361
named("main") {
347362
contents {
348363
from(generateDistributionVersion)
364+
from(generateJavacJvmOptions)
349365
}
350366
}
351367
}
@@ -455,7 +471,7 @@ project(":scip-snapshots") {
455471
rootProject.layout.projectDirectory.dir("scip-snapshots/expected/kotlin/common").asFile.absolutePath,
456472
"snapshot.case.kotlin-common.targetroot" to kotlinTargetroot.get().asFile.absolutePath,
457473
"snapshot.case.kotlin-common.aggregateNoEmitInverseRelationships" to "true",
458-
"scip.jdk.version" to "11",
474+
"scip.jdk.version" to "17",
459475
)
460476

461477
tasks.named<Test>("test") {

docs/getting-started.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ finished indexing the project.
3535

3636
> The `sourcegraph/scip-java` Docker image is made available for convenience at
3737
> the cost of performance. The `sourcegraph/scip-java` image is a big download
38-
> because it includes pre-installed versions of Java 11, Java 17, and Java 21.
38+
> because it includes pre-installed versions of Java 17 and Java 21.
3939
> The `sourcegraph/scip-java` image has slow performance because it needs to
4040
> download all external dependencies of your codebase on every invocation.
4141
>
@@ -46,9 +46,6 @@ Java 17 is the default Java version in the `sourcegraph/scip-java` Docker image.
4646
Use the following commands to use a different JVM version:
4747

4848
```sh
49-
# Java 11
50-
docker run -v $(pwd):/sources --env JVM_VERSION=11 sourcegraph/scip-java:latest scip-java index
51-
5249
# Java 17 (default)
5350
docker run -v $(pwd):/sources --env JVM_VERSION=17 sourcegraph/scip-java:latest scip-java index
5451

@@ -60,7 +57,7 @@ docker run -v $(pwd):/sources --env JVM_VERSION=21 sourcegraph/scip-java:latest
6057
### Java launcher
6158

6259
Use the Java launcher to install `scip-java` on your local computer or any
63-
Docker image with a pre-installed Java version.
60+
Docker image with a pre-installed Java version (JDK 17 or newer).
6461

6562
```sh
6663
# macOS/Linux
@@ -86,7 +83,8 @@ the `index` subcommand.
8683
### Java fat jar
8784

8885
Use the fat jar option to build a standalone `scip-java` executable. Note that
89-
you still need a Java installation to run the `scip-java` binary.
86+
you still need a Java installation (JDK 17 or newer) to run the `scip-java`
87+
binary.
9088

9189
```sh
9290
# macOS/Linux
@@ -204,7 +202,7 @@ of Java versions.
204202
| ------------ | ---------------------------- | -------------- |
205203
| Java 7 || |
206204
| Java 8 || |
207-
| Java 11 | | |
205+
| Java 11 | | |
208206
| Java 17 | ✅, requires `--add-exports` | |
209207
| Java 21 | ✅, requires `--add-exports` | |
210208

docs/manual-configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ targetroot directory.
117117

118118
```
119119
❯ find $TARGETROOT -type f
120-
build/scip-targetroot/META-INF/scip/j11/src/test/java/example/ExampleTest.java.scip
121-
build/scip-targetroot/META-INF/scip/j11/src/main/java/example/Example.java.scip
120+
build/scip-targetroot/META-INF/scip/j17/src/test/java/example/ExampleTest.java.scip
121+
build/scip-targetroot/META-INF/scip/j17/src/main/java/example/Example.java.scip
122122
...
123123
```
124124

0 commit comments

Comments
 (0)