{"id":473,"date":"2016-12-07T17:35:20","date_gmt":"2016-12-07T16:35:20","guid":{"rendered":"http:\/\/www.ume.li\/blog\/?p=473"},"modified":"2016-12-07T17:40:24","modified_gmt":"2016-12-07T16:40:24","slug":"fiddling-with-gradle","status":"publish","type":"post","link":"https:\/\/www.ume.li\/blog\/2016\/12\/07\/fiddling-with-gradle\/","title":{"rendered":"Fiddling with gradle"},"content":{"rendered":"<p>I&#8217;m getting more and more into the Java World at the moment. Switching from pure Domino to pure Java. Outside of Domino, there&#8217;s a lot about manageing dependencies. The freedom of choice is paid by work to beat different runtimes.<br \/>\nLooking for a decent tool to help managing dependencies I came across Ant, Maven and Gradle.<br \/>\nAnt I new from the past. It&#8217;s ok but seems to be a lot of code to write and it&#8217;s XML&#8230;<br \/>\nMaven? Seems that I&#8217;m not smart enough.<br \/>\nI was not able to setup a working multi project setup without installing my sub projects in a repository. And it&#8217;s XML too.<br \/>\nGradle, the youngest among these three, groovy based. After reading through some tutorials, and combing through stackoverflow I was able to setup my multi-project build,<br \/>\nwith integratopm into my eclipse environment.<\/p>\n<p>Even a Vaadin client is compiling with the right plugin. So I was not forced to use the Vaadin eclipse plugin at all. One thing I was not happy, the Vaadin plugin compiles some JavaDoc and Sources into my final EAR.<\/p>\n<p>Step 1: Remove the JavaDoc and Sources from the deployment descriptor<\/p>\n<pre class=\"brush: groovy; title: ; notranslate\" title=\"\">\r\ndeploymentDescriptor{\r\n....\r\nwithXml {\r\ndef javaDocNode = asNode().module.find { it.ejb.text().contains('javadoc.jar') }\r\nif (javaDocNode) {\r\nasNode().remove( javaDocNode )\r\n}\r\ndef sourceNode = asNode().module.find{it.ejb.text().contains('sources.jar') }\r\nif (sourceNode) {\r\nasNode().remove(sourceNode)\r\n}\r\n}\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Step 2: Removing the actual Jar&#8217;s from the EAR<\/p>\n<p>This <a href=\"http:\/\/stackoverflow.com\/questions\/27072183\/how-do-i-call-7zip-from-gradle-to-unsign-a-jar\" target=\"_blank\">page\u00a0<\/a>\u00a0helped me creating the following block<\/p>\n<pre class=\"brush: groovy; title: ; notranslate\" title=\"\">\r\nimport org.apache.tools.ant.taskdefs.condition.Os\r\ntask removeJars (dependsOn:'ear'){\r\ndescription 'Entferne unn\u00f6tige Source und JavaDoc Jars'\r\n\r\ndoLast {\r\n\tif (Os.isFamily(Os.FAMILY_UNIX)){\r\n\tprintln &quot;Entferne unn\u00f6tige Source und JavaDoc Jars&quot;\r\n\t exec {\r\n  \t\texecutable &quot;zip&quot;\r\n  \t\targs &quot;-d&quot;, &quot;build\/libs\/${project.archivesBaseName}-${project.version}.ear&quot;, &quot;*-${project.version}-sources.jar&quot;\r\n \t }\r\n     exec {\r\n     \texecutable &quot;zip&quot;\r\n  \t\targs &quot;-d&quot;, &quot;build\/libs\/${project.archivesBaseName}-${project.version}.ear&quot;, &quot;*-${project.version}-javadoc.jar&quot;\r\n \t}\r\n \t}\r\n \telse\r\n \t{\r\n \t\tprintln &quot;get Linux!&quot;\r\n \t}\r\n \t}\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now I can build my EAR by simply calling <span style=\"color: #0000ff;\">gradle assemble removeJars<\/span><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m getting more and more into the Java World at the moment. Switching from pure Domino to pure Java. Outside<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[33,34,32],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-connections","tag-gradle","tag-java","tag-vaadin"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":6,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/473\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}