Android Studio 发布项目到Jcenter

简介

本文介绍如何发布一个简单的项目到Bintray

注册账号和生成Maven库的步骤省略,不过注意Maven库的名字最好取maven。

上传的主项目的gradle的配置

上传的插件用的是 com.novoda:bintray-release:0.3.4
如果项目中包含中文注释或中文字符,最好添加

tasks.withType(Javadoc) {
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
    }

不然会报错
项目Gradle配置

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.novoda:bintray-release:0.3.4'
    }
}

allprojects {
    repositories {
        jcenter()
    }
    tasks.withType(Javadoc) {
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

上传的Module的gradle的配置

添加

apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'
publish {
    userOrg = 'anotherme17'//bintray.com用户名
    groupId = 'com.anotherme17'//jcenter上的路径
    artifactId = 'common-adapter'//项目名称
    publishVersion = '0.0.1'//版本号
    desc = 'An CommonAdapter for ListView or RecyclerView'//描述,不重要
    website = 'https://github.com/anotherMe17/CommonAdapterSample'
    //网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
}

publish {
    userOrg = 'anotherme17'//bintray.com用户名
    groupId = 'com.anotherme17'//jcenter上的路径
    artifactId = 'common-adapter'//项目名称
    publishVersion = '0.0.1'//版本号
    desc = 'An CommonAdapter for ListView or RecyclerVIew'//描述,不重要
    website = 'https://github.com/anotherMe17/CommonAdapterSample'
    //网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
}

执行

在控制台输入以下代码

./gradlew clean build bintrayUpload 
 -PbintrayUser=hyman 
 -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx 
 -PdryRun=false

user就是用户名,key就是我们刚才的让你保存的key,PdryRun是一个配置参数,当为true的时候,会运行所有的环节,但是不会上传

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值