GRADLE: How to specify resources from different folders on your sourceSet

Sometimes you need to have resources in your sourceset and these may come from different locations on disk, the official documentation is lacking in real world examples, or at least I just didn’t understand it very well, but from reading forums I finally got it to work.

In the example I specify what files to include/exclude from two different folders.
When the final .jar is created, they’ll keep the package path structure that lives inside the given srcDir folders.

If you just want to add these files (for some reason to the root of your resulting jar, you should make srcDir the full path to where the files live)

[pastacode lang=”java” manual=”sourceSets%20%7B%0Amain%20%7B%0Ajava%20%7B%0A%2F%2Fyour%20java%20source%20paths%20and%20exclusions%20go%20here%E2%80%A6%0A%7D%0A%0Aresources%20%7B%0AsrcDir%20%E2%80%98components%2Fresources%2Fsrc%2Fmain%2Fresources%E2%80%99%0Ainclude%20%E2%80%98**%2F*.properties%E2%80%99%0Ainclude%20%E2%80%98**%2F*.png%E2%80%99%0Ainclude%20%E2%80%98**%2F*.gif%E2%80%99%0Ainclude%20%E2%80%98**%2F*.jpg%E2%80%99%0Ainclude%20%E2%80%98**%2F*.html%E2%80%99%0Ainclude%20%E2%80%98**%2F*.js%E2%80%99%0Ainclude%20%E2%80%98**%2F*.sh%E2%80%99%0Ainclude%20%E2%80%98**%2F*.dat%E2%80%99%0Ainclude%20%E2%80%98**%2F*.icc%E2%80%99%0Aexclude%20%E2%80%98**%2F*.DS_Store%E2%80%99%0A%0AsrcDir%20%E2%80%98common%2Fvuze%2Fazureus2%2Fsrc%E2%80%99%0Ainclude%20%E2%80%98**%2FMessages*.properties%E2%80%99%0Aexclude%20%E2%80%98**%2F*.class%E2%80%99%0Aexclude%20%E2%80%98**%2F*.java%E2%80%99%0A%7D%0A%7D%0A%7D” message=”” highlight=”” provider=”manual”/]

Leave a Reply

Your email address will not be published. Required fields are marked *