How to add xml files from java source directory to output jar

I have a project that contains beandef.xml files for spring configuration in the src/main/java package. When I compile in gradle none of the files are in the output jar file. Should I be adding the xml files as a dependency like the following:

dependency {

compile fileTree(dir: ‘src’, includes: [’/*.xml,/*.properties’]) }

One solution is to move the files into ‘src/main/resources’. Another attempt is to let the sources and resources directories point to the same directory:

sourceSets {
  main {
    resources.srcDirs = ["src/main/java"]

If I’m not mistaken, I’ve seen this cause problems with duplicate resources in Jar files though.

That works! Thanks for your help.