This message was deleted.
# plugin-development
s
This message was deleted.
same 6
m
sorry for the rant, but there we are...
I have code which "looks" clean like this:
Copy code
task.getImage().convention(imageBuilder.flatMap(BuildNativeImageTask::getOutputFile));
                task.getRuntimeArgs().convention(options.getRuntimeArgs());
                task.getInternalRuntimeArgs().convention(
                        imageBuilder.zip(options.getPgoInstrument(), serializableBiFunctionOf((builder, pgo) -> {
                                    if (Boolean.TRUE.equals(pgo)) {
                                        File outputDir = builder.getOutputDirectory().get().getAsFile();
                                        return Collections.singletonList("-XX:ProfilesDumpFile=" + new File(outputDir, "default.iprof").getAbsolutePath());
                                    }
                                    return Collections.emptyList();
                                })
                        ));
but at runtime fails with:
• Task
:nativeRun
of type `org.graalvm.buildtools.gradle.tasks.NativeRunTask`: cannot serialize object of type 'org.graalvm.buildtools.gradle.tasks.BuildNativeImageTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
which indicates that the whole task is captured...
you could say that the report is supposed to help, but it doesn't tell why it was captured... In my project because of laziness sometimes the inputs come from mapping of mapping of flatmap of map of whatever...
looks like
imageBuilder.flatMap(BuildNativeImageTask::getOutputFile)
is enough to trigger the problem. A flatMap. Kill. me.
so for this particular instance, the issue was :
Copy code
@Internal
    public Provider<RegularFile> getOutputFile() {
        return getOutputDirectory().map(dir -> dir.file(getExecutableName()).get());
    }
which should be:
Copy code
@Internal
    public Provider<RegularFile> getOutputFile() {
        return getOutputDirectory().zip(getExecutableName(), Directory::file);
    }
these kind of things are extremely hard to figure out...
also the kind of things that I had to do:
Copy code
serializableSupplierOf(() -> Collectors.<File>toList())
pass a
Supplier<Collector>
and wrap it into a serializable supplier because passing the collector directly fails serialization.
I don't care about the supplier, it's just a workaround...
next one:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache state could not be cached: field `spec` of `org.gradle.api.internal.tasks.execution.SelfDescribingSpec` bean found in task `:compileJava` of type `org.gradle.api.tasks.compile.JavaCompile`: error writing value of type 'org.gradle.api.internal.tasks.compile.CompilerForkUtils$$Lambda$1429/0x0000000801621430'
> Unable to make field private final java.lang.Object[] java.lang.invoke.SerializedLambda.capturedArgs accessible: module java.base does not "opens java.lang.invoke" to unnamed module @60b9f4c
🙈 1
🥲 2
(and yet
0 problems were found storing the configuration cache.
)
a
how much time do you think configuration cache will save compared to how much time it takes you to implement? 🙃
m
Implement the feature I need: 1 hour. Fix compatibility with config cache : 3 days and counting.
I'm going to end up being fired for "slacking off"
a
I can really emphasise with how frustrating config cache is
I kind of get the point, but I think that Java Serialization just has too many problems
j
do they use java serialization? I thought it was a custom one
a
Ah you’re right
Gradle uses its own optimized serialization mechanism and format to store the configuration cache entries.
it’s used partially though - perhaps that’s where most of the problems come from?
As a fallback and to provide some aid in migrating existing tasks, some semantics of Java Serialization are supported.
https://docs.gradle.org/current/userguide/configuration_cache.html