Skip to content

Commit

Permalink
enable publishing AAR file to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Granatiero committed Feb 5, 2015
1 parent 0a7407f commit 1a2d023
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .idea/libraries/appcompat_v7_21_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/libraries/support_v4_21_0_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CoverFlow.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.moondroid.coverflow" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="CoverFlow" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.moondroid.coverflow" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ buildscript {
}
}

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

allprojects {

version = VERSION_NAME
group = GROUP

repositories {
jcenter()
}
}

apply plugin: 'android-reporting'
33 changes: 33 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=1.0
VERSION_CODE=1
GROUP=com.github.moondroid.coverflow

POM_DESCRIPTION=Android CoverFlow widget
POM_URL=https://github.com/moondroid/CoverFlow
POM_SCM_URL=https://github.com/moondroid/CoverFlow
POM_SCM_CONNECTION=scm:git@github.com:moondroid/CoverFlow.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:moondroid/CoverFlow.git
POM_LICENCE_NAME=The MIT License (MIT)
POM_LICENCE_URL=http://opensource.org/licenses/mit-license.php
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=moondroid
POM_DEVELOPER_NAME=Marco Granatiero
2 changes: 2 additions & 0 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

apply from: '../maven_push.gradle'
3 changes: 3 additions & 0 deletions lib/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=CoverFlow Library
POM_ARTIFACT_ID=library
POM_PACKAGING=aar
2 changes: 1 addition & 1 deletion lib/lib.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="CoverFlow" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.moondroid.coverflow" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
92 changes: 92 additions & 0 deletions maven_push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apply plugin: 'maven'
apply plugin: 'signing'

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

def getRepositoryUsername() {
return hasProperty('nexusUsername') ? nexusUsername : ""
}

def getRepositoryPassword() {
return hasProperty('nexusPassword') ? nexusPassword : ""
}

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

pom.artifactId = POM_ARTIFACT_ID

repository(url: sonatypeRepositoryUrl) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

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.java.sourceFiles
}

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.java.sourceFiles
}

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

0 comments on commit 1a2d023

Please sign in to comment.