新建一个文件夹, 在里面编辑 build.gradle

doLast
1
2
3
4
5
task hello {
doLast {
println 'Hello world!'
}
}
1
2
$ gradle -q build
Hello world!

doLast的简化写法
1
2
3
task hello << {
println 'Hello world!'
}
1
2
$ gradle -q build
Hello world!

Use String Lower&Upper
1
2
3
4
5
6
task string << {
String someString = "mY_nAme"
println "Original: " + someString
println "Lower case: " + someString.toLowerCase()
println "Upper case: " + someString.toUpperCase()
}
1
2
$ gradle -q build
Hello world!