fxlauncher-gradle-plugin
fxlauncher-gradle-plugin copied to clipboard
copyAppDependencies should not copy, if dependency has not changed
First, another thanks for the people who have tried to make this plugin great.
I'm using it for something at work—hence all the activity recently—so I'm willing to help where I can.
The ideal work-flow when launching with FXLauncher is thus:
Fix a bug. Plugin copies over just the fixed dependency. Clients will automatically pull down just the updated dependency.
However, the way things currently stand, the copyAppDependencies
task copies all of the dependencies, regardless if they've been changed or not. This makes all of the dependencies update and defeats the purpose of having a granular auto-updater: with the current work-flow, the clients have to pull down the whole app every time there is an update.
This problem doesn't seem to occur in projects using Maven because the Maven Dependency Plugin takes into account whether dependencies need updating.
@aalmiray, how easy is it to check for the same file already being there before copying it over? Can you point me in the right direction? I'm a groovy noob, but I'd be happy to submit a PR.
The copyAppDependencies
should identify its inputs and outputs. As it currently stands it does not. The task should either:
- declare inputs and outputs.
- extends from Copy task.
See https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks for more information.
Alright, I'm on-board. I've been reading through the documentation you provided.
The CopyAppDependenciesTask
should identify it's inputs and outputs.
Got it:
public class CopyAppDependenciesTask extends DefaultTask {
@InputFiles
FileCollection dependencies
@OutputDirectory
File directoryToCopyTo
...
But now when we create the task we need to pass those in, right?
Previously the task is being created in FXLauncherPlugin
like this
project.task('copyAppDependencies',
type: CopyAppDependenciesTask,
group: 'FXLauncher',
description: 'Copies all application runtime dependencies into working directory',
dependsOn: project.tasks.jar
)
So is this how I pass in those inputs and outputs?
project.task('copyAppDependencies',
type: CopyAppDependenciesTask,
group: 'FXLauncher',
description: 'Copies all application runtime dependencies into working directory',
dependsOn: project.tasks.jar,
{
dependencies = project.configurations.runtime.resolvedConfiguration.resolvedArtifacts
directoryToCopyTo = project.extensions.fxlauncher.resolveWorkingDirectory()
}
)
I started a PR, but it's far from ready. But I put it there so that it's clear what I've done so far.
Okay, I've been trying and trying.
I've figured out about delegates, so: progress.
Then I realized that if you call resolvedConfiguration
, like I was
{ vvvvvvvvvvvvvvvvvv
dependencies = project.configurations.runtime.resolvedConfiguration.resolvedArtifacts
directoryToCopyTo = project.extensions.fxlauncher.resolveWorkingDirectory()
}
, before the user has added their dependencies in their build.gradle
file that gradle gets upset because it already resolved that configuration, and you can't add dependencies after it's been resolved.
Error:(80, 0) Cannot change dependencies of configuration ':compile' after it has been included in dependency resolution.
So, I'm not sure how we can pass the dependencies in as an @Input
, like that. I'm sure there's a way, but I haven't been able to figure that out.
But then, I happened upon this thread, which gave the wonderful suggestion of using the Sync task instead of the Copy task!
Sync
This task is like the Copy task, except the destination directory will only contain the files copied. All files that exist in the destination directory will be deleted before copying files, unless a Sync.preserve(org.gradle.api.Action) is specified.