Gradle5.x打jar包上傳maven倉庫
阿新 • • 發佈:2019-03-04
releases 私有 get rep mave then pan 參考 release
1.上傳本地倉庫
1.1 build.gradle 項目設置
plugins { id ‘java‘ id ‘maven‘ //引入maven插件 } group ‘com.inkyi‘ //包名 version ‘1.0.1-SNAPSHOT‘ //版本號
1.2 build.gradle 上傳設置
// 指定上傳的路徑 def localMavenRepo = ‘file://‘ + new File(System.getProperty(‘user.home‘), ‘.m2/repository‘).absolutePath // 上傳Task,Gradle會生成並上傳pom.xml文件。uploadArchives { repositories { mavenDeployer { repository(url: localMavenRepo)//構造項目的Pom文件 pom.project { name = project.name packaging = ‘jar‘ description = ‘description‘ } } } }
1.3 項目根目錄執行命令
Z:\xxxxxx>gradle uploadArchives BUILD SUCCESSFUL in 0s 3 actionable tasks: 1 executed, 2 up-to-date
2.上傳私有倉庫(參考Gradle Plugin文檔,沒有真正上傳過)
2.1 build.gradle 項目設置和上面的 1.1 一樣
2.2 build.gradle 上傳設置
// 上傳Task,Gradle會生成並上傳pom.xml文件。
uploadArchives {
repositories {
mavenDeployer {//這個地方,多了填寫用戶名和密碼的方法,用來私有倉庫的驗證
repository(url: "scp://repos.mycompany.com/releases") {
authentication(userName: "me", password: "myPassword")
}
//構造項目的Pom文件
pom.project {
name = project.name
packaging = ‘jar‘
description = ‘description‘
}
}
}
}
2.3 項目根目錄執行命令與1.3是一樣的
上傳本地倉庫的我試過是可以用的,上傳私有倉庫的還沒試過,建議有不符合的地方,參考文檔再調整一下。文檔地址:https://docs.gradle.org/current/userguide/maven_plugin.html
Gradle5.x打jar包上傳maven倉庫