What would be the best way to make something <like...
# community-support
r
What would be the best way to make something like this configuration cache compatible? My initial idea was to during the plugin being applied grab the packaging tasks and register configured versions of the Jar task as needed, but I can't seem to find a way to get those tasks
s
What is not compatible about it currently?
r
it configures and executes a task at execution time
s
ok I'm not familiar with the project so this may be a dumb question but why does it have to configure itself during execution? can't it just depend on tasks.jar and configure itself lazily based on that task's properties?
r
I'm not sure configuring the jar task is even correct here. It does so to insert some metadata into the manifest as well as set the classpath of the jar, to produce a jar that can be executed standalone while loading dependencies from an external source Javapackager is a plugin to well, package java applications into their nativeish executables, bundling libs and the JVM etc
s
Sounds to me like it would be better to create a separate Jar task and configure it the way you need it?
r
I am working on a PR to make it configuration cache compatible https://github.com/fvarrui/JavaPackager/pull/450
yes, but the task isn't always needed - the user can supply the jar, so I would like to only create the tasks as needed, but then I run back into the question of - how can I get the package tasks when the plugin is applied
s
They might not exist yet when the plugin is applied. Can you maybe have the user either provide an existing task or explicitly request a task to be created?
t
When I see plugin code like that, my first reaction is that it needs to be entirely rethought.
👆 1
r
that is one of the solutions I propose in my PR, will need to here back from the author though. I was wondering if there was a better/different way to handle it
it could probably use some spring cleaning
Speaking of which, the plugin has a way to specifying additional files to be packaged that takes a
List<File>
what would be the best way to pass/add an overload that can take a
CopySpec
? In my own project that uses the plugin, I have a shared CopySpec for those files, but to pass them into the plugin I have to copy them all to a folder on project sync so I can get the file list
s
I think the plugin should take a ConfigurableFileCollection instead and you can add all sorts of things to a file collection then, including providers that originate by mapping or flatMapping tasks, meaning that they will bring task dependencies with them.
r
my copyspec does include task output, so that it probably a good idea
if I allow a
Configuration
as a task input, what needs to be done to allow gradle to automatically build what is needed?
s
r
Specifically, I have a subproject that builds the runnable jar, and I share it with the root project via a configuration, I'd like to be able to give that configuration to the task for it to pull the jar
s
you can pass a Configuration to
ConfigurableFileCollection#from
, and it should pick up the dependencies
r
ahha, that does sem to work! had to move the testing from the extension to the task itself