Roded Bahat
06/13/2024, 7:30 AMtasks.register<Jar>("buildFatJar") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
isZip64 = true
from(fatJar.map(::zipTree))
with(tasks["jar"] as CopySpec)
}
This seems to be producing a bunch of deprecation errors in Gradle 7.6.2:
Reason: Task ':project:buildFatJar' uses this output of task ':other-project:jar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
I assume that this is due to the from clause in the task which explodes all the dependencies of the fatJar configuration into the fatJar.
How can I make this task compatible with Gradle 8?
Thanks!Vampire
06/13/2024, 7:52 AM.map you use is not the one from Provider that preserves task dependencies, but the one from Iterable<File>. It not only looses the task dependency but is also evaluated eagerly. If you use fatJar.elements and work on that, for example call .map on it, it should work better I think.Roded Bahat
06/13/2024, 7:54 AMVampire
06/13/2024, 7:57 AMRoded Bahat
06/13/2024, 8:01 AMVampire
06/13/2024, 8:08 AMRoded Bahat
06/13/2024, 8:09 AMRoded Bahat
06/13/2024, 8:10 AMfrom(fatJar.elements.map(::zipTree))
Can't seem to pass elements.map into the from due to:
Cannot fingerprint input file property 'rootSpec$1': Cannot convert the provided notation to a File or URI: [/path/some-jar.jar, ....].
The following types/formats are supported:
- A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
- A String or CharSequence URI, for example 'file:/usr/include'.
- A File instance.
- A Path instance.
- A Directory instance.
- A RegularFile instance.
- A URI or URL instance.
- A TextResource instance.
I was hoping to be able to bend this into being compatible with Gradle 8. But if it's so against the grain, then I'll just try using the shadow plugin. Thanks for the advice.Vampire
06/13/2024, 9:40 AMBy distributions, do you mean the distributions built by Gradle's application plugin?For example, yes.
Can't seem to pass elements.map into the from due to:You can, if you do it right. π
from(fatJar.elements.map(::zipTree)) compiles as zipTree accepts Any, but then fails as you give it a Set<FileSystemLocation> and that is what complains, not the from.Vampire
06/13/2024, 9:40 AMfrom(fatJar.elements.map { it.map(::zipTree) }) is what you intendedRoded Bahat
06/13/2024, 9:44 AMRoded Bahat
06/13/2024, 9:44 AMVampire
06/13/2024, 9:47 AMRoded Bahat
06/13/2024, 9:50 AMVampire
06/13/2024, 9:56 AMRoded Bahat
06/13/2024, 9:56 AMRoded Bahat
06/13/2024, 10:02 AM