Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: Copy subproject resources

So I have a project that contains a few subprojects that I am using Gradle with. What I would like to do is copy the resources from subprojectA to the main subprojectB. My structure looks like so.

Application
  \subprojectA
      \src\main\resources\blah
  \subprojectB
       \src\main\...

What I want to do, is when my application builds and compiles, overlay the resources folder from subprojectA into the main application's resource folder.

I've tried creating a Gradle task which looks like

task copyExtractorResources(type: Copy) {
    from 'extractors/src/main/resources/'
    into 'main/build/resources'
 }

and while it runs, I can't for the life of me find out how to say "Hey, always do this task before building"

Any help is greatly appreciated.

like image 729
Black Dynamite Avatar asked Jan 01 '15 05:01

Black Dynamite


1 Answers

A simpler way to accomplish this is simply to tell the existing processResources task to include your additional resources.

processResources {
    from 'extractors/src/main/resources'
}

However, for future reference you could implement your original solution by simply adding jar.dependsOn copyExtractorResources to your build script.

like image 104
Mark Vieira Avatar answered Sep 20 '22 21:09

Mark Vieira