{"id":434,"date":"2017-11-27T20:52:06","date_gmt":"2017-11-28T01:52:06","guid":{"rendered":"http:\/\/jebware.com\/blog\/?p=434"},"modified":"2020-06-05T11:11:31","modified_gmt":"2020-06-05T16:11:31","slug":"proguard-pro-tip-dont-use-proguards-include-with-gradle-builds","status":"publish","type":"post","link":"https:\/\/jebware.com\/blog\/?p=434","title":{"rendered":"ProGuard pro-tip: Don&#8217;t use ProGuard\u2019s \u201c-include\u201d with Gradle builds"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">I like to organize my ProGuard rules by breaking them up into separate files, grouped by what they&#8217;re acting on &#8212; my data model, third-party libs, etc.<\/span><\/p>\n<p><a href=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-27-at-8.46.19-PM.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-437\" src=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-27-at-8.46.19-PM.png\" alt=\"\" width=\"220\" height=\"83\"><\/a><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s tempting to reference one main ProGuard file from your build.gradle, and then put &#8216;-include\u2019 entries in the main file to point to the rest, but there&#8217;s a problem with this. If you make a change in one of the included files, it won&#8217;t be picked up until you do a clean build.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The reason for this is Gradle\u2019s model of inputs and outputs for tasks. &nbsp;Gradle is really smart about avoiding unnecessary work, so if none of the inputs for a task have changed, then Gradle won&#8217;t rerun the task. &nbsp;If you list one main ProGuard file in your build.gradle and include the rest from there, Gradle only sees the main file as an input. &nbsp;So if you make changes in an included file, Gradle doesn&#8217;t think anything changed.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The easy way I&#8217;ve found to work around this is to put all of my ProGuard rules into a directory, and include them all in your build.gradle with this snippet:<\/span><\/p>\n<p><script src=\"https:\/\/gist.github.com\/jebware\/e9a2af4782d3b31c961f9a06a902ae79.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like to organize my ProGuard rules by breaking them up into separate files, grouped by what they&#8217;re acting on &#8212; my data model, third-party libs, etc. It&#8217;s tempting to reference one main ProGuard file from your build.gradle, and then put &#8216;-include\u2019 entries in the main file to point to the rest, but there&#8217;s a &hellip; <a href=\"https:\/\/jebware.com\/blog\/?p=434\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ProGuard pro-tip: Don&#8217;t use ProGuard\u2019s \u201c-include\u201d with Gradle builds&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"twitterCardType":"summary","cardImageID":0,"cardImage":"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-27-at-8.46.19-PM.png","cardTitle":"","cardDesc":"","cardImageAlt":"","cardPlayer":"","cardPlayerWidth":0,"cardPlayerHeight":0,"cardPlayerStream":"","cardPlayerCodec":""},"categories":[4,16],"tags":[],"_links":{"self":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/434"}],"collection":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=434"}],"version-history":[{"count":4,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/434\/revisions"}],"predecessor-version":[{"id":627,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/434\/revisions\/627"}],"wp:attachment":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}