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.

signing.keyId=1C5E1752
signing.password=topsecret
signing.secretKeyRingFile=C:/Users/xxx/AppData/Roaming/gnupg/secring.gpg

artifactoryAndroidDev=http://artifactory.dev.cba/artifactory/android-dev/
artifactoryUsername=xxx
artifactoryPassword=topsecret
nexusSnapshotRepo=http://localhost:8081/nexus/content/repositories/snapshots/
nexusReleaseRepo=http://localhost:8081/nexus/content/repositories/releases/
nexusUsername=admin
nexusPassword=xxx

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

buildscript {
    repositories {
        mavenCentral()
  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'
                }
            }
        }
    }
}

10 comments:

  1. This comment has been removed by the author.

    ReplyDelete


  2. 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

    ReplyDelete
  3. 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

    ReplyDelete
  4. 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

    ReplyDelete
  5. 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

    ReplyDelete
  6. 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

    ReplyDelete
  7. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. The angular js programming language is very popular which are most widely used.


    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery





    ReplyDelete