How can I get jaxb.index files co-located with .class files in final jar?

I guess my requirements are:

  1. in my file I’d like to not have to know how many jaxb.index files are in my source tree, nor where they are located. I’d like to be able to refer to them with something like src/**/jaxb.index

  2. I’d like the resulting jar from the jar task to have included all of the jaxb.index files from my source tree in the corresponding location, co-located with the relevant package’s .class files

What I currently have is:

processResources {

from(projectDir) {

include ‘src/**/jaxb.index’

} }

…which of course doesn’t work because the index files are not co-located with the .class files in the resulting jar, leading to jaxb binding exceptions.

Any suggestions?

Only took me 2.5 hours of random experimentation to figure this out, but the following works:

processResources {


include ‘**/jaxb.index’ }

When I do this, the rest of the src/main/resources do not get processed. Is there a better alternative?