Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintaing reference to Configuration in BaseGraalCompileTask breaks configuration caching #461

Open
nhoughto opened this issue Jan 27, 2022 · 0 comments

Comments

@nhoughto
Copy link

What happened?

Use of Gradle Configuration Caching fails because of an illegal type referenced in the task definition, some types are special and not allowed to be maintained in the configuration, like Configuration for the classpath variable. FileCollection should be used instead

* What went wrong:
Could not load the value of field `classpath` of task `:nativeImage` of type `com.palantir.gradle.graal.NativeImageTask`.
> Cannot set the value of a property of type org.gradle.api.artifacts.Configuration using a provider of type org.gradle.api.internal.file.DefaultFileCollectionFactory$ResolvingFileCollection.

What did you want to happen?

use FileCollection instead and configuration caching will work as expected:

Change

private final Property<Configuration> classpath = getProject().getObjects().property(Configuration.class);

to:

-    private final Property<Configuration> classpath = getProject().getObjects().property(Configuration.class);
+    private final Property<FileCollection> classpath = getProject().getObjects().property(FileCollection.class);

and in Plugin

-            task.setClasspath(project.getConfigurations().named("runtimeClasspath"));
+            final JavaPluginExtension javaPlugin = project.getExtensions().getByType(JavaPluginExtension.class);
+            final SourceSetContainer sourceSets = javaPlugin.getSourceSets();
+            final FileCollection classpathFiles = sourceSets.getByName("main").getRuntimeClasspath();
+            task.setClasspath(project.provider(() -> classpathFiles));

this does change the types for the getters and setters, but is likely worth the impact?

Happy to PR it if open to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant