maven私服的搭建在這里先不介紹
1.引入jfrog插件
工程gradle中的buildscript下dependencied引入classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"捶惜;
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
}}
2.項目gradle中配置項目參數(shù)
注意王污!建議這一步寫在單獨的jfrog.gradle文件中。如果已經(jīng)有jfrog.gradle 文件隅居,直接跳轉第3步V购蟆O贡埂溜腐!
jfrog.gradle文件
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
repositories {
jcenter()
maven { url 'https://oss.jfrog.org/libs-snapshot' }
}
def packageName = 'your packageName'
def artifactName = 'your artifactName'
def libraryVersion = 'x.x.x'
publishing {
publications {
aar(MavenPublication) {
groupId packageName
artifactId artifactName
version = libraryVersion
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactory {
contextUrl = 'http://your ip:your port/artifactory'
publish {
repository {
repoKey = libraryVersion.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
username = "your username"
password = "your password"
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
3.生成aar包
執(zhí)行如下命令,output中會生成aar文件
gradle clean build
4.生成pom文件
在task列表中找到并執(zhí)行如下命令瓜喇,生成pom文件
Tasks - publishing - generatePomFileForAarPublication
pom文件生成位置:build-publications-aar文件夾
注意:pom文件中可能不會自動寫入依賴挺益,可能導致無法使用,如果無法使用乘寒,需要手動在pom中寫入依賴
5.上傳私服
在task列表中找到并執(zhí)行如下命令望众,上傳aar和pom文件到maven私服
Tasks - publishing - artifactoryPublish
6.升級
每次更新aar只需要改動jfrog.gradle文件中的libraryVersion即可。