如何将传递依赖 [英] How To Include Transitive Dependencies
问题描述
我有2个项目的gradle:一个Android应用程序和RoboSpock测试
I have 2 gradle projects: an Android app and a RoboSpock test.
我对Android应用的build.gradle有
My build.gradle for the Android app has
. . .
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile ('com.actionbarsherlock:actionbarsherlock:4.4.0@aar') {
exclude module: 'support-v4'
}
}
. . .
和自行建立正确的,例如assembleRelease工作。
and builds correctly by itself, e.g assembleRelease works.
我坚持让测试工作。我得到很多错误的,如:
I'm stuck getting the test to work. I gets lots of errors such as:
package com.google.zxing does not exist
那些似乎表明.jar文件不被拾取。
Those seem to indicate that the .jar files aren't being picked up.
下面是我的测试项目的build.gradle:
Here's my build.gradle for the test project:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'org.robospock:robospock-plugin:0.4.0'
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'groovy'
dependencies {
compile "org.codehaus.groovy:groovy-all:1.8.6"
compile 'org.robospock:robospock:0.4.4'
}
dependencies {
compile fileTree(dir: ':android:libs', include: '*.jar')
compile (project(':estanteApp')) {
transitive = true
}
}
sourceSets.test.java.srcDirs = ['../android/src/', '../android/build/source/r/debug']
test {
testLogging {
lifecycle {
exceptionFormat "full"
}
}
}
project.ext {
robospock = ":estanteApp" // project to test
}
apply plugin: 'robospock'
由于显示,我试着将传递= TRUE,并明确包括.jar文件。但无论我怎么努力,我结束了与包不存在错误。
As that shows, I've tried adding transitive = true and including the .jar files explicitly. But no matter what I try, I end up with the package does not exist error.
推荐答案
在Android Studio中,你不再需要测试不同的项目。把你的测试code在同一个模块下的SRC / androidTest / JAVA
In Android Studio you no longer need a different project for testing. Put your testing code in the same module under "src/androidTest/java"
然后在defaultConfig
Then add the following to "build.gradle" in the "defaultConfig"
testPackageName "com.yourpackage.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testFunctionalTest true
这篇关于如何将传递依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!