Gradle-learning
配置文件解释
build.gradle
对当前项目做局部配置
plugins { // 项目中声明了哪些插件
id 'java' // id 表示项目中要使用哪个插件,调用所有的java相关插件
// id 'kotlin'
}
项目组织以及版本号
// 项目名称在settings.gradle
group 'org.example' // 组织名
version '1.0-SNAPSHOT' // 版本号 "SNAPSHOT"表示快照版本,"RELEASED"表示稳定版
repositories { // 下载的文件放置在.gradle文件下
mavenCentral()
}
依赖管理,可以在maven中心仓库查看依赖怎么写。格式为scope group:name:version
testRuntimeOnly
称为Scope
- complie 表示编译、运行可用,打包时也会加入
- testRuntimeOnly 表示运行测试时可用
- providedCompile 仅在当前环境可用
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
test {
useJUnitPlatform()
}
settings.gradle
全局配置
rootProject.name = 'gradleDemo'
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 chl'blog!