安装gradle
~$ mkdir -p /usr/local/gradle
~$ cd /usr/local/gradle
~$ unzip ~/Downloads/gradle-6.0-bin.zip
- 导入环境
- 将
Gradle
的bin
目录添加到PATH
环境变量
~$ echo "export PATH=$GRADLE_HOME/bin:$PATH" >> ~/.bashrc # ~/.bash_profile ~/.zshrc
~$ source ~/.bashrc
- 或者将
Gradle
的可执行文件软连接到/usr/loca/bin
~$ ln -s $GRADLE_HOME/bin/gradle /usr/local/bin/gradle
提示: $GRADLE_HOME
指的是gradle
解压后的目录, 比如 /usr/local/gradle/6.0
使用gradle
创建初始工程
➜ Kotlin mkdir project
➜ Kotlin cd project
➜ project gradle init
Configuration on demand is an incubating feature.
Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4] 2
Select implementation language:
1: C++
2: Groovy
3: Java
4: Kotlin
5: Swift
Enter selection (default: Java) [1..5] 4
Select build script DSL:
1: Groovy
2: Kotlin
Enter selection (default: Kotlin) [1..2] 2
Project name (default: project): app
Source package (default: app): com