From 955590b60226b2e3c27f6a0bdba4b2979a4cd140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Schn=C3=A9ider?= Date: Thu, 15 Aug 2024 00:37:42 -0400 Subject: [PATCH] Migrate to JSpecify from OpenRewrite JSR-305 meta-annotations (#840) Use this link to re-run the recipe: https://app.moderne.io/builder/gW3xaSLWV?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../org/openrewrite/maven/AbstractRewriteBaseRunMojo.java | 2 +- .../org/openrewrite/maven/AbstractRewriteDryRunMojo.java | 2 +- .../java/org/openrewrite/maven/AbstractRewriteMojo.java | 2 +- .../org/openrewrite/maven/AbstractRewriteRunMojo.java | 2 +- .../org/openrewrite/maven/ConfigurableRewriteMojo.java | 2 +- .../org/openrewrite/maven/MavenLoggingMeterRegistry.java | 8 ++++---- .../maven/MavenLoggingResolutionEventListener.java | 2 +- .../org/openrewrite/maven/MavenMojoProjectParser.java | 6 +++--- .../java/org/openrewrite/maven/MavenPomCacheBuilder.java | 2 +- .../java/org/openrewrite/maven/MeterRegistryProvider.java | 8 ++++---- .../java/org/openrewrite/maven/RewriteDiscoverMojo.java | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java index 35030088..2ea3891d 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java @@ -20,6 +20,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.config.CompositeRecipe; import org.openrewrite.config.DeclarativeRecipe; @@ -27,7 +28,6 @@ import org.openrewrite.config.RecipeDescriptor; import org.openrewrite.internal.InMemoryLargeSourceSet; import org.openrewrite.internal.ListUtils; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.tree.J; import org.openrewrite.kotlin.tree.K; import org.openrewrite.marker.*; diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java index 28896258..4393fa80 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java @@ -17,9 +17,9 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.Result; -import org.openrewrite.internal.lang.Nullable; import java.io.BufferedWriter; import java.io.IOException; diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java index 5be6a20e..e422f5e4 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java @@ -23,11 +23,11 @@ import org.apache.maven.settings.crypto.SettingsDecrypter; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.artifact.Artifact; +import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.config.ClasspathScanningLoader; import org.openrewrite.config.Environment; import org.openrewrite.config.YamlResourceLoader; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.ipc.http.HttpSender; import org.openrewrite.ipc.http.HttpUrlConnectionSender; diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java index 016335e9..8cbbadb2 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java @@ -16,12 +16,12 @@ package org.openrewrite.maven; import org.apache.maven.plugin.MojoExecutionException; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.FileAttributes; import org.openrewrite.PrintOutputCapture; import org.openrewrite.Result; import org.openrewrite.binary.Binary; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.quark.Quark; import org.openrewrite.remote.Remote; diff --git a/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java b/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java index 0841eadc..3abaf5a3 100644 --- a/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java +++ b/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java @@ -25,8 +25,8 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.MXSerializer; import org.intellij.lang.annotations.Language; +import org.jspecify.annotations.Nullable; import org.openrewrite.config.Environment; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.style.NamedStyles; import java.io.IOException; diff --git a/src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java b/src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java index c1c0e32e..1b2ae748 100644 --- a/src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java +++ b/src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java @@ -25,9 +25,9 @@ import io.micrometer.core.instrument.internal.DefaultLongTaskTimer; import io.micrometer.core.instrument.internal.DefaultMeter; import io.micrometer.core.instrument.util.TimeUtils; -import org.apache.maven.plugin.logging.Log; -import org.openrewrite.internal.lang.NonNullApi; -import org.openrewrite.internal.lang.Nullable; +import org.apache.maven.plugin.logging.Log; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import java.time.Duration; import java.util.concurrent.TimeUnit; @@ -38,7 +38,7 @@ import static io.micrometer.core.instrument.util.DoubleFormat.decimalOrNan; import static java.util.stream.Collectors.joining; -@NonNullApi +@NullMarked public class MavenLoggingMeterRegistry extends MeterRegistry { private final Log log; diff --git a/src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java b/src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java index 0305a476..e883e865 100644 --- a/src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java +++ b/src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java @@ -16,7 +16,7 @@ package org.openrewrite.maven; import org.apache.maven.plugin.logging.Log; -import org.openrewrite.internal.lang.Nullable; +import org.jspecify.annotations.Nullable; import org.openrewrite.maven.tree.*; import java.util.List; diff --git a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java index bc3309fa..a6369b4f 100644 --- a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java +++ b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java @@ -30,11 +30,11 @@ import org.apache.maven.settings.crypto.SettingsDecryptionRequest; import org.apache.maven.settings.crypto.SettingsDecryptionResult; import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.jspecify.annotations.Nullable; import org.openrewrite.ExecutionContext; import org.openrewrite.ParseExceptionResult; import org.openrewrite.SourceFile; import org.openrewrite.internal.StringUtils; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.JavaParser; import org.openrewrite.java.internal.JavaTypeCache; import org.openrewrite.java.marker.JavaProject; @@ -155,7 +155,7 @@ public Stream listSourceFiles(MavenProject mavenProject, List listSourceFiles(MavenProject mavenProject, @Nullable Xml.Document maven, List projectProvenance, List styles, + public Stream listSourceFiles(MavenProject mavenProject, Xml.@Nullable Document maven, List projectProvenance, List styles, ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException { Stream sourceFiles = Stream.empty(); Set alreadyParsed = new HashSet<>(); @@ -514,7 +514,7 @@ private static JavaSourceSet sourceSet(String name, List dependencies, Jav return JavaSourceSet.build(name, dependencies); } - public @Nullable Xml.Document parseMaven(MavenProject mavenProject, List projectProvenance, ExecutionContext ctx) { + public Xml.@Nullable Document parseMaven(MavenProject mavenProject, List projectProvenance, ExecutionContext ctx) { return parseMaven(singletonList(mavenProject), singletonMap(mavenProject, projectProvenance), ctx).get(mavenProject); } diff --git a/src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java b/src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java index 4c1464aa..c05691a5 100644 --- a/src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java +++ b/src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java @@ -16,7 +16,7 @@ package org.openrewrite.maven; import org.apache.maven.plugin.logging.Log; -import org.openrewrite.internal.lang.Nullable; +import org.jspecify.annotations.Nullable; import org.openrewrite.maven.cache.CompositeMavenPomCache; import org.openrewrite.maven.cache.InMemoryMavenPomCache; import org.openrewrite.maven.cache.MavenPomCache; diff --git a/src/main/java/org/openrewrite/maven/MeterRegistryProvider.java b/src/main/java/org/openrewrite/maven/MeterRegistryProvider.java index e197e54e..8ac4d51c 100644 --- a/src/main/java/org/openrewrite/maven/MeterRegistryProvider.java +++ b/src/main/java/org/openrewrite/maven/MeterRegistryProvider.java @@ -25,16 +25,16 @@ import io.rsocket.transport.ClientTransport; import io.rsocket.transport.netty.client.TcpClientTransport; import io.rsocket.transport.netty.client.WebsocketClientTransport; -import org.apache.maven.plugin.logging.Log; -import org.openrewrite.internal.lang.Nullable; +import org.apache.maven.plugin.logging.Log; +import org.jspecify.annotations.Nullable; import reactor.netty.http.client.HttpClient; import reactor.netty.tcp.TcpClient; import reactor.util.retry.Retry; import java.net.URI; import java.time.Duration; -import java.util.Base64; - +import java.util.Base64; + public class MeterRegistryProvider implements AutoCloseable { private final Log log; diff --git a/src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java b/src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java index 31800281..787e53b5 100644 --- a/src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java +++ b/src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java @@ -18,11 +18,11 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.jspecify.annotations.Nullable; import org.openrewrite.config.Environment; import org.openrewrite.config.OptionDescriptor; import org.openrewrite.config.RecipeDescriptor; import org.openrewrite.internal.StringUtils; -import org.openrewrite.internal.lang.Nullable; import org.openrewrite.style.NamedStyles; import java.util.*;