behdad222 / UploadToBintray

[Example] Awesome library built to demonstrate the process of publishing android libraries via JCenter/Bintray

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upload to JCenter/Bintray

Specs

Download

Show some ❤️

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

Base repository to demonstrate the process of uploading an aar/jar to JCenter/Bintray.

Blog Post : Guide to publishing your Android Library via Jcenter/Bintray

The process is as follows

  1. Create an Android project or open an existing one in Android Studio

  2. Init the project with git and also create a repo on Github for the same. Each step here onwards represent a commit and should be pushed to github.

  3. Create and add a new module and choose Android Library.

    Goto File>New>New Module.. and select Android Library.

    newmodule

    newlib

    newlibinfo

  4. Implement your library code inside the library module you created in the last step.

  5. Next add the library module as a dependency to the app module.

    1. Goto File>Project Structure..
    2. Select app module in the sidebar
    3. Select the Dependencies tab
    4. At the bottom is a + icon, click that and select Module dependency and select your library module.
    5. Press apply or ok.

    project

    prjstruct

    addmodule

  6. Once project is synced, add the required plugins to classpath in build.gradle file at root project level, as shown below

 dependencies {
    classpath 'com.android.tools.build:gradle:2.1.3'
    ..
    ..
    // Required plugins added to classpath to facilitate pushing to Jcenter/Bintray
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
    ..
  1. Next, apply the bintray and install plugins at the bottom of build.gradle file at library module level. Also add the ext variable with required information as shown below
 apply plugin: 'com.android.library'
 
 ext {
   bintrayRepo = 'maven'
   bintrayName = 'awesomelib'   // Has to be same as your library module name
 
   publishedGroupId = 'com.github.nisrulz'
   libraryName = 'AwesomeLib'
   artifact = 'awesomelib'     // Has to be same as your library module name
 
   libraryDescription = 'Android Library to make any text into Toast with Awesome prepended to the text'
 
   // Your github repo link
   siteUrl = 'https://github.com/nisrulz/UploadToBintray'
   gitUrl = 'https://github.com/nisrulz/UploadToBintray.git'
   githubRepository= 'nisrulz/UploadToBintray'
 
   libraryVersion = '1.0'
 
   developerId = 'nisrulz'
   developerName = 'Nishant Srivastava'
   developerEmail = 'nisrulz@gmail.com'
 
   licenseName = 'The Apache Software License, Version 2.0'
   licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
   allLicenses = ["Apache-2.0"]
 }
 
 ..
 ..
 
 // Place it at the end of the file
 apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/installv1.gradle'
 apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/bintrayv1.gradle'
 
  1. Edit your local.properties
bintray.user=<your_bintray_username>
bintray.apikey=<your_bintray_apikey>
  1. Now lets setup Bintray before we can push our artifact to it.
  • Register for an account on bintray.com and click the activation email they send you.

  • Add a new Maven repository and click Create New Package

  • You should now have a maven repository. For instance: https://bintray.com/nisrulz/maven

  • Now once you have your maven repo setup , click on Edit

    edit

    and see that you have selected the option GPG sign uploaded files using Bintray's public/private key pair. and then click Update.

    gpg

  1. Once everything is configured, run the below in your terminal in your root of the project
./gradlew clean build install bintrayUpload
  1. Now once your project is up on bintray, simply hit Add to Jcenter button to sync with JCenter.

addtojcenter

  1. Your code is available
  • through the private repo at bintray

    repositories { 
       jcenter()
       maven { url 'https://dl.bintray.com/<bintray_username>/maven' }
    }
    dependencies {
      compile 'com.github.<bintray_username>:<library_module>:1.0'
    }

    i.e for the sample lib in this repo , awesomelib

    repositories { 
       jcenter()
       maven { url 'https://dl.bintray.com/nisrulz/maven' }
    }
    dependencies {
      compile 'com.github.nisrulz:awesomelib:1.0'
    }
  • through JCenter if you have received the mail with confirmation

    finalmail

    Few things to note when you received the final email.

    • Goto your maven repo at bintray and verify that you have Jcenter under the Linked to section

      linked

    • Now you would also want to sync the artifact to MavenCentral, for that you need to hit the Maven Central tab and sync

      synctomaven

    • Once you hit sync you would see as below. Wait for few hours for the sync to occur.

      syncstatus

    You can use the lib now as follows

    dependencies {
        compile 'com.github.<bintray_username>:<library_module>:1.0'
      }

    i.e for the sample lib in this repo , awesomelib

    dependencies {
          compile 'com.github.nisrulz:awesomelib:1.0'
      }
  1. Let the world know of your AwesomeLib 😄
  • Add a readme that explains how to integrate and use your Awesome library

  • Add a license block as in this repo

  • Also include the Bintray badge provided by Bintray in your readme

    badge

  • Promote your lib on social media so that others can know about it.

  • Always add a working sample app in your project that demonstrates your library in use.

  • Add screenshots if possible in your readme.

If you found this example helpful or you learned something today and want to thank me, consider buying me a cup of ☕

  • PayPal
  • Bitcoin Address: 13PjuJcfVW2Ad81fawqwLtku4bZLv1AxCL

License

Copyright 2016 Nishant Srivastava

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

[Example] Awesome library built to demonstrate the process of publishing android libraries via JCenter/Bintray

License:Apache License 2.0


Languages

Language:Java 100.0%