上传库到Bintray.com

注册什么的就看文末的感谢链接

在项目根目录下build.gradle中添加以下内容

在这里插入图片描述

buildscript {
        dependencies {
            classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
            classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        }
}

在库模块目录下新建bintray.gradle文件

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

def siteUrl = 'https://github.com/zhangwei911/Paging'   // 项目的主页
def gitUrl = 'https://github.com/zhangwei911/Paging.git'   // Git仓库的url
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
version = "1.0.0" //发布版本号
group = "viz.commonlib" //最终引用形式,如implementation 'viz.commonlib:paging:1.0.0',其中paging在后面配置

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    pkg {
        repo = 'VCommon'//自己创建的仓库名字
        name = 'paging'//上传到JCenter的名字,最终引用的名字 implementation 'viz.commonlib:paging:1.0.0'
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ['Apache-2.0']//不能随便写,只能是仓库创建时选择的license type
        userOrg = 'viz' //自己创建的organization名称,一定要全是小写字母,即使当时创建的名称含有大写,这里全部转换为小写,否则404
        publish = true // 是否是公开项目,公开别人可以引用
        version {
            name = '1.0.0'
            desc = 'Android Jetpack Paging 封装'//描述,自己定义
            released  = new Date()
            vcsTag = 'v1.0.0'
            attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
        }
    }
    configurations = ['archives']
}


install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                // Add your description here
                name 'paging'
                description 'Android Jetpack Paging 封装'
                url siteUrl
                // Set your license
                licenses {
                    license {
                        name 'Apache-2.0' //和之前自己定义的协议一致
                        url 'https://github.com/zhangwei911/Paging/blob/master/LICENSE'
                    }
                }
                developers {
                    developer {
                        id 'wellchang222'        //填写bintray或者github的用户名
                        name '张维'         //姓名
                        email 'wei.zhang911.love@gmail.com'//邮箱
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

ext.packageTask = {
    task sourcesJar(type: Jar) {
        from android.sourceSets.main.java.srcDirs
        classifier = 'sources'
    }
    task javadoc(type: Javadoc) {
        failOnError false //必须添加以免出错
        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
    }
    javadoc {
        options {
            //如果你的项目里面有中文注释的话,必须将格式设置为UTF-8,不然会出现乱码
            encoding "UTF-8"
            charSet 'UTF-8'
            author true
            version true
            links "http://docs.oracle.com/javase/7/docs/api"
        }
    }
}

在库模块目录下build.gradle中添加以下内容

在这里插入图片描述

//在apply plugin: 'com.android.library'后添加
apply from: 'bintray.gradle'

在这里插入图片描述

//在最后面添加
packageTask()

在项目根目录中新建local.properties,并添加以下内容

#bintray用户名
bintray.user=xxxxx
#apikey,查看方法点击感谢链接
bintray.apikey=xxxxx

感谢

https://blog.csdn.net/Android_Study_OK/article/details/85283981

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值