这篇文章使用最简单的HelloWorld例子对Gradle的使用进行概要性的说明。
事前准备
事前安装和设定好gradle
liumiaocn:hello liumiao$ gradle --version
------------------------------------------------------------
Gradle 4.10.2
------------------------------------------------------------
Build time: 2018-09-19 18:10:15 UTC
Revision: b4d8d5d170bb4ba516e88d7fe5647e2323d791dd
Kotlin DSL: 1.0-rc-6
Kotlin: 1.2.61
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Mac OS X 10.14 x86_64
liumiaocn:hello liumiao$
第一个HelloWorld
- 准备一个groovy文件,具体信息如下
liumiaocn:hello liumiao$ ls
build.gradle
liumiaocn:hello liumiao$ cat build.gradle
println "hello gradle"
liumiaocn:hello liumiao$
- 执行gradle命令
liumiaocn:hello liumiao$ gradle
> Configure project :
hello gradle
> Task :help
Welcome to Gradle 4.10.2.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
liumiaocn:hello liumiao$
这个例子看起来更像