android gradle 發(fā)布插件到 jcenter

1.在bintray官網(wǎng)注冊一個開源的賬號,可以用谷歌郵箱或者 GitHub 賬號 ,推特賬號授權(quán)登錄

2.注冊后創(chuàng)建代碼倉庫


3.在倉庫下創(chuàng)建一個 package,此 package 表現(xiàn)為在項目中引用的artifactId

4.修改項目的根目錄的? build.gradle文件引用 bintray 的插件

dependencies {

classpath 'com.android.tools.build:gradle:3.0.0'

? ? ? ? classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

? ? ? ? classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'

//? ? ? ? classpath 'com.huodonghezi.aspectj.Plugin:hzaspectj:1.1.0'

}

5.修改module的 build.gradle文件

applyplugin:'groovy'

applyplugin:'maven'

applyplugin:'com.jfrog.bintray'

applyplugin:'maven-publish'

//另外一個上傳包到 jcenter 的插件

//apply plugin: 'com.novoda.bintray-release'//添加

dependencies {

compile gradleApi()

compile localGroovy()

compile'com.android.tools.build:gradle:3.0.0'

? ? compile"org.aspectj:aspectjtools:1.8.9"

? ? compile"org.aspectj:aspectjrt:1.8.9"

? ? compile'com.android.tools.build:transform-api:1.5.0'

}

repositories {

mavenCentral()

}

//打包到本地

//group = 'com.huodonghezi.aspectj.Plugin'

//version = '1.1.0'

//uploadArchives {

//? ? repositories {

//? ? ? ? mavenDeployer {

//? ? ? ? ? ? repository(url: uri('../repo'))

//? ? ? ? }

//? ? }

//}

group ='com.weijian.welljan'? // 組名 jcenter中的倉庫路徑

version ='1.0.0' // 版本

//// 應(yīng)用插件

applyfrom:'bintray.gradle'

6.在 module 目錄新建一個 bintray.gradle 的文件

// 應(yīng)用插件

applyplugin:'com.jfrog.bintray'

applyplugin:'maven-publish'

def baseUrl ='https://github.com/WellJan'

def siteUrl = baseUrl

def gitUrl ="${baseUrl}/hzAspectJ"

def issueUrl ="${gitUrl}/issues"

install {

repositories {

mavenInstaller {

// This generates POM.xml with proper paramters

? ? ? ? ? ? pom.project {

//添加項目描述

? ? ? ? ? ? ? ? name'Gradle Plugin for Android'

? ? ? ? ? ? ? ? url siteUrl

//設(shè)置開源證書信息

? ? ? ? ? ? ? ? licenses {

license {

name'The Apache Software License, Version 2.0'

? ? ? ? ? ? ? ? ? ? ? ? url'http://www.apache.org/licenses/LICENSE-2.0.txt'

? ? ? ? ? ? ? ? ? ? }

}

//添加開發(fā)者信息

? ? ? ? ? ? ? ? developers {

developer {

name'jcenter 的用戶名'

? ? ? ? ? ? ? ? ? ? ? ? email' jcenter 登錄郵箱'

? ? ? ? ? ? ? ? ? ? }

}

scm {

connection gitUrl

developerConnection gitUrl

url siteUrl

}

}

}

}

}

//配置上傳Bintray相關(guān)信息

bintray {

user ='用戶名'

? ? key =' jcenter 的個人 api key'

? ? configurations = ['archives']

pkg {

repo ='welljan' // 上傳到中央倉庫的名稱

? ? ? ? name ='hzAspectJ' // 上傳到j(luò)center 的項目名稱

? ? ? ? desc ='test aop' // 項目描述

? ? ? ? websiteUrl = siteUrl

issueTrackerUrl = issueUrl

vcsUrl = gitUrl

labels = ['gradle','plugin']

licenses = ['Apache-2.0']

publish =true

? ? }

}



7.設(shè)置好后,重新編譯,執(zhí)行 gradle.install 然后在執(zhí)行 gradle.bintrayUpload?

8.執(zhí)行過程中如果是發(fā)現(xiàn)找不到 maven 庫 的表示你注冊的不是開源的賬號,如果是另外一個測試版的話 需要新建名字為 maven 的倉庫才行

9.執(zhí)行完畢后在 bintray 后臺即可看到上傳的庫的信息,以及可以加入 jcenter


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容