Reputation: 847
I'm trying to zip a folder in my resources folder, then put that zip instead of the folder in the output jar. Example:
resources
|- my-folder
|---- test.txt
Output:
myjar.jar
|- my-folder.zip
|---- test.txt
My current task for zipping:
task zipResources(type:Zip) {
classifier = 'test-zip'
from projectDir
sourceSets*.resources.stream()
.flatMap({ set -> set.files.stream() })
.filter({ file -> file.getAbsolutePath().contains('resource-pack') })
.forEach({ file ->
println file
include file.getAbsolutePath()
})
}
That prints the test.txt I've also tried with
from projectDir
include 'src/main/resources/resource-pack'
and various other variations, but no luck so far. How the heck do I do this?
Upvotes: 0
Views: 461
Reputation: 2438
You have line up the tasks here - myZip between processResources and jar
sample:
processResources {
exclude 'records-dir/'
}
task myZip(type: Zip) {
destinationDirectory = file('build/resources/main')
archiveFileName = 'records-dir.zip'
from 'src/main/resources/records-dir'
}
myZip.mustRunAfter processResources
jar.dependsOn myZip
Upvotes: 2