Skip to content

Commit

Permalink
Updated build (both Travis and Gradle configuration)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarek committed May 3, 2014
1 parent e83f35d commit d474673
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 63 deletions.
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
branches:
only:
- master
language:
- java
jdk:
Expand All @@ -16,15 +13,15 @@ before_install:
# for gradle output style
- export TERM=dumb
# newer version of gradle
- wget http://services.gradle.org/distributions/gradle-1.11-bin.zip
- unzip -qq gradle-1.11-bin.zip
- export GRADLE_HOME=$PWD/gradle-1.11
- wget http://services.gradle.org/distributions/gradle-1.12-bin.zip
- unzip -qq gradle-1.12-bin.zip
- export GRADLE_HOME=$PWD/gradle-1.12
- export PATH=$GRADLE_HOME/bin:$PATH
# just to test gradle version, against our provided one
- gradle -v
# newest android SDK 22.6.1
- wget http://dl.google.com/android/android-sdk_r22.6.1-linux.tgz
- tar -zxf android-sdk_r22.6.1-linux.tgz
# newest android SDK 22.6.3
- wget http://dl.google.com/android/android-sdk_r22.6.3-linux.tgz
- tar -zxf android-sdk_r22.6.3-linux.tgz
- export ANDROID_HOME=`pwd`/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
# manually set sdk.dir variable, according to local paths
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ POM_SCM_DEV_CONNECTION=scm:[email protected]:loopj/android-async-http.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=jamessmith
POM_DEVELOPER_NAME=James Smith

22 changes: 0 additions & 22 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,4 @@ android {
}
}

android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def task = project.tasks.create "android${name.capitalize()}Jar", Jar
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
artifacts.add('archives', task);
}

android.libraryVariants.all { variant ->

task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
}

}

apply from: '../maven_push.gradle'
78 changes: 46 additions & 32 deletions maven_push.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'maven'
apply plugin: 'signing'

configurations {
archives {
extendsFrom configurations.default
}
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

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/"
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

if (ext.properties.containsKey('signing.keyId') && !ext.properties.containsKey('signing.password')) {
if (System.console())
ext.set('signing.password', System.console().readPassword("\n\$ Type in GPG key password: "))
else
ext.set('signing.password', 'dummy')
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

if (System.env.TERM != 'dumb' && !ext.properties.containsKey('nexusPassword')) {
if (System.console())
ext.set('nexusPassword', new String(System.console().readPassword("\n\$ Type in password for Sonatype nexus account ${nexusUsername}: ")))
else
ext.set('nexusPassword', 'dummy')
def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

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

afterEvaluate { project ->
Expand All @@ -36,10 +45,15 @@ afterEvaluate { project ->
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: sonatypeRepositoryUrl) {
authentication(userName: nexusUsername, password: nexusPassword)
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

pom.project {
Expand All @@ -64,12 +78,8 @@ afterEvaluate { project ->

developers {
developer {
id "loopj"
name "James Smith"
}
developer {
id "smarek"
name "Marek Sebera"
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
Expand All @@ -82,9 +92,14 @@ afterEvaluate { project ->
sign configurations.archives
}

task androidJavadocsJar(type: Jar, dependsOn: generateReleaseJavadoc) {
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.allJava
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from generateReleaseJavadoc.destinationDir
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
Expand All @@ -93,7 +108,6 @@ afterEvaluate { project ->
}

artifacts {
archives androidReleaseJar
archives androidSourcesJar
archives androidJavadocsJar
}
Expand Down

0 comments on commit d474673

Please sign in to comment.