1
我正在將Java庫遷移到Gradle,我遇到了下面定義的集成任務的一些問題。Gradle 4.0-milestone2上的集成測試
這個任務讓我有兩種不同的源目錄src/test
和src/integration
,並有獨立的gradle這個任務來運行它們,./gradlew test
和./gradlew integration
。
的build.gradle
apply plugin: 'java-library'
apply plugin: 'idea'
apply from: './integration.gradle'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
dependencies {
api 'com.github.ihsanbal:LoggingInterceptor:2.0.0'
api 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
api 'com.squareup.retrofit2:retrofit:2.0.2'
api 'com.squareup.retrofit2:converter-gson:2.0.2'
api 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
testImplementation 'junit:junit:4.12'
}
test {
testLogging.showStandardStreams = true
}
task copyTestResources(type: Copy) {
from sourceSets.test.resources
into sourceSets.test.output.classesDir
}
processTestResources.dependsOn copyTestResources
integration.gradle
sourceSets {
integration {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration/java')
}
resources.srcDir file('src/integration/resources')
}
}
configurations {
integrationCompile.extendsFrom testCompile
integrationRuntime.extendsFrom testRuntime
}
idea {
module {
testSourceDirs += file('src/integration/java')
scopes.TEST.plus += [configurations.integrationCompile]
}
}
task integration(type: Test) {
testClassesDir = sourceSets.integration.output.classesDir
classpath = sourceSets.integration.runtimeClasspath
}
integration.mustRunAfter test
內容內容有兩個問題與此配置。
1)copyTestResources
任務不起作用classesDir
已棄用且classesDirs
不兼容。
2)類路徑不包括庫依賴關係。 編譯失敗完全以下錯誤
error: cannot find symbol
error: package SOMETHING does not exist
關於如何解決這個問題的任何線索?謝謝