- 安裝 Gradle
~$ sudo apt-get -y install
~$ brew install gradle
- 驗證 Gradle 版本 - gradle -v
jazz@jazzbook ~/git/gradle-sample$ gradle -v
------------------------------------------------------------
Gradle 2.12
------------------------------------------------------------
Build time: 2016-03-14 08:32:03 UTC
Build number: none
Revision: b29fbb64ad6b068cb3f05f7e40dc670472129bc0
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_77 (Oracle Corporation 25.77-b03)
OS: Mac OS X 10.11.4 x86_64
- 使用 gradle init 產生 gradle 專案目錄的範本
~$ mkdir -p gradle-sample
~$ cd gradle-sample
~/gradle-sample$ gradle init
:wrapper
:init
BUILD SUCCESSFUL
Total time: 2.419 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html
- gradle init 產生的目錄結構如下:
.
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
2 directories, 6 files
- 可以用 gradle tasks 了解目前定義了哪些 task
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'gradle-sample'.
components - Displays the components produced by root project 'gradle-sample'. [incubating]
dependencies - Displays all dependencies declared in root project 'gradle-sample'.
dependencyInsight - Displays the insight into a specific dependency in root project 'gradle-sample'.
help - Displays a help message.
model - Displays the configuration model of root project 'gradle-sample'. [incubating]
projects - Displays the sub-projects of root project 'gradle-sample'.
properties - Displays the properties of root project 'gradle-sample'.
tasks - Displays the tasks runnable from root project 'gradle-sample'.
BUILD SUCCESSFUL
Total time: 1.994 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html