Skip to content

Commit 81a7065

Browse files
committed
feat!(*): Migrate to JSpecify
1 parent 576349b commit 81a7065

File tree

16 files changed

+69
-71
lines changed

16 files changed

+69
-71
lines changed

.checkstyle/checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
<!-- https://checkstyle.org/config_imports.html#IllegalImport -->
103103
<module name="IllegalImport">
104-
<property name="illegalPkgs" value="sun, jdk, com.sun"/>
104+
<property name="illegalPkgs" value="sun, jdk, com.sun, org.jetbrains.annotations"/>
105105
</module>
106106

107107
<!-- https://checkstyle.org/config_coding.html#IllegalTokenText -->

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ indraSonatype {
1717
}
1818

1919
dependencies {
20-
compileOnlyApi libs.jetbrainsAnnotations
20+
compileOnlyApi libs.jspecify
2121
implementation gradleApi()
2222

2323
testImplementation platform(libs.junit.bom)

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ stylecheck = "0.2.1"
99
errorprone = "2.30.0"
1010

1111
[libraries]
12-
jetbrainsAnnotations = "org.jetbrains:annotations:25.0.0"
12+
jspecify = { module = "org.jspecify:jspecify", version = "1.0.0" }
1313

1414
# test
1515
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }

mammoth-test/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description = "JUnit extensions for testing Gradle plugins"
33
dependencies {
44
api gradleApi()
55
api gradleTestKit()
6-
compileOnlyApi libs.jetbrainsAnnotations
6+
compileOnlyApi libs.jspecify
77
api platform(libs.junit.bom)
88
api libs.junit.api
99
implementation libs.junit.platformCommons

mammoth-test/src/main/java/net/kyori/mammoth/test/GradleFunctionalTestExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import java.util.List;
3737
import java.util.Optional;
3838
import java.util.stream.Stream;
39-
import javax.annotation.Nullable;
4039
import org.gradle.util.GradleVersion;
40+
import org.jspecify.annotations.Nullable;
4141
import org.junit.jupiter.api.extension.Extension;
4242
import org.junit.jupiter.api.extension.ExtensionContext;
4343
import org.junit.jupiter.api.extension.TestTemplateInvocationContext;

mammoth-test/src/main/java/net/kyori/mammoth/test/TestContext.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of mammoth, licensed under the MIT License.
33
*
4-
* Copyright (c) 2021-2022 KyoriPowered
4+
* Copyright (c) 2021-2024 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -37,7 +37,6 @@
3737
import java.util.regex.Pattern;
3838
import org.gradle.testkit.runner.BuildResult;
3939
import org.gradle.testkit.runner.GradleRunner;
40-
import org.jetbrains.annotations.NotNull;
4140
import org.junit.jupiter.api.Assertions;
4241

4342
import static java.util.Objects.requireNonNull;
@@ -78,11 +77,11 @@ public final class TestContext {
7877
* @return the output directory
7978
* @since 1.1.0
8079
*/
81-
public @NotNull Path outputDirectory() {
80+
public Path outputDirectory() {
8281
return this.outputDirectory;
8382
}
8483

85-
@NotNull String gradleVersion() {
84+
String gradleVersion() {
8685
return this.gradleVersion;
8786
}
8887

@@ -93,7 +92,7 @@ public final class TestContext {
9392
* @throws IOException if an error occurs writing the input file to disk
9493
* @since 1.1.0
9594
*/
96-
public void copyInput(final @NotNull String name) throws IOException {
95+
public void copyInput(final String name) throws IOException {
9796
this.copyInput(name, name);
9897
}
9998

@@ -105,7 +104,7 @@ public void copyInput(final @NotNull String name) throws IOException {
105104
* @throws IOException if an error occurs writing the input file to disk
106105
* @since 1.1.0
107106
*/
108-
public void copyInput(final @NotNull String fromName, final @NotNull String toName) throws IOException {
107+
public void copyInput(final String fromName, final String toName) throws IOException {
109108
requireNonNull(fromName, "fromName");
110109
requireNonNull(toName, "toName");
111110
try (final InputStream is = this.resourceBase.getResourceAsStream(this.testName + "/in/" + fromName)) {
@@ -130,7 +129,7 @@ public void copyInput(final @NotNull String fromName, final @NotNull String toNa
130129
* @throws IOException if an error occurs writing the text
131130
* @since 1.2.0
132131
*/
133-
public void writeText(final @NotNull String destination, final @NotNull String text) throws IOException {
132+
public void writeText(final String destination, final String text) throws IOException {
134133
requireNonNull(destination, "destination");
135134
requireNonNull(text, "text");
136135

@@ -149,7 +148,7 @@ public void writeText(final @NotNull String destination, final @NotNull String t
149148
* @throws IOException if thrown while attempting to read the output file
150149
* @since 1.1.0
151150
*/
152-
public @NotNull String readOutput(final @NotNull String fileName) throws IOException {
151+
public String readOutput(final String fileName) throws IOException {
153152
final StringBuilder builder = new StringBuilder();
154153
try (final BufferedReader reader = Files.newBufferedReader(this.outputDirectory.resolve(fileName), StandardCharsets.UTF_8)) {
155154
final char[] buffer = new char[8192];
@@ -169,7 +168,7 @@ public void writeText(final @NotNull String destination, final @NotNull String t
169168
* @throws IOException if an error occurs reading the text
170169
* @since 1.2.0
171170
*/
172-
public void assertOutputEqualsLiteral(final @NotNull String destination, final @NotNull String text) throws IOException {
171+
public void assertOutputEqualsLiteral(final String destination, final String text) throws IOException {
173172
requireNonNull(destination, "destination");
174173
requireNonNull(text, "text");
175174

@@ -188,7 +187,7 @@ public void assertOutputEqualsLiteral(final @NotNull String destination, final @
188187
* @throws IOException if failed to read one of the files
189188
* @since 1.1.0
190189
*/
191-
public void assertOutputEquals(final @NotNull String resourceName, final @NotNull String fileName) throws IOException {
190+
public void assertOutputEquals(final String resourceName, final String fileName) throws IOException {
192191
final String actualOutput = this.readOutput(fileName);
193192

194193
final StringBuilder builder = new StringBuilder();
@@ -215,7 +214,7 @@ public void assertOutputEquals(final @NotNull String resourceName, final @NotNul
215214
* @return the new runner
216215
* @since 1.1.0
217216
*/
218-
public @NotNull GradleRunner runner(final @NotNull String@NotNull... extraArgs) {
217+
public GradleRunner runner(final String... extraArgs) {
219218
final List<String> args = new ArrayList<>(this.commonArguments.size() + extraArgs.length);
220219
args.addAll(this.commonArguments);
221220
Collections.addAll(args, extraArgs);
@@ -234,7 +233,7 @@ public void assertOutputEquals(final @NotNull String resourceName, final @NotNul
234233
* @return the result of an executed build
235234
* @since 1.1.0
236235
*/
237-
public @NotNull BuildResult build(final @NotNull String@NotNull... extraArgs) {
236+
public BuildResult build(final String... extraArgs) {
238237
return this.runner(extraArgs).build();
239238
}
240239

mammoth-test/src/main/java/net/kyori/mammoth/test/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@
2828
* annotating methods that have a parameter of either type {@link net.kyori.mammoth.test.TestContext}
2929
* or {@link org.gradle.testkit.runner.GradleRunner}.</p>
3030
*/
31+
@NullMarked
3132
package net.kyori.mammoth.test;
33+
34+
import org.jspecify.annotations.NullMarked;

src/main/java/net/kyori/mammoth/Configurable.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of mammoth, licensed under the MIT License.
33
*
4-
* Copyright (c) 2021-2022 KyoriPowered
4+
* Copyright (c) 2021-2024 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -24,8 +24,7 @@
2424
package net.kyori.mammoth;
2525

2626
import org.gradle.api.Action;
27-
import org.jetbrains.annotations.NotNull;
28-
import org.jetbrains.annotations.Nullable;
27+
import org.jspecify.annotations.Nullable;
2928

3029
import static java.util.Objects.requireNonNull;
3130

@@ -47,7 +46,7 @@ private Configurable() {
4746
* @return the provided {@code instance}
4847
* @since 1.0.0
4948
*/
50-
public static <T> @NotNull T configure(final @NotNull T instance, final @NotNull Action<T> configureAction) {
49+
public static <T> T configure(final T instance, final Action<T> configureAction) {
5150
requireNonNull(configureAction, "configureAction").execute(instance);
5251
return instance;
5352
}
@@ -61,7 +60,7 @@ private Configurable() {
6160
* @return the provided {@code instance}
6261
* @since 1.0.0
6362
*/
64-
public static <T> @NotNull T configureIfNonNull(final @NotNull T instance, final @Nullable Action<T> configureAction) {
63+
public static <T> T configureIfNonNull(final T instance, final @Nullable Action<T> configureAction) {
6564
if (configureAction != null) {
6665
configureAction.execute(instance);
6766
}

src/main/java/net/kyori/mammoth/GradleCompat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of mammoth, licensed under the MIT License.
33
*
4-
* Copyright (c) 2021-2023 KyoriPowered
4+
* Copyright (c) 2021-2024 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -28,7 +28,7 @@
2828
import org.gradle.api.Project;
2929
import org.gradle.api.provider.Provider;
3030
import org.gradle.util.GradleVersion;
31-
import org.jetbrains.annotations.Nullable;
31+
import org.jspecify.annotations.Nullable;
3232

3333
final class GradleCompat {
3434
static final boolean SHOULD_USE_CONVENTION = hasMethod(Project.class, "getConvention") && !hasMinGradleVersion("8.2");

src/main/java/net/kyori/mammoth/IsolatingClassLoader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
import java.util.Iterator;
3131
import java.util.Set;
3232
import org.gradle.api.file.FileCollection;
33-
import org.jetbrains.annotations.NotNull;
34-
import org.jetbrains.annotations.Nullable;
33+
import org.jspecify.annotations.Nullable;
3534

3635
/**
3736
* A factory for classloaders that will load classes from themselves rather than its parent where possible.
@@ -54,7 +53,7 @@ private IsolatingClassLoader() {
5453
* @return the newly created loader
5554
* @since 1.4.0
5655
*/
57-
public static @NotNull URLClassLoader isolatingClassLoader(final @Nullable ClassLoader parent, final @NotNull URL @NotNull... urls) {
56+
public static URLClassLoader isolatingClassLoader(final @Nullable ClassLoader parent, final URL... urls) {
5857
return new IsolatingClassLoaderImpl(urls, parent);
5958
}
6059

@@ -66,7 +65,7 @@ private IsolatingClassLoader() {
6665
* @return the newly created loader
6766
* @since 1.4.0
6867
*/
69-
public static @NotNull URLClassLoader isolatingClassLoader(final @Nullable ClassLoader parent, final @NotNull FileCollection files) {
68+
public static URLClassLoader isolatingClassLoader(final @Nullable ClassLoader parent, final FileCollection files) {
7069
final Set<File> unwrapped = files.getFiles();
7170
final URL[] urls = new URL[unwrapped.size()];
7271
final Iterator<File> it = files.iterator();

0 commit comments

Comments
 (0)