Tuesday, January 7, 2014

Install Android Library on maven with gradle

If we need to hide the password or any other confidential information, we can move the info into gradle global properties. To do so, we put the info in the file at $GRADLE_HOME/gradle.properties. If it doesn't exist just create a new one.

Here is the content of file %GRADLE_HOME/gradle.properties.



The we refer the info in the build.gradle file. Here is the gradle build file I used to install slidingmenu library.

buildscript {
    repositories {
  maven {
            url 'http://localhost:8081/nexus/content/repositories/central/'
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
apply plugin: 'android-library'

repositories {
    maven {
        url 'http://localhost:8081/nexus/content/repositories/central/'

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

android {
    compileSdkVersion 19
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19

    sourceSets {
        main {
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']

            manifest.srcFile 'AndroidManifest.xml'


apply plugin: 'maven'
apply plugin: 'signing'
version = "1.3-release"
group = "com.jeremyfeinstein"
configurations {
    archives {
        extendsFrom configurations.default

//Singing the library for release version.
signing {
    required { version.contains("release") && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives

uploadArchives {
    configuration = configurations.archives
    repositories.mavenDeployer {
        beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

//nexusReleaseRepo, nexusUsername and nexusPassword are defined in gradle global properties which are stored in $GRADLE_HOME/gradle.properties.
        repository(url: nexusReleaseRepo) {
            authentication(userName: nexusUsername, password: nexusPassword)

        pom.project {
            name 'Android SlidingMenu Library'
            packaging 'aar'
            description 'Sliding menu library for Android applications'
            url 'https://github.com/jfeinstein10/SlidingMenu'

 //           scm {
 //               url 'scm:git@github.com:VandalSoftware/android-cache-lib.git'
 //               connection 'scm:git@github.com:VandalSoftware/android-cache-lib.git'
 //               developerConnection 'scm:git@github.com:VandalSoftware/android-cache-lib.git'
 //           }

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

            developers {
                developer {
                    id 'jfeinstein10'
                    name 'Jeremy Feinstein'
                    email 'jfeinstein10@gmail.com'


  1. At this time, it seems like Word Press is the preferred blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog? Great post, however, I was wondering if you could write a little more on this subject?
    Best AWS Training in Marathahalli | AWS Training in Marathahalli
    Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai

  2. This comment has been removed by the author.


  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.

    angularjs-Training in velachery

    angularjs-Training in annanagar

    angularjs Training in chennai

    angularjs Training in chennai

  4. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    advanced excel training in bangalore

  5. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    blueprism training in chennai | blueprism training in bangalore | blueprism training in pune | blueprism online training

  6. I would assume that we use more than the eyes to gauge a person's feelings. Mouth. Body language. Even voice. You could at least have given us a face in this test.

    Java training in Chennai | Java training in Bangalore

    Java online training | Java training in Pune

  7. Very good brief and this post helped me alot. Say thank you I searching for your facts. Thanks for sharing with us!

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

  8. Pleasant Tips..Thanks for Sharing….We keep up hands on approach at work and in the workplace, keeping our business pragmatic, which recommends we can help you with your tree clearing and pruning in an invaluable and fit way.
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training