Skip to content

Commit

Permalink
Switch to gradle and AAR
Browse files Browse the repository at this point in the history
This purposefully tries to limit the scope to just necessary changes. The android gradle plugin and build tools are updated, but the rest of the dependencies use the same as before. This configuration matches the ones used in sqldelight/rxbinding
  • Loading branch information
ZacSweers committed Jun 9, 2016
1 parent a4a5c63 commit bbe8e0a
Show file tree
Hide file tree
Showing 27 changed files with 742 additions and 392 deletions.
2 changes: 1 addition & 1 deletion .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
else
echo "Deploying snapshot..."
mvn clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -Dmaven.test.skip=true
./gradlew clean uploadArchives
echo "Snapshot deployed!"
fi
9 changes: 0 additions & 9 deletions .buildscript/settings.xml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ gen-external-apklibs
tmp

.DS_Store

# Gradle
.gradle
jniLibs
build
local.properties
reports
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ language: android

android:
components:
- build-tools-20.0.0
- android-17
licenses:
- android-sdk-license-5be876d5
- tools
- platform-tools
- build-tools-23.0.3
- extra-android-m2repository
- android-23

jdk:
- oraclejdk7
- oraclejdk8

script:
- ./gradlew clean check

after_success:
- .buildscript/deploy_snapshot.sh

Expand All @@ -30,4 +33,4 @@ sudo: false

cache:
directories:
- $HOME/.m2
- $HOME/.gradle
24 changes: 24 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Releasing
========

1. Change the version in `gradle.properties` to a non-SNAPSHOT version.
2. Update the `CHANGELOG.md` for the impending release.
3. Update the `README.md` with the new version.
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
6. `./gradlew clean uploadArchives`
7. Update the `gradle.properties` to the next SNAPSHOT version.
8. `git commit -am "Prepare next development version."`
9. `git push && git push --tags`
10. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact.

If step 6 or 7 fails, drop the Sonatype repo, fix the problem, commit, and start again at step 5.


Prerequisites
-------------

In `~/.gradle/gradle.properties`, set the following:

* `SONATYPE_NEXUS_USERNAME` - Sonatype username for releasing to `com.squareup`.
* `SONATYPE_NEXUS_PASSWORD` - Sonatype password for releasing to `com.squareup`.
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
subprojects {
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}

plugins.apply('checkstyle')

task('checkstyle', type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
source 'src/main/java'
ignoreFailures false
showViolations true
include '**/*.java'

classpath = files()
}

group = GROUP
version = VERSION_NAME

afterEvaluate {
tasks.findByName('check').dependsOn('checkstyle')
}
}

apply from: rootProject.file('dependencies.gradle')
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</module>

<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!--<property name="cacheFile" value="${checkstyle.cache.file}"/>-->

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
Expand Down
26 changes: 26 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ext {
compileSdkVersion = 23
buildToolsVersion = '23.0.3'
minSdkVersion = 14
targetSdkVersion = 23
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
okhttp3Version = '3.0.1'

dep = [
androidPlugin : 'com.android.tools.build:gradle:2.1.2',
okhttp : 'com.squareup.okhttp:okhttp:2.7.1',
okhttp3 : "com.squareup.okhttp3:okhttp:$okhttp3Version",
mockWebServer : "com.squareup.okhttp3:mockwebserver:$okhttp3Version",
intellijAnnotations: 'com.intellij:annotations:12.0',
pollexor : 'com.squareup:pollexor:2.0.0',
supportV4 : 'com.android.support:support-v4:23.4.0',
junit : 'junit:junit:4.10',
fest : 'org.easytesting:fest-assert-core:2.0M10',
festAndroid : 'com.squareup:fest-android:1.0.6',
robolectric : 'org.robolectric:robolectric:2.2',
mockito : 'org.mockito:mockito-core:1.9.5'
]

isCi = "true".equals(System.getenv('CI'))
}
14 changes: 14 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
GROUP=com.squareup.picasso
VERSION_NAME=2.6.0-SNAPSHOT

POM_URL=https://github.com/square/picasso/
POM_SCM_URL=https://github.com/square/picasso/
POM_SCM_CONNECTION=scm:git:git://github.com/square/picasso.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/square/picasso.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=square
POM_DEVELOPER_NAME=Square, Inc.
218 changes: 218 additions & 0 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
/*
* 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'

version = VERSION_NAME
group = GROUP

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

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL :
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL :
"https://oss.sonatype.org/content/repositories/snapshots/"
}

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

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

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

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

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
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
}

if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
task install(type: Upload, dependsOn: assemble) {
repositories.mavenInstaller {
configuration = configurations.archives

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

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
}
}
}
}
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

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

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}
} else {
install {
repositories.mavenInstaller {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

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
}
}
}
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

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

if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}

artifacts {
if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
archives androidSourcesJar
archives androidJavadocsJar
} else {
archives sourcesJar
archives javadocJar
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Tue Oct 20 20:22:56 EDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
Loading

0 comments on commit bbe8e0a

Please sign in to comment.