AndroidStudio发布项目到jcenter流程记录

1、打开https://bintray.com 注册创建自己的账号、maven库、新的项目包


2、在Project目录build.gradle中

buildscript {
	dependencies {
        	classpath 'com.android.tools.build:gradle:2.2.2'


	        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
        	classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
	        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
	}
}


allprojects {
    repositories {
        jcenter()
    }


    tasks.withType(Javadoc).all {
        enabled = false
        options.setEncoding('UTF-8')
    }
}




3、在要上传的Moudle目录build.gradle中

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


version = "1.0.0"
group = "abc.def" // Maven Group ID for the artifact,一般填你唯一的包名
def siteUrl = '' // 项目的主页
def gitUrl = '' // Git仓库的url


android {
    compileSdkVersion 23
    buildToolsVersion "24.0.2"
    resourcePrefix "libname__"


    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())


bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"
        name = "libname"    //发布到JCenter上的项目名字 组合开始的group和version -> compile 'abc.def:libname:1.0.0'
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}


install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                // Add your description here
                name '' //项目描述 不重要应该
                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 ''    //填写的一些基本信息 在jcenter上注册的 id 
                        name 'else'  // 在jcenter的昵称
                        email '' // 联系用的电子邮件
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}


dependencies {
    ...
}


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
}


4、项目build成功后,在androidstudio terminal中输入
gradlew bintrayUpload

 
5、https://bintray.com/<你的用户id>/maven/<项目包>  这个页面下中Versions下应该会有一个1.0.0
点击add to jcenter button。如果没有看到这个按钮,输入网址 https://bintray.com/bintray/jcenter?filterByPkgName=<项目名称libname>
这个时候会自动提示是否添加项目到jcenter,选择自己的项目确定,进入界面https://bintray.com/repo/packageInclusionRequestToJcenter。
输入描述并且提交



文章参考
http://blog.csdn.net/lmj623565791/article/details/51148825
http://blog.csdn.net/wangdong20/article/details/50098535
https://github.com/dcendents/android-maven-gradle-plugin
http://blog.csdn.net/zdd199401/article/details/52387472
https://github.com/Tencent/tinker/blob/master/build.gradle

你可能感兴趣的:(Android)