Android Studio to upload lib Jcenter (Record)

Explanation

Android Stuido by a simple phrase can cite some tripartite libraries, greatly facilitates the program. Sometimes, we also want to save some of their own development libraries down for later use. Search for a long time, finally realized.

Procedure:

The relevant functions through four steps.

  • Step 1:
    add the following code in the top build.gradle:
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

After increasing effect as follows:
Write pictures described here

  • Step 2:
    open build.gradle lib library (or new) gradle.properties file, this file-related information is configured, add the following fields
PROJ_GROUP=cn.com.jkin
PROJ_VERSION=1.0.0
PROJ_NAME=jad
PROJ_WEBSITEURL=https://github.com/ss/jkin    //项目地址
PROJ_VCSURL=https://github.com/ss/GooglePlayer.git   //项目所在vcs地址
PROJ_DESCRIPTION=a spinner can memory history select item //说明
PROJ_ARTIFACTID=jad  //
DEVELOPER_ID=wujinxiang  //开发者id
DEVELOPER_NAME=wujinxiang  //开发者姓名
[email protected] //开发者email
BINTRAY_USER=kailaisi       //bintray的用户名
BINTRAY_KEY=39855***42daf852fe      //bintray的key值
PROJ_ISSUETRACKERURL=https://github.com/kailaisi/GooglePlayer //问题反馈地址

The effect is as follows:
Write pictures described here

  • Step 3:

Add the following code in build.gradle lib library is located, you do not need to change anything. Wherein the parameter modification related settings in step 2.

group = PROJ_GROUP
version = PROJ_VERSION
project.archivesBaseName = PROJ_ARTIFACTID

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

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

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += configurations.compile
    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
        version true
        links "http://docs.oracle.com/javase/7/docs/api"
        title PROJ_ARTIFACTID
    }
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

install {
    repositories.mavenInstaller {
        pom.project {
            name PROJ_NAME
            description PROJ_DESCRIPTION
            url PROJ_WEBSITEURL
            inceptionYear '2016'

            packaging 'aar'
            groupId PROJ_GROUP
            artifactId PROJ_ARTIFACTID
            version PROJ_VERSION

            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }
            scm {
                connection PROJ_VCSURL
                url PROJ_WEBSITEURL

            }
            developers {
                developer {
                    id DEVELOPER_ID
                    name DEVELOPER_NAME
                    email DEVELOPER_EMAIL
                }
            }
        }
    }
}

bintray {
    user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : project.property('BINTRAY_USER')
    key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : project.property('BINTRAY_KEY')

    configurations = ['archives']

    dryRun = false
    publish = true

    pkg {
        repo = 'maven'
        name = PROJ_NAME
        licenses = ['Apache-2.0']
        vcsUrl = PROJ_VCSURL
        websiteUrl = PROJ_WEBSITEURL
        issueTrackerUrl = PROJ_ISSUETRACKERURL
        publicDownloadNumbers = true
        version {
            name = PROJ_VERSION
            desc = PROJ_DESCRIPTION
            vcsTag = PROJ_VERSION

            gpg {
                sign = true
            }

            mavenCentralSync {
                sync = project.hasProperty('SONATYPE_USER') && project.hasProperty('SONATYPE_KEY')
                user = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : ""
                password = project.hasProperty('SONATYPE_PASS') ? project.property('SONATYPE_PASS') : ""
                close = '1'
            }
        }
    }
}
  • Step 4:
    At this time, configuration has been completed, directly enter the relevant instruction in the terminal, can be introduced into their bintray the library lib.
    Write pictures described here

The first step is to check the correctness of the code, and the compiler library file (aar, pom, etc.), enter the following command:

gradlew install

If there is no problem, after a long, long testing, it will be displayed:

BUILD SUCCESSFUL
now we have half the battle. The next step is to upload files to compile bintray, use the following command:

gradlew bintrayUpload

look forward:


Published 16 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/adfghjkl/article/details/52233379