Code Monkey home page Code Monkey logo

uploadtomavencentral's Introduction

Android Library: Publish to MavenCentral

Show some ❤️

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

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

Blog Post : Guide to publishing your Android Library via MavenCentral

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.

  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.

    • Goto File>Project Structure..
    • Select app module in the sidebar
    • Select the Dependencies tab
    • At the bottom is a + icon, click that and select Module dependency and select your library module.
    • Press apply or ok.
  6. Add the plugin by Chris Banes to your library's build.gradle file at the end

    NOTE: Below is a fork of the original script written by Chris Banes.

    apply from: 'https://raw.github.com/nisrulz/gradle-mvn-push/master/gradle-mvn-push.gradle'

    and define the required variables in the gradle.properties.

    # Properties used by gradle maven-push plugin
    
    # Library info
    GROUP=<group_name>
    VERSION_NAME=1.0.0
    VERSION_CODE=1
    
    # POM info
    POM_NAME=<Library_Name>
    POM_ARTIFACT_ID=<library_name_smallcaps>
    POM_DESCRIPTION=<library_description>
    POM_URL=https://github.com/<username>/<repo_name>
    POM_SCM_URL=https://github.com/<username>/<repo_name>
    POM_SCM_CONNECTION=scm:[email protected]:<username>/<repo_name>.git
    POM_SCM_DEV_CONNECTION=scm:[email protected]:<username>/<repo_name>.git
    
    
  7. Setup GPG and generate yourself a key.

    • Now list your gpg keys

      $ gpg --list-keys

      There the first line will be like pub XXXXX/YYYYYYYY . Remember that ‘YYYYYYYY’ part, it’s you key ID.

    • Next, publish your keys

      $ gpg --keyserver hkp://keyserver.ubuntu.com --send-keys YYYYYYYY
      $ gpg --keyserver hkp://pgp.mit.edu --send-keys YYYYYYYY
    • To ensure your keys were published

      $ gpg --keyserver hkp://pgp.mit.edu --search-keys 
      [email protected] # Use your email
  8. Setup Sonatype account

    • Create a JIRA account on Sonatype

    • Once you are logged in, create a new issue

    • Fill out the form as below

      Group Id : com.github.<github_username>
      Project URL : https://github.com/<github_username>/<project_name>
      SCM url : https://github.com/<github_username>/<project_name>.git
      Username : <sonatype_username>
      Already Synced to Central : No
      
    • Next hit submit. After you submit, it can take up to 2 business days to process your issue. Then you will receive a confirmation that your configuration has been prepared and you can publish your library.

      IMPORTANT : Do not deploy until after you have received an e-mail notice indicating that the ticket is Resolved.

    • Update the global gradle.properties on your local machine at location ~/.gradle/gradle.properties and include

        NEXUS_USERNAME=sonatype_username
        NEXUS_PASSWORD=sonatype_password
        signing.keyId=gpg_key_id 
        signing.password=gpg_password
        signing.secretKeyRingFile=/Users/username/.gnupg/secring.gpg
        org.gradle.daemon=true
      
  9. Run in terminal to publish your artifacts

    ./gradlew build clean uploadArchive
  10. Login into Nexus Repository Console and search for your package name.

  11. Close the staged artifact.[wait]

  12. Release the closed artifact (keep drop artifact selected).[wait]

  13. Wait for some hours before everything gets synced with MavenCentral.

  14. To use the published library you have do something like below

    dependencies {
        implementation 'com.github.nisrulz:awesomelib:1.0'
    }
  15. 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
    • 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 read

If you appreciate my work, consider buying me a cup of ☕ to keep me recharged 🤘 [PayPal]

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.

uploadtomavencentral's People

Contributors

nisrulz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

uploadtomavencentral's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.