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'
}
}
}
}
}