chd 6d64a49960 更新 'upload.gradle' | 2 years ago | |
---|---|---|
.gitignore | 2 years ago | |
README.md | 2 years ago | |
base.gradle | 2 years ago | |
maven.gradle | 2 years ago | |
upload.gradle | 2 years ago | |
version.gradle | 2 years ago |
Gradle工程统一Gradle全局配置
gradle相比maven配置灵活,可自定义更多的任务,但是当项目众多,每个项目都去维护一大堆gradle配置的时候,会发现版本变得很难管理,每个项目一个gradle.properties,公共组件,其他组件都无法达到统一维护版本的问题。 本文主要解决gradle将版本进行统一管理
在项目最外层的build.gradle中
//buildscript不能省略,每个项目必须定义
buildscript {
ext {
gradleHome = 'http://192.168.16.201:8899/basic-public-component/itgdevfwk-public-group/cecdhc-basic-gradle-base/raw/master/'
}
//maven.gradle配置
apply from: resources.text.fromInsecureUri(gradleHome + 'maven.gradle')
//version.gradle配置
apply from: resources.text.fromInsecureUri(gradleHome + 'version.gradle')
//私库
repositories {
maven {
allowInsecureProtocol = true
url REPOSITORY_URL
}
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:${gradleManagePluginVersion}"
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply from: resources.text.fromInsecureUri(gradleHome + 'base.gradle')
version = '1.0.0-SNAPSHOT'
group = 'cec.dhc.itgfwk.oauth'
dependencies {
//模块引用
implementation project(':demo-api')
}
1.如项目的api模块,需要对外提供jar包到私库中时,使用方式如下 在模块下的build.gradle中配置
group 'cec.dhc.itgfwk.api.oauth'
apply from: resources.text.fromInsecureUri(gradleHome + 'upload.gradle')
dependencies {
compileOnly ("io.swagger:swagger-annotations")
compileOnly ("io.springfox:springfox-core")
compileOnly ("javax.servlet:javax.servlet-api")
compileOnly ("org.springframework:spring-web")
compileOnly ("cec.dhc.plffwk.comps:cecdhc-plffwk-component")
compileOnly ("cec.dhc.devfwk.starters.feign:cecdhc-devfwk-starters-feign")
}
2.非api模块使用
dependencies {
implementation ("io.swagger:swagger-annotations")
}