How can I change the location of resouces in a jar file?

I have a two folders xml/schema1 and xml/schema2 and I would like to add them as resources to a Java project. I do this via the resources sourceset. However, what I would like to see is actual folders xml/schema1 and xml/schema2 in the jar file. Now, just the contents are copied in the jar file. How can change the path in the jar file, that the resources are copied to?

I see two options here. 1. you declare the common parent folder as resource directory using sourceSets 2. you use the api of the jar task to include these xml files where you want them to have in your jar file

option 2 might look like this:

       into ('xml')

Thanks. Option 2) works for us. Just to clearify, there is no way to specify a folder as a resource? Not just the content, but the folder itself, so it will be added to the jar accordingly?

you can only configure directories to be the root dir for your resources

sourceSets.main.resources.srcDirs = ‘xml/schema1’, ‘xml/schema2’

BTW. another (3rd) approach would be to copy those files as part of the processResources task instead of doing this during the jar. The syntax would look similar to the custom jar task configuration