Android Library Gradle Publish uploads projects to JCenter quickly

introduce

This project contains Gradle scripts and properties files

Account configuration

First register bintray account, address: bintray.com/. After the account is generated, you will be automatically assigned an API Key. The account name and API Key are the keys that we can upload library to Bintray.

We need to save this information to local.properties:

BINTRAY_USER=*********
BINTRAY_APIKEY=*******************************
BINTRAY_GPG_PASSWORD=Copy the code

Project configuration

Step 1: Add it to your root build.gradle file

Classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 1.3' classpath 'com. Jfrog. Bintray. Gradle: gradle bintray - plugin: 1.2'Copy the code

Step 2: Add it to the build.gradle file in your Library Module

apply from: 'https://raw.githubusercontent.com/LiangMaYong/android-library-gradle-publish/master/library.gradle'
apply from: 'https://raw.githubusercontent.com/LiangMaYong/android-library-gradle-publish/master/bintray.gradle'
apply from: 'https://raw.githubusercontent.com/LiangMaYong/android-library-gradle-publish/master/install.gradle'Copy the code

Step 3: Configure in the project gradle.properties

# PROJ_GROUP=com.liangmayong # Project name PROJ_NAME=BintrayDemo # Project version PROJ_VERSION=1.0.0 PROJ_WEBSITEURL=https://github.com/liangmayong/bintray-demo [email protected]:liangmayong/bintray-demo.git PROJ_DESCRIPTION= this is android Library bintray-demo # project artifactId =bintray-demo # Developer info DEVELOPER_ID=linagmayong DEVELOPER_NAME=Liang Ma Yong [email protected]Copy the code

Compile and upload

Run gradlew Install to verify compilation

gradlew installCopy the code

Execute gradlew bintrayUpload to publish the library to bintray.com

gradlew bintrayUploadCopy the code

Use the format

The example above is eventually referenced in Android Studio as follows:

repositories { maven { url 'https://dl.bintray.com/liangmayong/maven/' } } ...... Dependencies {compile 'com.liangmayong:bintray-demo:1.0.0'}Copy the code

As you can see, it is composed of PROJ_GROUP:PROJ_ARTIFACTID:PROJ_VERSION.

Q&A

Keep your Library Module name the same as artifactId, otherwise an error will be reported

Could not upload to 'https://*****.pom': HTTP/1.1 400 Bad Request [message:Unable to upload files: Maven group, artifact or version defined in the pom file do not match the file path '****.pom']Copy the code

Note that linking to JCenter is a once-only operation. If you make any changes to your package, such as uploading a new version of Binary, deleting an old version of binary, etc., these changes will also affect JCenter. After all, your own repository and JCenter are in a different location, so wait 2-3 minutes for JCenter to synchronize these changes.

Also note that if you decide to delete the entire package, the Library on the JCenter repository will not be deleted. They will exist like zombies, and no one will be able to delete them. So I suggest that if you want to delete the entire package, delete each version on the web page before removing the package.

The source address

Github.com/LiangMaYong…