Skip to content

Conversation

@melix
Copy link

@melix melix commented Apr 18, 2025

This commit updates the Gradle build to replace the use of processResources.dependsOn with a proper dependency.

The rationale is described here:
https://melix.github.io/blog/2021/10/gradle-quickie-dependson.html

But in a nutshell: hooking the generation of the resources on the processResources task will only work if the processResources task is actually called, so it works "by accident" when you generate a jar for example. However, let's say that you have another task, in another plugin, which needs to reason about all available resources, including these generated by other plugins. In that case, that plugin would not see the native image source set.

The fix is actually fairly straightforward: you need to declare that the task contributes to the resources source set, and Gradle will automatically handle the task dependencies when needed: result should never depend on the execution of lifecycle tasks.

This commit updates the Gradle build to replace the use of
`processResources.dependsOn` with a proper dependency.

The rationale is described here:
   https://melix.github.io/blog/2021/10/gradle-quickie-dependson.html

But in a nutshell: hooking the generation of the resources on the
`processResources` task will only work if the `processResources`
task is actually called, so it works "by accident" when you generate
a jar for example. However, let's say that you have another task,
in another plugin, which needs to reason about all available resources,
including these generated by other plugins. In that case, that plugin
would not see the native image source set.

The fix is actually fairly straightforward: you need to declare that
the task contributes to the `resources` source set, and Gradle
will automatically handle the task dependencies when needed: result
should never depend on the execution of lifecycle tasks.
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

Successfully merging this pull request may close these issues.

1 participant