Reputation: 320
I am converting a project built with Ant to use Gradle. The project looks something like
root
|-RelevantProject
...
|-LotsOfOtherSubprojects
...
|-Resources
|--resources
|---subfolder
|----bunchOfProps.properties
The code references these as Resources/resources/subfolder/bunchOfProps.properties
. This code and the folder structure cannot be changed as the ant scripts need to keep functioning
I have attempted to include this as
sourceSets {
main {
resources {
srcDir '../Resources'
}
}
}
Which fails as the code top level folder is now cut off. The code would work if looking for resources/subfolder/bunchOfProps.properties
.
I have also attempted compile files('../Resources')
with the same problem. Hard to say as this one did not appear in the Build directory. compile fileTree(dir: '../', include: '**/*.properties')
, which I hoped would just pick up the relevant files also did not show up in the build directory.
Simply using the root directory as a resource folder caused problems as it included other projects and even the .gradle directory. I haven't yet gotten it to compile this way. Not sure yet if I can exclude enough things to get this to work.
Upvotes: 0
Views: 933
Reputation: 7590
PrasadU's answer is sort-of correct, but it breaks up-to-date checking as it introduces a task where the output overlaps with the one from processResources
. It is better to just reconfigure the latter task instead:
processResources {
from(projectDir) {
include("Resources/**")
}
}
Upvotes: 2
Reputation: 2438
if you just need to copy the files
ext.prjRoot = project.projectDir.toString()
task copyExtResources(type: Copy) {
from prjRoot
include "Resources/**"
into "$buildDir/resources/main"
}
processResources.dependsOn copyExtResources
Upvotes: 0