Uploading items to Jcenter using Gradle

Source: Internet
Author: User
Tags hasproperty jfrog jcenter

1. Register an account with https://bintray.com/

2.AndroidStudio Create a project, and then create a library in this project (File->new->new module->android Library)

3. Open the Gradle.properties file of the project root and copy the following to replace the value of the corresponding field

version_name=0.1.0GROUP=Com.zzb.libraryPOM_NAME=Jcenter testpom_artifact_id=commonpom_packaging=aar#, for example, we cite AppCompat .-V7, then it will be written compile ' com.android.support:appcompat-v7:22.2.0 '#实际对应的字段就是 Compile' GROUP:POM_ARTIFACT_ID:VERSION_NAME 'pom_description=Item Description # project address and so on, I'm using GitHub's project address Pom_url=https://github.com/baronz/android-common-libraryPom_scm_url=https://github.com/baronz/android-common-libraryPom_scm_connection=scm:git:git://Github.com/baronz/android-common-library.gitPOM_SCM_DEV_CONNECTION=SCM:GIT:SSH://[Email Protected]/baronz/android-common-library.git#开源协议POM_LICENCE_NAME=the Apache software License, Version 2.0Pom_licence_url=http://Www.apache.org/licenses/LICENSE-2.0.txtpom_licence_dist=repopom_developer_id=Zzbpom_developer_name=Zzbpom_developer_email=[Email Protected]pom_developer_url=http://Baronz.github.ioGit_url=https://Github.com/baronz/android-common-library.gitIssue_url=https://github.com/baronz/android-common-library/issues
View Code

4. Build.gradle,dependencies Add Reference under Project directory

dependencies {        classpath ' com.android.tools.build:gradle:1.2.3 '        classpath ' com.jfrog.bintray.gradle: gradle-bintray-plugin:1.2 '    }
View Code

5. Add file Gradle-jcenter-push.gradle to the Gradle directory under the project directory, as follows:

Apply plugin: ' Maven-publish 'Apply plugin:' Com.jfrog.bintray 'Publishing {publications {Mavenjava (mavenpublication) {groupId GROUP version Versio N_name Artifactid pom_artifact_id ARTIFACT"${project.builddir}/outputs/aar/${project.name}-release.aar"artifact Androidjavadocsjar artifact Androidsourcesjar pom.withxml { Node Root=Asnode () Root.appendnode (' Name ', pom_artifact_id) Root.appendnode (' Description ', Pom_description) Root.appendnode (' URL ', Pom_url) def issues= Root.appendnode (' issuemanagement ') Issues.appendnode (' System ', ' GitHub ') Issues.appendnode (' URL ', Issue_url) def SCM= Root.appendnode (' SCM ') Scm.appendnode (' URL ', Pom_scm_url) Scm.appendnode (' Connection ', Pom_scm_connection) Scm.appendnode (' Developerconnection ', pom_scm_dev_connection) def license= Root.appendnode (' licenses '). Appendnode (' license ')) License.appendnode (' Name ', Pom_licence_name) License.appendnode (' URL ', Pom_licence_url) License.appendnode (' Distribution ', Pom_licence_dist)} }}}def Getbintrayuserproperty () {returnHasproperty (' Bintray_user ')? Bintray_user: ""}def Getbintrayapikeyproperty () {returnHasproperty (' Bintray_apikey ')? Bintray_apikey: ""}//Gradle bintrayuploadBintray {User=getbintrayuserproperty () key=Getbintrayapikeyproperty () Publications= [' Mavenjava '] Dryrun=falsePublish=truepkg {repo= ' maven 'name=pom_artifact_id desc=pom_name Websiteurl=Pom_url Issuetrackerurl=Issue_url Vcsurl=Git_url Licenses= [' Apache-2.0 '] Labels= [' Android ', ' AAR '] Publicdownloadnumbers=trueVersion {name=version_name Vcstag=version_name} }}
View Code

6. Add file Android-artifacts.gradle to the Gradle directory under the project directory, as follows:

task Androidjavadocs (type:javadoc) {    = android.sourceSets.main.java.srcDirs    + = Project.files (Android.getbootclasspath (). Join (File.pathseparator))}task Androidjavadocsjar (Type:jar, DependsOn: Androidjavadocs) {    = ' Javadoc ' from    androidjavadocs.destinationdir}task Androidsourcesjar (type: Jar) {    = ' sources ' from    android.sourceSets.main.java.sourceFiles}
View Code

7. Add the following two lines of script to the bottom of the Build.gradle in the library directory

Apply From:rootProject.file (' gradle/android-artifacts.gradle ') apply From:rootProject.file (' gradle/ Gradle-jcenter-push.gradle ')
View Code

8. Login bintray.com Create Maven Library

    • Click Maven
    • Click on the Add New package
    • Fill in the appropriate information, then click Create Package
    • Back to Bintray home page, click Edit
    • Click API Key
    • Click Show, make a note of your API Key, etc.

9. Locate the gradle.properties under your home directory (the directory under Windows is C:\Users\ your computer name \.gradle), add the following current script

bintray_user= your bintray.com username Bintray_apikey= The API Key that you noted in the previous step
View Code

10. OK, knock down the command below and wait for the upload to succeed,cmd-> into your project directory (note, execute the following command, make sure environment variables are set, PATH has gradle/bin, java_home environment variable)

Gradle Clean Build Bintrayupload

If you see the execution results below, then congratulations, wait for the audit to be able to quote

Uploading items to Jcenter using Gradle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.