Skip to content

Commit

Permalink
Prevent NPE through addition of GradleBuildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 11, 2024
1 parent 17a50c6 commit b3d6fa8
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.openrewrite.ExecutionContext;
import org.openrewrite.gradle.DependencyVersionSelector;
import org.openrewrite.gradle.marker.GradleBuildscript;
import org.openrewrite.gradle.marker.GradlePluginDescriptor;
import org.openrewrite.gradle.marker.GradleSettings;
import org.openrewrite.maven.MavenDownloadingException;
Expand Down Expand Up @@ -69,7 +70,12 @@ public static Optional<String> getNewerVersion(String versionPattern, String cur

public static Optional<String> getNewerGradlePluginVersion(String pluginId, String versionPattern, String currentVersion, ExecutionContext ctx) throws MavenDownloadingException {
MavenRepository gradlePluginsRepo = new MavenRepository("gradle-plugins", "https://plugins.gradle.org/m2/", "true", "false", true, null, null, true);
GradleSettings gradleSettings = new GradleSettings(randomId(), singletonList(gradlePluginsRepo), singletonList(new GradlePluginDescriptor("io.micronaut.gradle.MicronautApplicationPlugin", null)), emptyMap());
GradleSettings gradleSettings = new GradleSettings(
randomId(),
singletonList(gradlePluginsRepo),
singletonList(new GradlePluginDescriptor("io.micronaut.gradle.MicronautApplicationPlugin", null)),
emptyMap(),
new GradleBuildscript(randomId(), singletonList(gradlePluginsRepo), emptyMap()));
return Optional.ofNullable(new DependencyVersionSelector(null, null, gradleSettings)
.select(new GroupArtifactVersion(pluginId, pluginId + ".gradle.plugin", currentVersion), "classpath", versionPattern, null, ctx));
}
Expand Down

0 comments on commit b3d6fa8

Please sign in to comment.