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/dist
would be in./wrapper/build/resources/main/static
lib/build/dist
would 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 definemain1
andmain2
, this would work fine, but I have some problems making thosesourceSets
be child ofmain
. In other words - if you define customsourceSet
(notmain
ortest
) you need to make it compile - how? I know I can command:gradle build sourceSetName
to invoke specific customsourceSet
compilation, how can I do it so it is dependency tomain
?
I am using Gradle 4.10.1 with java (and eclipse) plugins.