I have 2 gradle.build scripts, one for my app and one for my test. The app has a dependency on actionbarsherlock as follows:
dependencies {
compile project(':shared-jars')
compile ('com.actionbarsherlock:actionbarsherlock:4.4.0@aar') {
exclude module: 'support-v4'
}
}
and assembleRelease
works correctly.
However when doing a build, the test build doesn't compile because it can't find actionbarsherlock. For example:
14:27:52.847 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
14:27:54.240 [ERROR] [system.err] /Users/bradrhoads/Documents/src/estante/src/android/src/main/java/org/maf/estante/Discover.java:13: package com.actionbarsherlock.app does not exist
I've tried adding the same compile dependency in the test build as well as trying to depend on the app's transitive dependencies. But in eather case I get the not found error. Here's the entire test build script:
def props = new Properties()
file("../local.properties").withInputStream {
stream -> props.load(stream)
}
repositories {
mavenCentral()
maven {
url new File(props['sdk.dir'] + "/extras/android/m2repository/").toURI()
}
}
apply plugin: 'groovy'
dependencies {
compile "org.codehaus.groovy:groovy-all:1.8.6"
compile 'org.robospock:robospock:0.4.4'
compile 'cglib:cglib-nodep:3.1'
compile 'com.jakewharton:butterknife:4.0.1'
//compile fileTree(dir: ':android:libs', include: '*.jar')
compile project(":shared-jars")
compile ('com.actionbarsherlock:actionbarsherlock:4.4.0@aar') {
exclude module: 'support-v4'
}
compile (project(":estanteApp")) {
transitive = true
}
}
sourceSets.test.java.srcDirs = ['../android/src/main/java', '../android/build/source/r/debug']
test {
systemProperty 'ro.build.date.utc', '1'
systemProperty 'ro.kernel.qemu', '0'
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
testLogging {
lifecycle {
exceptionFormat "full"
}
}
workingDir = '../android/src/main'
}
tasks["test"].dependsOn project(":estanteApp").tasks["compileDebugJava"]