Gradle笔记
基本概念
命令的类别
- application
run
- build
- assemble
- build
- buildDependents
- buildNeeded
- classes
- clean
- jar
- testClasses
- build setup
- init
- wrapper
- distribution
- documentation
- javadoc
- help
- buildEnvironment
- other
- verification
常用命令
gradle tasks 显示可用的task列表
gradle [task]
gradle build
其他
- 存在build.gradle文件是,执行gradle build,执行成功,生成 build 文件夹
build.gradle 文件
apply plugin: 'java'
# 声明为可运行程序
apply plugin: 'application'
# 主函数入口
mainClassName = 'hello.HelloWorld'
# 打包配置
jar {
archiveBaseName = 'gs-gradle'
archiveVersion = '0.1.0'
}
# 兼容版本
sourceCompatibility = 1.8
targetCompatibility = 1.8
# 指定第三方仓库
repositories {
mavenCentral()
}
# 声明依赖
dependencies {
implementation "joda-time:joda-time:2.2"
testImplementation "junit:junit:4.12"
}
I'll put a flower in your hair~