Skip to content

Commit aadaa92

Browse files
authored
Upgrade to openrewrite 21
See: #11
1 parent 0456c2f commit aadaa92

24 files changed

+400
-297
lines changed

build.gradle.kts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
plugins {
22
`java-library`
33
`maven-publish`
4-
id("com.github.johnrengelman.shadow") version "8.1.1"
4+
id("com.gradleup.shadow") version "8.3.5"
55
}
66

7-
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
7+
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
88
tasks.shadowJar { archiveClassifier.set("final"); mergeServiceFiles() }
99

1010
repositories {
1111
mavenCentral()
1212
}
1313

1414
dependencies {
15-
api("org.openrewrite:rewrite-java-17:8.7.4")
15+
api("org.openrewrite:rewrite-java-21:8.40.3")
1616
api("org.cadixdev:at:0.1.0-rc1")
17-
implementation("org.apache.logging.log4j:log4j-core:3.0.0-alpha1")
18-
implementation("org.slf4j:slf4j-api:2.0.9")
17+
implementation("org.apache.logging.log4j:log4j-core:3.0.0-beta3")
18+
implementation("org.slf4j:slf4j-api:2.0.16")
1919

20-
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
20+
testImplementation("org.junit.jupiter:junit-jupiter:5.11.3")
2121
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2222
}
2323

gradle/wrapper/gradle-wrapper.jar

-19.7 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

+12-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
4345
%JAVA_EXE% -version >NUL 2>&1
4446
if %ERRORLEVEL% equ 0 goto execute
4547

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5153

5254
goto fail
5355

@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5759

5860
if exist "%JAVA_EXE%" goto execute
5961

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6567

6668
goto fail
6769

restamp-cli/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
plugins {
22
java
3-
id("com.github.johnrengelman.shadow") version "8.1.1"
3+
id("com.gradleup.shadow") version "8.3.5"
44
}
55

