码迷,mamicode.com
首页 > 移动开发 > 详细

上传Android代码到Jcenter

时间:2015-04-30 19:41:30      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

请先阅读:http://blog.saymagic.cn/2015/02/16/release-library-to-jcenter.html

 

最外面的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {url ‘http://dl.bintray.com/tianzhijiexian/maven‘}
    }
    dependencies {
        classpath ‘com.android.tools.build:gradle:1.1.3‘
        classpath ‘com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0‘
        classpath ‘com.github.dcendents:android-maven-plugin:1.2‘
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

app的build.gradle

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

// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
version = "1.0.0"

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    resourcePrefix "随便填"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
        }
    }

    lintOptions {
        abortOnError true
    }
}

dependencies {
    compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
}

def siteUrl = ‘https://github.com/xxx/xxx// 项目的主页
def gitUrl = ‘https://github.com/xxx/xxx.git‘   // Git仓库的url
group = "com.kale.xx" // Maven Group ID for the artifact,一般填你唯一的包名
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging ‘aar‘
                // Add your description here
                name ‘Extra xxx//项目描述
                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 kale//填写开发者基本信息
                        name ‘kale
                        email xxxxx@qq.com
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

tasks.withType(JavaCompile) { options.encoding = "UTF-8" }


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
}

javadoc {
    options {
        encoding "UTF-8"
        charSet ‘UTF-8‘
        author true // 支持author标记
        version true // 支持version标记
        links "http://docs.oracle.com/javase/7/docs/api"
    }
}

artifacts {
    archives javadocJar
    archives sourcesJar
}
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"  //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
        name = "ExtraXXXXX"  //发布到Bintray上的项目名字
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}

local.properties

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=H\:\\Android\\sdk

bintray.user = 名字
bintray.apikey = 密钥

 

参考自:

http://www.cnblogs.com/qianxudetianxia/p/4322331.html

http://www.linuxidc.com/Linux/2015-02/113874.htm

http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0227/2502.html

http://blog.saymagic.cn/2015/02/16/release-library-to-jcenter.html

上传Android代码到Jcenter

标签:

原文地址:http://www.cnblogs.com/tianzhijiexian/p/4469543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!