➜ ~ gradle -v WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/java/groovy-all.jar) to method java.lang.Object.finalize() WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
Build time: 2012-12-21 00:00:00 UTC Revision: none
Groovy: 2.4.16 Ant: Apache Ant(TM) version 1.10.5 compiled on March 28 2019 JVM: 11.0.4 (Ubuntu 11.0.4+11-post-Ubuntu-1ubuntu218.04.3) OS: Linux 5.0.0-36-generic amd64
➜ gradle01 gradle -a tasks --no-rebuild/-a has been deprecated and is scheduled to be removed in Gradle 5.0.
> Configure project : go for it
> Task :tasks
------------------------------------------------------------ All tasks runnable from root project ------------------------------------------------------------
Build tasks ----------- hello - hello world
Build Setup tasks ----------------- init - Initializes a new Gradle build. wrapper - Generates Gradle wrapper files.
Help tasks ---------- buildEnvironment - Displays all buildscript dependencies declared in root project 'gradle01'. components - Displays the components produced by root project 'gradle01'. [incubating] dependencies - Displays all dependencies declared in root project 'gradle01'. dependencyInsight - Displays the insight into a specific dependency in root project 'gradle01'. dependentComponents - Displays the dependent components of components in root project 'gradle01'. [incubating] help - Displays a help message. model - Displays the configuration model of root project 'gradle01'. [incubating] projects - Displays the sub-projects of root project 'gradle01'. properties - Displays the properties of root project 'gradle01'. tasks - Displays the tasks runnable from root project 'gradle01'.
To see all tasks and more detail, run gradle tasks --all
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed
> Configure project : The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
> Task :helloworld hello world!
> Task :goforit go for it!
BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed
> Configure project : The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
> Task :helloworld hello world!
> Task :goforit go for it!
BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed
task method <<{ add(1, 2) minus 1, 2 //语句后面的可以省略,方法的括号可以省略。 def n = mul 1, 2 println n def f = div 2.0, 3 println f } //用def关键字定义方法。 def add(int a, int b){ println a + b } def minus(a, b){//参数类型可以省略 println a - b } //指定了方法返回类型,可以不需要def关键字来定义方法。 int mul(a, b){ return a * b } //如果不使用return ,方法的返回值为最后一行代码的执行结果。 double div(a, b){//return可以省略掉 a/b }