Skip to content

Instantly share code, notes, and snippets.

@gmarques33
Created April 8, 2014 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmarques33/10091861 to your computer and use it in GitHub Desktop.
Save gmarques33/10091861 to your computer and use it in GitHub Desktop.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.+'
}
}
apply plugin: 'android'
apply plugin: 'idea'
repositories {
maven {
url "my_nexus_repo"
}
}
configurations {
// apt configuration
apt
// these are needed because simple-xml has transitive dependencies on them, but they're already
// part of the Android framework.
compile.exclude group: 'stax'
compile.exclude group: 'xpp3'
// robolectric configuration
robolectric {
extendsFrom compile
}
robolectric.exclude group:'stax'
robolectric.exclude group:'xpp3'
}
sourceSets {
robolectric {
java.srcDir file('src/test/java')
resources.srcDir file('src/test/resources')
compileClasspath += configurations.robolectric
runtimeClasspath += compileClasspath
}
}
// version numbers for all out dependencies
ext.daggerVersion = '1.0.1'
ext.butterknifeVersion = '1.4.0'
ext.ksoap2Version = '3.0.0'
ext.ormliteVersion = '4.45'
ext.picassoVersion = '1.1.1'
ext.eventbusVersion = '2.0.2'
ext.simpleVersion = '2.7'
ext.playservicesVersion = '3.1.36'
ext.supportVersion = '13.0.0'
ext.lombokVersion = '0.11.8'
ext.hockeyappVersion = '2.2.1'
// Unit Testing Dependencies
ext.robolectricVersion = "2.1.1"
ext.junitVersion = "4.11"
ext.androidVersion = "4.1.1.4"
ext.festandroidVersion = '1.0.5'
// add dependencies to the build
dependencies {
// Android Support Library
compile "com.android.support:support-v4:${supportVersion}"
// Google Play Services
compile "com.google.android.gms:play-services:${playservicesVersion}"
// Dagger - IOC
compile "com.squareup.dagger:dagger:${daggerVersion}"
// ButterKnife - view injection
compile "com.jakewharton:butterknife:${butterknifeVersion}"
// XML (de)serialization lib.
compile "org.simpleframework:simple-xml:${simpleVersion}"
// ORM
compile "com.j256.ormlite:ormlite-android:${ormliteVersion}"
// Picasso - image loading library
compile "com.squareup.picasso:picasso:${picassoVersion}"
// EventBus
compile "de.greenrobot:eventbus:${eventbusVersion}"
// SOAP client
// for some reason I couldn't get this to work via nexus/repo.
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
// now... why isn't this actually *IN* maven central, instead of making me generate it?
compile files('libs/lombok-api.jar')
// HockeyApp
compile "net.hockeyapp.android:HockeySDK:${hockeyappVersion}"
// robolectric needs it's own copy of the android jars.
robolectricCompile "com.google.android:android:${androidVersion}"
// testing stuff
robolectricCompile "junit:junit:${junitVersion}"
robolectricCompile "org.robolectric:robolectric:${robolectricVersion}"
robolectricCompile "com.squareup:fest-android:${festandroidVersion}"
// Compile time code generation for dagger & project lombok
apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"
apt "org.projectlombok:lombok:${lombokVersion}"
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
}
android.applicationVariants.each { variant ->
aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}
}
task robolectric(type: Test, dependsOn: assemble) {
workingDir = 'src/main'
testClassesDir = sourceSets.robolectric.output.classesDir
android.sourceSets.main.java.srcDirs.each { dir ->
def buildDir = dir.getAbsolutePath().split('/')
buildDir = (buildDir[0..(buildDir.length - 4)] + ['build', 'classes', 'debug']).join('/')
sourceSets.robolectric.compileClasspath += files(buildDir)
sourceSets.robolectric.runtimeClasspath += files(buildDir)
}
classpath = sourceSets.robolectric.runtimeClasspath
}
check.dependsOn robolectric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment