使用阿里云Maven仓库部署项目公共jar包(Gardle)
进入阿里云的maven仓库,将以下复制到公共项目的build.gradlew中.
·
- 进入阿里云的maven仓库,将以下密码、用户名和url复制到公共项目的build.gradlew中填充(就是下面的java代码).(注意使用的是不是生产库,举例使用的生产库不是快照,release是生产,snapshot是快照)
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = "$project.group"
artifactId = "demo"
version = "$project.version"
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
repositories {
maven {
allowInsecureProtocol true
url = 'xxxxxxx'
credentials {
username = 'xxxxxx'
password = 'xxxxxx'
}
}
}
}
}
- 此外还需添加jar的处理方式,否则报错
bootJar {
enabled = false
}
jar {
enabled = true
}
- 其他项目引用该jar包,引用格式
allprojects {
repositories {
maven {
credentials {
username = 'xxxxxxx'
password = 'xxxxxx'
}
url = 'xxxxxxx'
}
//放其他的仓库
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/'}
}
}
- 在plugins中加上
** id 'maven-publish'**
- 流水线上构建上传时执行 ./gradlew build 和 ./gradlew publish
更多推荐
所有评论(0)