Skip to content

Commit

Permalink
maven publish configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Satya Narayan committed Jul 6, 2015
1 parent ebdcb3c commit 2a3e292
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 25 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.1.1'
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1'
}
}

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

allprojects {
version = VERSION_NAME
group = GROUP

repositories {
mavenLocal()
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ android {

dependencies {
compile project (':library')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:support-v4:22.2.0'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'junit:junit:4.12'
}

robolectric {
// Configure includes / excludes
include '**/*Test.class'
include '**/*Tests.class'
exclude '**/espresso/**/*.class'

// Configure max heap size of the test JVM
Expand Down
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.4
VERSION_CODE=1
GROUP=com.github.satyan

POM_DESCRIPTION=Sugar ORM - Insanely easy way to work with android database
POM_URL=https://github.com/satyan/sugar
POM_SCM_URL=https://github.com/satyan/sugar
POM_SCM_CONNECTION=scm:[email protected]:satyan/sugar.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:satyan/sugar.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=satyan
POM_DEVELOPER_NAME=Satya Narayan
24 changes: 2 additions & 22 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

group 'com.github.satyan'
version '1.3.1'
apply from: '../maven_push.gradle'

android {
compileSdkVersion 21
Expand All @@ -21,7 +18,7 @@ android {
}

dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.12'
}
Expand All @@ -33,20 +30,3 @@ task libraryJar(type: Jar) {
baseName 'sugar'
}

publishing {
publications {
artifactJar(MavenPublication) {
artifact libraryJar
artifactId 'sugar'
groupId project.group
}
artifactAar(MavenPublication) {
artifact bundleRelease
artifactId 'sugar'
groupId project.group
}
}
repositories {
mavenCentral()
}
}
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=Sugar ORM
POM_ARTIFACT_ID=sugar
POM_PACKAGING=aar
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 2a3e292

Please sign in to comment.