Skip to content

Commit

Permalink
Convert build to Gradle.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Feb 4, 2017
1 parent 461fd94 commit cf3279c
Show file tree
Hide file tree
Showing 23 changed files with 553 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 uploadArchives
echo "Snapshot deployed!"
fi
9 changes: 0 additions & 9 deletions .buildscript/settings.xml

This file was deleted.

27 changes: 4 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
# Eclipse
.classpath
.project
.settings
.metadata
eclipsebin

# Ant
bin
gen
# Gradle
.gradle
build
out
lib

# Maven
target
pom.xml.*
release.properties
reports
local.properties

# IntelliJ
.idea
*.iml
*.iws
*.ipr
classes
gen-external-apklibs

.DS_Store
26 changes: 18 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
language: android

android:
components:
- build-tools-20.0.0
- android-16

jdk:
- oraclejdk8

before_install:
- echo y | android update sdk --no-ui --all --filter "tools"
- echo y | android update sdk --no-ui --all --filter "platform-tools"
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"

script:
- ./gradlew build --no-daemon

after_success:
- .buildscript/deploy_snapshot.sh

env:
global:
- secure: "GiRZ29ScIYHiKjsYAA6WG+q5O5UdaNl5lcT3EJRea4aFjnZ8ar0xEWkoFXyMNeKTcx/cq4Yi1cRrW7vMnUNhTOYLANKpEY+p2V9b9oK4FzYGj25h+LwoYpzcQr+RtdLciseyu7mSuAkiOR6Ijxy3whOtk/cR807+wcNe+KwR444="
- secure: "A8h+gO/vwQ+bkBoGopu6gJsAysVxL9o4NG1U43B+4rRMCSzwYX8PlVSPfhpuD+hTWgMucDujebNy9RXqpfdP6143W0m6qC2Y0MB5zgnT+3LjGRRctqkSAF42T2kGyXMldCDEYukn3wvJw6/6BlnNkacDfA4KK8RI8DOwa6zJ0Es="
- secure: "YpBKpOdLkn4kcnzTUcOdupPV8zEDpUGLGkY5Z9mAtnZibOWnX+6MuQExkmi4Bd+uAHPB6QKP4AELiGv9udjE1UMtVUwZpb0hZ5XTo+kV4mOEvIS6FJAXwEqelyuqrtjo/QqnlWHmA579y2UBqFLzv1coiapKTNz3kwbUd9oMCr4="
- secure: "fAdMvu5VpVXEelBwGcIMMLg7zTol2DDrU7e+XKP8NTJYw0A7HOdDl5KB3uP2Lgb8lGMEIJ3Xin5AQNxuBmyQ4zP43Xjixs/rW/LqNdctvY8RmuI6PFJKm0QGsDni62iOKqqf681tjB3tDmRymEU14WQ5y81GGwDQ8GmqmI4U7h4="

branches:
except:
Expand All @@ -25,6 +29,12 @@ notifications:

sudo: false

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
buildscript {
ext.versions = [
'minSdk': 9,
'compileSdk': 25,
'buildTools': '25.0.2',
]

ext.deps = [
'gson': 'com.google.code.gson:gson:2.8.0',
'jcommander': 'com.beust:jcommander:1.35',
'commonsLang3': 'org.apache.commons:commons-lang3:3.3.1',
'commonsIo': 'commons-io:commons-io:2.5',
'ddmlib': 'com.android.tools.ddms:ddmlib:25.2.0',
'animatedGifLib': 'com.madgag:animated-gif-lib:1.2',
'guava': 'com.google.guava:guava:21.0',
'lesscss': 'org.lesscss:lesscss:1.3.3',
'mustache': 'com.github.spullara.mustache.java:compiler:0.8.14',
'jacocoMavenPlugin': 'org.jacoco:jacoco-maven-plugin:0.7.6.201602180812',

'junit': 'junit:junit:4.12',
'fest': 'org.easytesting:fest-assert-core:2.0M10',
'mockito': 'org.mockito:mockito-core:1.10.8',
]

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}

repositories {
jcenter()
}
}

subprojects { project ->
group = GROUP
version = VERSION_NAME

repositories {
jcenter()
}

apply plugin: 'checkstyle'
tasks.withType(Checkstyle) {
configFile rootProject.file('checkstyle.xml')
exclude 'com/squareup/spoon/axmlparser/**'
exclude '**/*Test*' // TODO fix problems and remove
}
}
2 changes: 0 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
</module>

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

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--module name="JavadocMethod"/-->
Expand Down
16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GROUP=com.squareup.spoon
VERSION_NAME=2.0.0-SNAPSHOT

POM_DESCRIPTION=Distributing instrumentation tests to all your Androids

POM_URL=http://github.com/square/spoon/
POM_SCM_URL=http://github.com/square/spoon/
POM_SCM_CONNECTION=scm:git:git://github.com/square/spoon.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/square/spoon.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-oss
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 Jan 03 15:02:23 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Loading

0 comments on commit cf3279c

Please sign in to comment.