Reputation: 1885
in my project I've the following directory setup:
src/main/resources/common
src/main/resources/local
src/main/resources/release
My goal is to override the default resources elaboration and to "flatten" this directory tree in the final archive.
At the moment I found only this ugly solution:
resources {
exclude 'release'
exclude 'common'
exclude 'local'
srcDir 'src/main/resources/common'
srcDir 'src/main/resources/local'
srcDir 'src/main/resources/release'
}
With this solution I think that the files in src/main/resources
will be copied in the final archive. Is there a way to exclude the resources default directory?
Is there any better way to solve my problem?
Upvotes: 0
Views: 464
Reputation: 426
What if we don't wish to explicity give each directly..can flatten happen as in ant it is happens with flatten attribute as in
https://alvinalexander.com/blog/post/java/flatten-directories-during-copy-with-java-ant-task/
Upvotes: 0
Reputation: 123890
A better approach is to override the default locations:
sourceSets {
main {
resources {
srcDirs = [
'src/main/resources/common',
'src/main/resources/local',
'src/main/resources/release'
]
}
}
}
It's a common idiom for Gradle APIs to offer a property (such as srcDirs
) that allows to set a collection (thereby overriding any defaults), and a similarly named method (such as srcDir
) that allows to add to the collection (thereby adding to the defaults).
My goal is to [...] "flatten" this directory tree in the final archive.
Not sure what you mean by that.
Upvotes: 1