{"id":3321,"date":"2014-07-29T19:20:31","date_gmt":"2014-07-29T19:20:31","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3321"},"modified":"2019-04-25T13:15:03","modified_gmt":"2019-04-25T13:15:03","slug":"solved-gradle-how-to-increase-the-java-compilers-available-heap-memory","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/solved-gradle-how-to-increase-the-java-compilers-available-heap-memory\/","title":{"rendered":"[SOLVED] Gradle: How to increase the Java Compiler&#8217;s available Heap Memory"},"content":{"rendered":"<p>The documentation is not very clear on what all the available options are&#8230;<br \/>\nafter much Googling and many different attempts finally figured out how to raise the maximum heap of the compiler from within the gradle.build script.<\/p>\n<p>[pastacode lang=&#8221;java&#8221; manual=&#8221;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&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n<p><strong>Update:<\/strong><br \/>\nSo I&#8217;ve noticed this works great on MacOSX, but it doesn&#8217;t work at all on Windows 8.<\/p>\n<p>The solution to increasing the JVM&#8217;s Heap has been to <strong>remove those options from gradle.build<\/strong> script and <strong>add a new file<\/strong> on the same folder as where your gradle.build file lives called <strong>&#8216;gradle.properties&#8217;<\/strong><\/p>\n<p>These are the contents that made it work for both Mac and Windows (I&#8217;ve still not tested this on my linux box)<\/p>\n<p>[pastacode lang=&#8221;java&#8221; manual=&#8221;org.gradle.jvmargs%3D-Xms256m%20-Xmx1024m&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The documentation is not very clear on what all the available options are&#8230; 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=&#8221;java&#8221; manual=&#8221;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&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/] Update: So I&#8217;ve noticed this works great on MacOSX, but it doesn&#8217;t [&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":[1410,232,1409,583,1411],"class_list":["post-3321","post","type-post","status-publish","format-standard","hentry","category-code","tag-ant","tag-building","tag-gradle","tag-java","tag-java-compiler"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-Rz","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":3321,"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":3336,"url":"https:\/\/www.gubatron.com\/blog\/gradle-how-to-specify-resources-from-different-folders-on-your-sourceset\/","url_meta":{"origin":3321,"position":1},"title":"GRADLE: How to specify resources from different folders on your sourceSet","author":"gubatron","date":"July 29, 2014","format":false,"excerpt":"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\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":3315,"url":"https:\/\/www.gubatron.com\/blog\/gradle-how-to-add-a-list-of-local-jars-to-the-build-classpath\/","url_meta":{"origin":3321,"position":2},"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":3321,"position":3},"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":3164,"url":"https:\/\/www.gubatron.com\/blog\/how-to-have-a-play-framework-app-autostart-during-boot-on-elastic-beanstalk-centos-ec2-instances\/","url_meta":{"origin":3321,"position":4},"title":"How to have a Play framework app autostart during boot on Elastic Beanstalk CentOS ec2 instances","author":"gubatron","date":"September 27, 2013","format":false,"excerpt":"So you've created an Elastic Beanstalk environment, you have a play framework distribution which you've created using play dist (either on your local environment, or right there on the server, whatever you prefer) play dist outputs a my-app-1.0.zip file which has a self-contained version of your app with all the\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":3321,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3321","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=3321"}],"version-history":[{"count":10,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions"}],"predecessor-version":[{"id":3788,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions\/3788"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}