6-
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
6+
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
77
tasks.shadowJar { archiveClassifier.set("final"); mergeServiceFiles() }
88
tasks.assemble { dependsOn(tasks.shadowJar) }
99
tasks.jar {
@@ -23,7 +23,7 @@ repositories {
2323

2424
dependencies {
2525
implementation(projects.restamp)
26-
implementation("info.picocli:picocli:4.7.5")
26+
implementation("info.picocli:picocli:4.7.6")
2727
}
2828

2929
tasks.test {

src/main/java/io/papermc/restamp/Restamp.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.cadixdev.at.AccessTransform;
99
import org.cadixdev.at.AccessTransformSet;
1010
import org.cadixdev.bombe.type.signature.MethodSignature;
11-
import org.jetbrains.annotations.NotNull;
11+
import org.jspecify.annotations.NullMarked;
1212
import org.openrewrite.Changeset;
1313
import org.openrewrite.config.CompositeRecipe;
1414
import org.openrewrite.internal.InMemoryLargeSourceSet;
@@ -20,6 +20,7 @@
2020
/**
2121
* The main executor of restamp.
2222
*/
23+
@NullMarked
2324
public class Restamp {
2425

2526
/**
@@ -29,8 +30,7 @@ public class Restamp {
2930
*
3031
* @return the computed changeset.
3132
*/
32-
@NotNull
33-
public static Changeset run(@NotNull final RestampInput input) {
33+
public static Changeset run(final RestampInput input) {
3434
final ModifierTransformer modifierTransformer = new ModifierTransformer();
3535
final AccessTransformerTypeConverter accessTransformerTypeConverter = new AccessTransformerTypeConverter();
3636
final AccessTransformSet accessTransformSet = input.accessTransformers();

src/main/java/io/papermc/restamp/RestampContextConfiguration.java

+26-35
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import org.cadixdev.at.io.AccessTransformFormat;
55
import org.cadixdev.at.io.AccessTransformFormats;
66
import org.jetbrains.annotations.Contract;
7-
import org.jetbrains.annotations.NotNull;
8-
import org.jetbrains.annotations.Nullable;
7+
import org.jspecify.annotations.NullMarked;
8+
import org.jspecify.annotations.Nullable;
99
import org.openrewrite.ExecutionContext;
1010

1111
import java.io.IOException;
@@ -30,12 +30,13 @@
3030
* @param failWithNotApplicableAccessTransformers whether restamp should fail if not all access transformers defined in {@code accessTransformers}
3131
* were consumed by restamp.
3232
*/
33+
@NullMarked
3334
public record RestampContextConfiguration(
34-
@NotNull ExecutionContext executionContext,
35-
@NotNull AccessTransformSet accessTransformSet,
36-
@NotNull Path sourceRoot,
37-
@NotNull List<Path> sourceFiles,
38-
@NotNull List<Path> classpath,
35+
ExecutionContext executionContext,
36+
AccessTransformSet accessTransformSet,
37+
Path sourceRoot,
38+
List<Path> sourceFiles,
39+
List<Path> classpath,
3940
boolean failWithNotApplicableAccessTransformers
4041
) {
4142

@@ -44,7 +45,7 @@ public record RestampContextConfiguration(
4445
*
4546
* @return the build instance.
4647
*/
47-
@NotNull
48+
4849
@Contract(value = "-> new", pure = true)
4950
public static Builder builder() {
5051
return new Builder();
@@ -59,10 +60,10 @@ public static class Builder {
5960
private @Nullable AccessTransformSet accessTransformSet;
6061
private @Nullable Path sourceRoot;
6162
private @Nullable List<Path> sourceFiles;
62-
private @NotNull SourceFileMode sourceFileMode = SourceFileMode.MANUAL;
63+
private SourceFileMode sourceFileMode = SourceFileMode.MANUAL;
6364
private boolean failWithNotApplicableAccessTransformers = false;
6465

65-
private @NotNull List<Path> classpath = Collections.emptyList();
66+
private List<Path> classpath = Collections.emptyList();
6667

6768
/**
6869
* Sets the execution context used by restamp for both parsing and running.
@@ -71,9 +72,9 @@ public static class Builder {
7172
*
7273
* @return this builder.
7374
*/
74-
@NotNull
75+
7576
@Contract(value = "_ -> this", mutates = "this")
76-
public Builder executionContext(@NotNull final ExecutionContext executionContext) {
77+
public Builder executionContext(final ExecutionContext executionContext) {
7778
this.executionContext = executionContext;
7879
return this;
7980
}
@@ -84,13 +85,12 @@ public Builder executionContext(@NotNull final ExecutionContext executionContext
8485
*
8586
* @param accessTransformerPath the path to the access transformers.
8687
*
87-
* @throws IOException when something goes wrong loading the accessTransformSet
88-
*
8988
* @return this builder.
89+
*
90+
* @throws IOException when something goes wrong loading the accessTransformSet
9091
*/
91-
@NotNull
9292
@Contract(value = "_ -> this", mutates = "this")
93-
public Builder accessTransformers(@NotNull final Path accessTransformerPath) throws IOException {
93+
public Builder accessTransformers(final Path accessTransformerPath) throws IOException {
9494
return this.accessTransformers(accessTransformerPath, AccessTransformFormats.FML);
9595
}
9696

@@ -100,28 +100,25 @@ public Builder accessTransformers(@NotNull final Path accessTransformerPath) thr
100100
* @param accessTransformerPath the path to the access transformers.
101101
* @param accessTransformerFormat the format of the access transformers defined in the file at the provided path.
102102
*
103-
* @throws IOException when something goes wrong loading the accessTransformSet
104-
*
105103
* @return this builder.
104+
*
105+
* @throws IOException when something goes wrong loading the accessTransformSet
106106
*/
107-
@NotNull
108107
@Contract(value = "_,_ -> this", mutates = "this")
109-
public Builder accessTransformers(@NotNull final Path accessTransformerPath, @NotNull final AccessTransformFormat accessTransformerFormat) throws IOException {
108+
public Builder accessTransformers(final Path accessTransformerPath, final AccessTransformFormat accessTransformerFormat) throws IOException {
110109
this.accessTransformSet = accessTransformerFormat.read(accessTransformerPath);
111110
return this;
112111
}
113112

114113
/**
115-
* Sets the path pointing to the file holding the access transformers.
114+
* Sets the access transformer set to be used by restamp.
116115
*
117-
* @param accessTransformerPath the path to the access transformers.
118-
* @param accessTransformerFormat the format of the access transformers defined in the file at the provided path.
116+
* @param accessTransformSet the transformer set.
119117
*
120118
* @return this builder.
121119
*/
122-
@NotNull
123120
@Contract(value = "_,_ -> this", mutates = "this")
124-
public Builder accessTransformSet(@NotNull final AccessTransformSet accessTransformSet) {
121+
public Builder accessTransformSet(final AccessTransformSet accessTransformSet) {
125122
this.accessTransformSet = AccessTransformSet.create();
126123
this.accessTransformSet.merge(accessTransformSet);
127124
return this;
@@ -134,9 +131,8 @@ public Builder accessTransformSet(@NotNull final AccessTransformSet accessTransf
134131
*
135132
* @return this builder.
136133
*/
137-
@NotNull
138134
@Contract(value = "_ -> this", mutates = "this")
139-
public Builder sourceRoot(@NotNull final Path sourceRoot) {
135+
public Builder sourceRoot(final Path sourceRoot) {
140136
this.sourceRoot = sourceRoot;
141137
return this;
142138
}
@@ -148,9 +144,8 @@ public Builder sourceRoot(@NotNull final Path sourceRoot) {
148144
*
149145
* @return this builder.
150146
*/
151-
@NotNull
152147
@Contract(value = "_ -> this", mutates = "this")
153-
public Builder sourceFiles(@NotNull final List<Path> sourceFiles) {
148+
public Builder sourceFiles(final List<Path> sourceFiles) {
154149
this.sourceFiles = sourceFiles;
155150
return this;
156151
}
@@ -163,7 +158,6 @@ public Builder sourceFiles(@NotNull final List<Path> sourceFiles) {
163158
*
164159
* @return this builder.
165160
*/
166-
@NotNull
167161
@Contract(value = "-> this", mutates = "this")
168162
public Builder sourceFilesFromAccessTransformers() {
169163
this.sourceFileMode = SourceFileMode.FROM_AT_STRICT;
@@ -177,9 +171,9 @@ public Builder sourceFilesFromAccessTransformers() {
177171
* If {@link #sourceFiles(List)} is called on this builder with a non-empty list, this option is meaningless.
178172
*
179173
* @param strict if true, restamp will fail if there are source files referenced in the ATs that don't exist.
174+
*
180175
* @return this builder.
181176
*/
182-
@NotNull
183177
@Contract(value = "_ -> this", mutates = "this")
184178
public Builder sourceFilesFromAccessTransformers(final boolean strict) {
185179
this.sourceFileMode = strict ? SourceFileMode.FROM_AT_STRICT : SourceFileMode.FROM_AT_GRACEFUL;
@@ -193,9 +187,8 @@ public Builder sourceFilesFromAccessTransformers(final boolean strict) {
193187
*
194188
* @return this builder.
195189
*/
196-
@NotNull
197190
@Contract(value = "_ -> this", mutates = "this")
198-
public Builder classpath(@NotNull final List<Path> classpath) {
191+
public Builder classpath(final List<Path> classpath) {
199192
this.classpath = classpath;
200193
return this;
201194
}
@@ -206,7 +199,6 @@ public Builder classpath(@NotNull final List<Path> classpath) {
206199
*
207200
* @return this builder.
208201
*/
209-
@NotNull
210202
@Contract(value = "-> this", mutates = "this")
211203
public Builder failWithNotApplicableAccessTransformers() {
212204
this.failWithNotApplicableAccessTransformers = true;
@@ -222,7 +214,6 @@ public Builder failWithNotApplicableAccessTransformers() {
222214
* @throws IOException if parsing the access transformer set failed due to an {@link IOException}.
223215
*/
224216
@Contract(value = "-> new", pure = true)
225-
@NotNull
226217
public RestampContextConfiguration build() throws IllegalStateException {
227218
if (this.executionContext == null) throw new IllegalStateException("Cannot build without an execution context");
228219
if (this.accessTransformSet == null) throw new IllegalStateException("Cannot build without access transformers!");

src/main/java/io/papermc/restamp/RestampInput.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.papermc.restamp;
22

33
import org.cadixdev.at.AccessTransformSet;
4-
import org.jetbrains.annotations.NotNull;
4+
import org.jspecify.annotations.NullMarked;
55
import org.openrewrite.ExecutionContext;
6-
import org.openrewrite.InMemoryExecutionContext;
76
import org.openrewrite.SourceFile;
8-
import org.openrewrite.java.Java17Parser;
7+
import org.openrewrite.java.Java21Parser;
98

109
import java.util.List;
1110

@@ -18,10 +17,11 @@
1817
* @param failWithNotApplicableAccessTransformers whether restamp should fail if not all access transformers defined in {@code accessTransformers}
1918
* were consumed by restamp.
2019
*/
20+
@NullMarked
2121
public record RestampInput(
22-
@NotNull ExecutionContext executionContext,
23-
@NotNull List<SourceFile> sources,
24-
@NotNull AccessTransformSet accessTransformers,
22+
ExecutionContext executionContext,
23+
List<SourceFile> sources,
24+
AccessTransformSet accessTransformers,
2525
boolean failWithNotApplicableAccessTransformers
2626
) {
2727

@@ -33,9 +33,8 @@ public record RestampInput(
3333
*
3434
* @return the parsed restamp input, ready for consumption via {@link Restamp#run(RestampInput)}.
3535
*/
36-
@NotNull
37-
public static RestampInput parseFrom(@NotNull final RestampContextConfiguration contextConfiguration) {
38-
final Java17Parser parser = Java17Parser.builder().classpath(contextConfiguration.classpath()).build();
36+
public static RestampInput parseFrom(final RestampContextConfiguration contextConfiguration) {
37+
final Java21Parser parser = Java21Parser.builder().classpath(contextConfiguration.classpath()).build();
3938

4039
final List<SourceFile> sourceFiles = parser.parse(
4140
contextConfiguration.sourceFiles(),

0 commit comments

Comments
 (0)