{"id":20281,"date":"2015-06-03T15:42:08","date_gmt":"2015-06-03T10:12:08","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=20281"},"modified":"2015-06-03T15:42:08","modified_gmt":"2015-06-03T10:12:08","slug":"run-gradle-tasks-from-grails-3-custom-scripts","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/run-gradle-tasks-from-grails-3-custom-scripts\/","title":{"rendered":"Run Gradle tasks from Grails 3 custom scripts"},"content":{"rendered":"<p>In Grails 3 each script extends from GroovyScriptCommand. One of the property which GroovyScriptCommand provides is &#8220;gradle&#8221;. With the help of this property you can invoke gradle tasks.<\/p>\n<p>When you write :<br \/>\n[java]<br \/>\ngrails create-scipt demo<br \/>\n[\/java]<br \/>\nA script file will be generated in src\/main\/scripts folder with the name demo.groovy<\/p>\n<p>Now let us assume that there is a custom task in build.gradle:<br \/>\n[java]<br \/>\ntask hello {<br \/>\n    doLast { println &quot;This is my task&quot; }<br \/>\n}<br \/>\n[\/java]<br \/>\nand we want to execute this Gradle task inside our custom Grails script.<br \/>\nWe can simply do it by using the following statement in<br \/>\ndemo.groovy<br \/>\n[java]<br \/>\ngradle.hello()<br \/>\n[\/java]<br \/>\nNow if we run the grails custom script:<br \/>\n[java]<br \/>\ngrails demo<br \/>\n[\/java]<br \/>\nIt will run the hello task inside build.gradle<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Grails 3 each script extends from GroovyScriptCommand. One of the property which GroovyScriptCommand provides is &#8220;gradle&#8221;. With the help of this property you can invoke gradle tasks. When you write : [java] grails create-scipt demo [\/java] A script file will be generated in src\/main\/scripts folder with the name demo.groovy Now let us assume that [&hellip;]<\/p>\n","protected":false},"author":102,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20281"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/102"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=20281"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20281\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=20281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=20281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=20281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}