I've introduced a dependency for my unit tests to a custom task I've written in gradle. In android-gradle v1.2.3 the unit test task is named test
. So I assumed you add a dependency with test.dependsOn
. Gradle doesn't like that.
Error:
C:\coding\source\testapp\app\build.gradle
Error:(30, 0) Could not find property 'test' on project ':app'.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.nilzor.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
task myTask() {
}
test.dependsOn 'mytask'
Where do I go wrong and how do I fix it?
Solution: Wrap it in
afterEvaluate {
test.dependsOn 'mytask'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With