diff --git a/minimal-plugin/src/main/java/io/micronaut/gradle/ApplicationClasspathInspector.java b/minimal-plugin/src/main/java/io/micronaut/gradle/ApplicationClasspathInspector.java index fa27f54e..f1db6e8e 100644 --- a/minimal-plugin/src/main/java/io/micronaut/gradle/ApplicationClasspathInspector.java +++ b/minimal-plugin/src/main/java/io/micronaut/gradle/ApplicationClasspathInspector.java @@ -20,6 +20,8 @@ import org.gradle.api.file.RegularFileProperty; import org.gradle.api.tasks.CacheableTask; import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; @@ -30,6 +32,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Set; +import java.util.stream.Collectors; @CacheableTask public abstract class ApplicationClasspathInspector extends DefaultTask { @@ -37,15 +40,14 @@ public abstract class ApplicationClasspathInspector extends DefaultTask { @PathSensitive(PathSensitivity.RELATIVE) public abstract ConfigurableFileCollection getResources(); - /** - * The runtime classpath. Curently we only care about the file names, - * which is why the path sensitivity is set to name only. - * @return the runtime classpath - */ - @InputFiles - @PathSensitive(PathSensitivity.NAME_ONLY) + @Internal public abstract ConfigurableFileCollection getRuntimeClasspath(); + @Input + public Set getResolvedClasspathNames() { + return getRuntimeClasspath().getFiles().stream().map(File::getName).collect(Collectors.toSet()); + } + @OutputFile public abstract RegularFileProperty getReportFile(); @@ -55,8 +57,7 @@ void inspect() throws IOException { Set resources = getResources().getFiles(); if (resources.stream().anyMatch(ApplicationClasspathInspector::isYamlConfigurationFile)) { writer.println("YAML configuration file detected"); - Set runtimeClasspath = getRuntimeClasspath().getFiles(); - if (runtimeClasspath.stream().noneMatch(f -> f.getName().startsWith("snakeyaml"))) { + if (getResolvedClasspathNames().stream().noneMatch(n -> n.startsWith("snakeyaml"))) { writer.println("Didn't find snakeyaml on classpath. Failing"); throw new RuntimeException("YAML configuration file detected but snakeyaml is not on classpath. Make sure to add a runtimeOnly dependency on snakeyaml, e.g 'runtimeOnly(\"org.yaml:snakeyaml\")'"); } diff --git a/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautComponentPlugin.java b/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautComponentPlugin.java index cc0047c3..87f9f7e8 100644 --- a/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautComponentPlugin.java +++ b/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautComponentPlugin.java @@ -297,7 +297,6 @@ private void configureDefaultGroovySourceSet(Project p, private static TaskProvider registerInspectRuntimeClasspath(Project project, TaskContainer tasks) { return tasks.register(INSPECT_RUNTIME_CLASSPATH_TASK_NAME, ApplicationClasspathInspector.class, task -> { - var javaPluginExtension = PluginsHelper.javaPluginExtensionOf(project); task.setGroup(BasePlugin.BUILD_GROUP); task.setDescription("Performs sanity checks of the runtime classpath to warn about misconfigured builds"); task.getRuntimeClasspath().from(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));