1

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"]
Brad Rhoads
  • 1,828
  • 3
  • 29
  • 52

1 Answers1

2

Groovy plugin doesn't understand the aar dependency. Currently only android* plugins can evaluate such dependencies.

You could try first to assemble the Android project and link to build/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/classes.jar but I'm not sure how robolectric will act with resources from aar lib.

Rudy Rudolf
  • 227
  • 2
  • 3