?????通過(guò)上面的介紹組件修改上傳至本地后洼畅,我們大概知道了如何將項(xiàng)目上傳的步驟芥备,接下來(lái)我們進(jìn)一步的修改將項(xiàng)目上傳到maven的私服.
繼續(xù)上面的library項(xiàng)目
1.在整個(gè)項(xiàng)目中g(shù)radle.properties文件中添加
RELEASE_URL = xxx
SNAPSHOT_URL = xxx
NAME = xxx
PASSWORD = xxx
VERSION = 1.0-SNAPSHOT
GROUP = xxx.xxx.xxxx
POM_ARTIFACT_ID = xxxx
2.在需要修改成maven的library目錄下屁使,創(chuàng)建maven_push.gradle文件
apply plugin:'maven'
apply plugin:'signing'
configurations{
deployerJars
}
repositories{
mavenCentral()
}
//判斷版本是Release or snapshot
def isReleaseBuild(){
return !VERSION.contains("SNAPSHOT");
}
//獲取倉(cāng)庫(kù)URL
def getRepositoryUrl(){
return isReleaseBuild()? RELEASE_URL : SNAPSHOT_URL;
}
uploadArchives{
repositories{
mavenDeployer{
beforeDeployment{
MavenDeployment deployment -> signing.signPom(deployment)
}
pom.version = VERSION
pom.artifaceId = POM_ARTIFACE_ID
pom.groupId = GROUP
repository(url:getRepositoryUrl()){
authentication(userName:NAME,password:PASSWORD)//maven授權(quán)
}
}
}
}
//進(jìn)行數(shù)字簽名
signing{
required{
isReleaseBuild()&& gradle.taskGraph.hasTask("uploadArchives")
}
sign configurations.archives
}
3.在需要修改成maven的library下修改build.gradle文件
apply from: 'maven_push.gradle'