I think the problem is that the task is evaluated at build file read time unstead of task execution time. I wish there were a project method ‘zip’ like there is ‘copy’, and I would have been done with this hours ago. I’m not being picky-- I have no problem feeding the zip task a hand-rolled File collection, but the same problem… Gradle throws a npe even though the zip task doesn’t execute until after the Collection is populated.
I was hoping that the curly braces would defer execution, but no.
My Jar task uses 7 resolved dependency files, and it echos that count as you can see below, but the zip (generated afterwards) only ever contains the primary output jar of my project… which isn’t a runtime dependency at all.
beyla$ gradlew clean jar zip
:clean
:compileJava
:processResources
:classes
:jar
RTLIBS-> 7
:zip
Configuration.allArtifacts.files contains only the published files from the current project. It does not include any dependencies. You should do something like this, instead:
task zip(type: Zip) {
from configurations.runtime.allArtifacts.files
from configurations.runtime
into ...
}
Hmm, well this is probably a fairly unique scenario as I had 3 versions of gradle installed and then was using the oldest version while looking at the documentation for a newer version.
After looking through Ivy’s documentation a lot recently and seeing how they label the versions of features throughout, I think it’s distracting. If I’m looking at the documentation for some version I shouldn’t assume some functionality is available in previous versions.
btw- I went back to using M3 after installing M5 because it’s so much faster for the kind of integrated builds I’m testing…