8

Enviroment

I am using a third party lib which requires bytecode instrumentation. The tool which does the bytecode instrumentation requires some description files and those files have to be in the same folder structure like the compiled .class files. Those files are only necessary at compiletime.

Problem

I thought gradle would place all files (resource and class) temporarily within the same folder and then create a jar from that folder. But it seems that gradle have two different places for resources and class files before assembling a jar. Like mentioned before the third party tool for code instrumentation requires the description files in the same folderstructure like the class files.

Question

Simply: How can I solve this Problem?

Ideas

  1. Place the description files with in src/main/java. Not very "clean" but could be a solution. Sadly gradle ignores those files. I tried to include them somehow but didn't get it working yet.
  2. Temporarily copy the description files to the right place. Also not a very "clean" way
Jan
  • 1,004
  • 6
  • 23

1 Answers1

13

You can redirect the resources output dir by:

sourceSets {
  main {
    output.resourcesDir = "build/classes/main"
  }
  test {
    output.resourcesDir = "build/classes/test"
  }
}

then the folder with class files (build/classes/main) will also contain your resources.

František Hartman
  • 14,436
  • 2
  • 40
  • 60
  • Thank you very much! I redirected them to `bin` at the moment (I am using Eclipse). Does this have any negative effect on the further build process? Because those files can't be seperated anymore then – Jan Mar 02 '17 at 11:46
  • If you redirect all resources to `bin`, then they won't end up in the final jar - depends whether you have other resources you want to keep. – František Hartman Mar 02 '17 at 11:57