Skip to content

Commit

Permalink
Script gradle to push in Maven Central as aar
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielemariotti committed Sep 27, 2013
1 parent b5c3203 commit a1a85e2
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}

def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}

allprojects {
version = VERSION_NAME
group = GROUP

repositories {
mavenCentral()
}
}

apply plugin: 'android-reporting'
2 changes: 2 additions & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
}

Expand Down
14 changes: 14 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
VERSION_NAME=0.2.1-SNAPSHOT
VERSION_CODE=5
GROUP=com.github.gabrielemariotti.cards

POM_DESCRIPTION=Android Library to build a UI Card
POM_URL=https://github.com/gabrielemariotti/cardslib
POM_SCM_URL=https://github.com/gabrielemariotti/cardslib
POM_SCM_CONNECTION=scm:[email protected]:gabrielemariotti/cardslib.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:gabrielemariotti/cardslib.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=gabrielemariotti
POM_DEVELOPER_NAME=Gabriele Mariotti
4 changes: 4 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
}

dependencies {
}

apply from: '../maven_push.gradle'
3 changes: 3 additions & 0 deletions library/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=Card Library
POM_ARTIFACT_ID=library
POM_PACKAGING=aar
82 changes: 82 additions & 0 deletions maven_push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apply plugin: 'maven'
apply plugin: 'signing'

def sonatypeRepositoryUrl
if (isReleaseBuild()) {
println 'RELEASE BUILD'
sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
println 'DEBUG BUILD'
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.artifactId = POM_ARTIFACT_ID

repository(url: sonatypeRepositoryUrl) {
authentication(userName: nexusUsername, password: nexusPassword)
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.allJava
}

task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
//basename = artifact_id
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
//basename = artifact_id
from android.sourceSets.main.allSource
}

artifacts {
//archives packageReleaseJar
archives androidSourcesJar
archives androidJavadocsJar
}
}

0 comments on commit a1a85e2

Please sign in to comment.