From 61f060462aac632b04ce01828944cfc039f85cd3 Mon Sep 17 00:00:00 2001 From: Argannor <4489279+Argannor@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:55:21 +0100 Subject: [PATCH] Gradle Configuration Cache fails to caches run task (#1064) * refactor: replace usage of Project and SourceSet in tasks to allow configuration cache to be used * Fix incorrect version in test --------- Co-authored-by: Cedric Champeau --- .../gradle/RuntimeDependenciesSpec.groovy | 2 +- .../MicronautMinimalApplicationPlugin.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/functional-tests/src/test/groovy/io/micronaut/gradle/RuntimeDependenciesSpec.groovy b/functional-tests/src/test/groovy/io/micronaut/gradle/RuntimeDependenciesSpec.groovy index 3fee3b92c..600fb4541 100644 --- a/functional-tests/src/test/groovy/io/micronaut/gradle/RuntimeDependenciesSpec.groovy +++ b/functional-tests/src/test/groovy/io/micronaut/gradle/RuntimeDependenciesSpec.groovy @@ -23,7 +23,7 @@ class RuntimeDependenciesSpec extends AbstractEagerConfiguringFunctionalTest { } micronaut { - version "$shadowVersion" + version "$micronautVersion" runtime "$runtime" } diff --git a/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautMinimalApplicationPlugin.java b/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautMinimalApplicationPlugin.java index a5aa8319d..57648a9a6 100644 --- a/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautMinimalApplicationPlugin.java +++ b/minimal-plugin/src/main/java/io/micronaut/gradle/MicronautMinimalApplicationPlugin.java @@ -114,13 +114,13 @@ private void configureJavaExecTasks(Project project, Configuration developmentOn Map sysProps = new LinkedHashMap<>(); sysProps.put("micronaut.io.watch.restart", true); sysProps.put("micronaut.io.watch.enabled", true); + FileCollection sourceDirectories = sourceSet.getAllSource().getSourceDirectories(); //noinspection Convert2Lambda javaExec.doFirst(new Action<>() { @Override public void execute(Task workaroundEagerSystemProps) { - String watchPaths = sourceSet - .getAllSource() - .getSrcDirs() + String watchPaths = sourceDirectories + .getFiles() .stream() .map(File::getPath) .collect(Collectors.joining(",")); @@ -205,12 +205,12 @@ private void configureGoogleCloudFunctionRuntime(Project project, Project p, Dep "--target", "io.micronaut.gcp.function.http.HttpFunction", "--port", 8080 )); + SourceSet sourceSet = PluginsHelper.findSourceSets(p).getByName("main"); + SourceSetOutput output = sourceSet.getOutput(); + String runtimeClasspath = project.files(project.getConfigurations().getByName("runtimeClasspath"), + output + ).getAsPath(); run.doFirst(t -> { - SourceSet sourceSet = PluginsHelper.findSourceSets(p).getByName("main"); - SourceSetOutput output = sourceSet.getOutput(); - String runtimeClasspath = project.files(project.getConfigurations().getByName("runtimeClasspath"), - output - ).getAsPath(); ((JavaExec) t).args("--classpath", runtimeClasspath );