I have multi-project where I want to attach resources from different locations (sub-projects that generate them) but also place them in different output directories.
wrapper (parent)
|--frontend (child)
| |--build/dist
| |--js
| | |-- ...
| |--css
| |-- ...
|--lib (child)
|--build/dist
|--python
|-- ...
I need for wrapper (parent) to treat both of child projects' build/dist as resource, BUT placed in different outputDir.
frontend/build/distwould be in./wrapper/build/resources/main/staticlib/build/distwould be in./wrapper/build/resources/main
Goal is to have given resource of sourceSet main be appended with static directory when moving it to outputDir.
Note that outputDir is NOT jar task. This is not packaging issue, but outputDir issue.
sourceSets {
main {
resources {
srcDirs [
project(':frontend').projectDir.absolutePath + '/build/dist'
project(':lib').projectDir.absolutePath + '/build/dist'
]
}
output.resourcesDir project.buildDir.absolutePath + '/resources/main/static'
}
}
Above will add resources to main sourceSet, but they will have the same output.resourceDir.
Final questions
- Is there syntax that allows defining output for given src? Can you give me example?
- If not (yet?), I though about defining more than one
sourceSet. Basically definemain1andmain2, this would work fine, but I have some problems making thosesourceSetsbe child ofmain. In other words - if you define customsourceSet(notmainortest) you need to make it compile - how? I know I can command:gradle build sourceSetNameto invoke specific customsourceSetcompilation, how can I do it so it is dependency tomain?
I am using Gradle 4.10.1 with java (and eclipse) plugins.