{"id":3336,"date":"2014-07-29T23:04:17","date_gmt":"2014-07-29T23:04:17","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3336"},"modified":"2019-04-25T13:12:03","modified_gmt":"2019-04-25T13:12:03","slug":"gradle-how-to-specify-resources-from-different-folders-on-your-sourceset","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/gradle-how-to-specify-resources-from-different-folders-on-your-sourceset\/","title":{"rendered":"GRADLE: How to specify resources from different folders on your sourceSet"},"content":{"rendered":"<p>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&#8217;t understand it very well, but from reading forums I finally got it to work.<\/p>\n<p>In the example I specify what files to include\/exclude from two different folders.<br \/>\nWhen the final .jar is created, they&#8217;ll keep the package path structure that lives inside the given srcDir folders.<\/p>\n<p>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)<\/p>\n<p>[pastacode lang=&#8221;java&#8221; manual=&#8221;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&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t understand it very well, but from reading forums I finally got it to work. In the example I specify what files to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15],"tags":[1414,1437,1227,1409,583],"class_list":["post-3336","post","type-post","status-publish","format-standard","hentry","category-code","tag-build","tag-code","tag-examples","tag-gradle","tag-java"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-RO","jetpack-related-posts":[{"id":3331,"url":"https:\/\/www.gubatron.com\/blog\/gradle-how-to-copy-files-from-another-jar-into-your-resulting-output-jar\/","url_meta":{"origin":3336,"position":0},"title":"GRADLE: How to copy files from another .jar into your resulting output .jar","author":"gubatron","date":"July 29, 2014","format":false,"excerpt":"In our project we like to deliver a single jar as the final product, if you need to copy files that live on an existing jar into the Gradle's output jar, this example shows you how to do that (and more) [pastacode lang=\"java\" manual=\"jar%20%7B%0A%2F%2Fthis%20is%20how%20you%20change%20the%20name%20of%20the%20output%20jar%0AarchiveName%3D%E2%80%99frostwire.jar%E2%80%99%0A%0A%2F%2Fsome%20exclusion%20rules%20to%20keep%20your%20.jar%20clean%0Aexclude(%E2%80%98META-INF%2F*.SF%E2%80%99%2C%20%E2%80%98META-INF%2F*.DSA%E2%80%99%2C%20%E2%80%98META-INF%2F*.RSA%E2%80%99%2C%20%E2%80%98META-INF%2F*.MF%E2%80%99)%0A%0A%2F%2Fhere%20we%20grab%20all%20the%20.class%20files%20inside%20messages.jar%20and%20we%20put%20them%20in%20our%20resulting%20jar%0Afrom%20(zipTree(%E2%80%98lib%2Fjars%2Fmessages.jar%E2%80%99))%20%7B%0Ainclude%20%E2%80%98**%2F*.class%E2%80%99%0A%7D%0A%0A%2F%2Fhow%20to%20manipulate%20the%20jar%E2%80%99s%20manifest%0Amanifest%20%7B%0Aattributes%20%E2%80%98Main-Class%E2%80%99%3A%20%E2%80%98com.limegroup.gnutella.gui.Main%E2%80%99%0A%7D%0A%7D\" message=\"\" highlight=\"\" provider=\"manual\"\/]","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3315,"url":"https:\/\/www.gubatron.com\/blog\/gradle-how-to-add-a-list-of-local-jars-to-the-build-classpath\/","url_meta":{"origin":3336,"position":1},"title":"GRADLE: How to add a list of local .jar files to the build classpath","author":"gubatron","date":"July 29, 2014","format":false,"excerpt":"Sometimes you don't want\/cant use maven repos, all you have is a bunch of local jars on disk that you want to use as part of your compilation classpath, and the freaking gradle documentation is too vague. Here is an example: [pastacode lang=\"java\" manual=\"dependencies%20%7B%0Acompile%20files(%E2%80%98lib%2Fjars%2Fgettext-commons.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Flucene-3.5.0.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjaudiotagger.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Fh2-1.3.164.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Fmessages.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Fslf4j-api-1.7.5.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Fjaudiotagger.jar%E2%80%99%2C%0A%E2%80%98lib%2Fjars%2Fmetadata-extractor-2.6.2.jar%E2%80%99%0A)%0A%7D\" message=\"\" highlight=\"\" provider=\"manual\"\/]","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3802,"url":"https:\/\/www.gubatron.com\/blog\/gradle-groovy-a-simple-way-to-check-if-a-gradle-task-name-has-been-invoked-e-g-assemblerelease-for-android-developers\/","url_meta":{"origin":3336,"position":2},"title":"gradle\/groovy: A simple way to check if a gradle task name has been invoked (e.g. &#8220;assembleRelease&#8221; for Android developers)","author":"gubatron","date":"May 4, 2019","format":false,"excerpt":"If you google for this question, you'll find a bunch of crap answers about creating tasks and checking the task graph, bullshit. All you need to do is check if a parameter has been passed to gradle. Keep it simple and stupid: [pastacode lang=\"java\" manual=\"boolean%20isAssembleRelease%20%3D%20gradle.startParameter.taskNames.contains(%22assembleRelease%22)\" message=\"\" highlight=\"\" provider=\"manual\"\/] (If you're\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/05\/simple.jpg?fit=1000%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/05\/simple.jpg?fit=1000%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/05\/simple.jpg?fit=1000%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/05\/simple.jpg?fit=1000%2C667&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3321,"url":"https:\/\/www.gubatron.com\/blog\/solved-gradle-how-to-increase-the-java-compilers-available-heap-memory\/","url_meta":{"origin":3336,"position":3},"title":"[SOLVED] Gradle: How to increase the Java Compiler&#8217;s available Heap Memory","author":"gubatron","date":"July 29, 2014","format":false,"excerpt":"The documentation is not very clear on what all the available options are... after much Googling and many different attempts finally figured out how to raise the maximum heap of the compiler from within the gradle.build script. [pastacode lang=\"java\" manual=\"apply%20plugin%3A%20%E2%80%98java%E2%80%99%0A%0AcompileJava%20%7B%0A%2F%2Fraise%20heap%0Aoptions.fork%20%3D%20%E2%80%98true%E2%80%99%0Aoptions.forkOptions.with%20%7B%0AmemoryMaximumSize%20%3D%20%E2%80%9C2048m%E2%80%9D%0A%7D%0A%7D\" message=\"\" highlight=\"\" provider=\"manual\"\/] Update: So I've noticed this works great\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3874,"url":"https:\/\/www.gubatron.com\/blog\/coding-solved-gradle-build-android-breaks-after-upgrading-a-dependency-with-nullpointerexception-thrown-at-programclass-constantpoolentryaccept\/","url_meta":{"origin":3336,"position":4},"title":"[CODING\/SOLVED] gradle build (android) breaks after upgrading a dependency with NullPointerException thrown at ProgramClass.constantPoolEntryAccept","author":"gubatron","date":"February 27, 2020","format":false,"excerpt":"You've just upgraded one of your Android project's dependencies and when you .\/gradlew assembleRelease the build process breaks. You invoke it again with --stacktrace to find the following exception: \u00a0 [pastacode lang=\"java\" manual=\"java.lang.NullPointerException%0Aat%20proguard.classfile.ProgramClass.constantPoolEntryAccept(ProgramClass.java%3A537)%0Aat%20proguard.shrink.UsageMarker.markConstant(UsageMarker.java%3A1246)%0Aat%20proguard.shrink.UsageMarker.visitRequiresInfo(UsageMarker.java%3A1040)%0Aat%20proguard.classfile.attribute.module.ModuleAttribute.requiresAccept(ModuleAttribute.java%3A138)%0Aat%20proguard.shrink.UsageMarker.visitModuleAttribute(UsageMarker.java%3A739)%0Aat%20proguard.classfile.attribute.module.ModuleAttribute.accept(ModuleAttribute.java%3A99)%0Aat%20proguard.classfile.ProgramClass.attributesAccept(ProgramClass.java%3A619)%0Aat%20proguard.shrink.UsageMarker.markProgramClassBody(UsageMarker.java%3A124)%0Aat%20proguard.shrink.UsageMarker.visitProgramClass(UsageMarker.java%3A94)%0Aat%20proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java%3A67)%0Aat%20proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java%3A67)%0Aat%20proguard.classfile.visitor.ClassNameFilter.visitProgramClass(ClassNameFilter.java%3A128)%0Aat%20proguard.classfile.ProgramClass.accept(ProgramClass.java%3A430)%0Aat%20proguard.classfile.ClassPool.classesAccept(ClassPool.java%3A124)%0Aat%20proguard.classfile.visitor.AllClassVisitor.visitClassPool(AllClassVisitor.java%3A45)%0Aat%20proguard.classfile.visitor.MultiClassPoolVisitor.visitClassPool(MultiClassPoolVisitor.java%3A85)%0Aat%20proguard.classfile.ClassPool.accept(ClassPool.java%3A110)%0Aat%20proguard.shrink.Shrinker.execute(Shrinker.java%3A90)%0Aat%20proguard.ProGuard.shrink(ProGuard.java%3A381)%0Aat%20proguard.ProGuard.execute(ProGuard.java%3A145)%0Aat%20proguard.ProGuard.main(ProGuard.java%3A572)\" message=\"\" highlight=\"\" provider=\"manual\"\/] This is a ProGuard bug, which my friend, has been solved by the ProGuard\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3616,"url":"https:\/\/www.gubatron.com\/blog\/codejava-argb_8888-pixel-abstraction\/","url_meta":{"origin":3336,"position":5},"title":"[CODE\/JAVA] ARGB_8888 Pixel Abstraction","author":"gubatron","date":"December 4, 2016","format":false,"excerpt":"This is one of the ways you can decode Pixel colors out of the integers you get from Android Pixels. ARGB_8888, stands for Alpha, Reg, Green, Blue. The 8's stand for the number of bits per channel. In Android, signed int's are used to represent pixel's alpha\/color information. Since Android's\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3336"}],"version-history":[{"count":2,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3336\/revisions"}],"predecessor-version":[{"id":3784,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3336\/revisions\/3784"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}