Run Gradle tasks from Grails 3 custom scripts

03 / Jun / 2015 by pulkit 0 comments

In Grails 3 each script extends from GroovyScriptCommand. One of the property which GroovyScriptCommand provides is “gradle”. With the help of this property you can invoke gradle tasks.

When you write :
grails create-scipt demo
A script file will be generated in src/main/scripts folder with the name demo.groovy

Now let us assume that there is a custom task in build.gradle:
task hello {
doLast { println "This is my task" }
and we want to execute this Gradle task inside our custom Grails script.
We can simply do it by using the following statement in
Now if we run the grails custom script:
grails demo
It will run the hello task inside build.gradle


Leave a Reply

Your email address will not be published. Required fields are marked *