8

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.

Black Dynamite
  • 4,067
  • 5
  • 40
  • 75

1 Answers1

9

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.

Mark Vieira
  • 13,198
  • 4
  • 46
  • 39
  • Thanks Mark. Turns out, I was trying to solve this problem in order to solve another problem. I've figured it out, and I stumbled upon the "dependsOn" method right after posting this question. Thanks for your help! – Black Dynamite Jan 01 '15 at 06:32