Android library三方框架-jcenter仓库

本文详细介绍了如何将Android library提交到JCenter仓库的步骤,包括创建bintray账号,配置项目Gradle,设置上传插件和命令,以及如何将库添加到JCenter并进行引用。完成这些步骤后,开发者可以通过JCenter直接引用你的Android库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

提交Android library 到jcenter

1.创建bintray官网账号
注册地址:https://bintray.com/signup
当然你也可以使用GitHub账号地址注册,这里需要注意邮箱地址不能是QQ邮箱地址
2.创建jcenter仓库
这里写图片描述
这里写图片描述
3.创建仓库的package–你的项目地址
这里写图片描述
这里写图片描述
4.在project项目的gradle文件中添加上传插件

 dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }

5.在需要上传的库Module里添加上传命令和参数
如下:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

def siteUrl = 'https://github.com/limushan/AnimationSummary'      // 配置项目地址
def gitUrl = 'https://github.com/limushan/AnimationSummary.git'
group = "com.possess"              //Maven Group ID for the artifact                                                 
version = "1.0.0"                  //版本号
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                name 'Plane Revolution For Android'        // 配置项目说明
                url siteUrl
                // Set your license
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'possess'                              // 配置你的昵称
                        name 'limushan'                           // 用户名
                        email '1530422024@qq.com'                 // 邮箱地址
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    // archives javadocJar
    archives sourcesJar
}

Properties properties = new Properties()
boolean isHasFile = false
if (project.rootProject.file('local.properties') != null){  
//在local.properties文件配置bintray账号的用户名和apikey
    isHasFile = true
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
bintray {
    user = isHasFile ? properties.getProperty("bintray.user") : System.getenv("bintray.user")
    key = isHasFile ? properties.getProperty("bintray.apikey") : System.getenv("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "android"               //配置你在jcenter上创建的仓库名
        name = "plane-revolution"     // 配置项目名即你在仓库中创建的package名
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}

APIKEY:
这里写图片描述
6.依此执行gradlew install 和gradlew bintrayUpload命令(Mac使用./gradlew命令)
上传成功:
这里写图片描述
7.引用: compile CROUP_IP:ARTIFACT_ID:VERSION
例如本库的的地址:
compile ‘com.possess:plane-revolution:1.0.0’
还需要加上下面这句话,添加你的bintray本地库地址,因为此时你的库还没有加入到jcenter中
maven {
url ‘https://dl.bintray.com/limushan/android/
}
8.加入jcenter库很简单:登录bintray账号,在你的项目中点击【Add to JCenter】发送信息提交
这里写图片描述
Bintray团队审核,审核通过会给你会邮件。此时就可以直接使用【compile ‘com.possess:plane-revolution:1.0.0’】
引用您的项目了。
这里写图片描述

项目GitHub地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值