Skip to content

Instantly share code, notes, and snippets.

@sh1nj1
Last active August 29, 2015 14:09
Show Gist options
  • Save sh1nj1/5c12f2390a9180be4949 to your computer and use it in GitHub Desktop.
Save sh1nj1/5c12f2390a9180be4949 to your computer and use it in GitHub Desktop.
/*
Usage: define 4 variables. and apply this file as below in build.gradle.
archivesBaseName = 'doblist'
group = 'doblist'
version = '1.0.0-SNAPSHOT'
System.properties.repoUrl = 'http://REPOSITORY_URL'
apply from: 'https://gist.githubusercontent.com/sh1nj1/5c12f2390a9180be4949/raw/9b5711490bc0526ac2bfc3df5aa4a0343e722b52/upload-archives.gradle'
gradle uploadArchives
*/
apply plugin: 'maven'
apply plugin: 'signing'
def repoUrl = System.properties['repoUrl'] == null ? 'http://dev1' : System.properties['repoUrl']
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
task apklib(type: Zip) {
dependsOn 'packageReleaseJar'
appendix = extension = 'apklib'
from 'AndroidManifest.xml'
into('res') {
from 'res'
}
into('src') {
from 'src'
}
}
configurations {
archives {
extendsFrom configurations.default
}
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: repoUrl + '/nexus/content/repositories/releases/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: repoUrl + '/nexus/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
/* XXX : if I added this line it will break dependencies in generated pom!
SEE: https://code.google.com/p/android/issues/detail?id=67110
modifyPom(addFilter('aar') { artifact, file ->
artifact.name == archivesBaseName
})
// FIXME I can't upload apklib I don't know even if I declare "archives { apklib }".
modifyPom(addFilter('apklib') { artifact, file ->
artifact.name == archivesBaseName + '-apklib'
})
*/
}
}
}
def modifyPom(pom) {
pom.project {
name archivesBaseName
description ''
url 'https://github.com/sh1nj1/'+archivesBaseName
scm {
url 'scm:git@github.com/sh1nj1/'+archivesBaseName+'.git'
connection 'scm:git@github.com/sh1nj1/'+archivesBaseName+'.git'
developerConnection 'scm:git@github.com/sh1nj1/'+archivesBaseName+'.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment