Issue
I've provided
dependency scope configured like below. My problem is, the provided dependencies are not visible during runtime in tests. How can I configure this to keep the dependencies provided
but available on the test classpath?
apply plugin: 'java'
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
dependencies {
provided 'com.google.guava:guava:18.0'
provided 'org.apache.commons:commons-lang3:3.3.2'
// Tests
testCompile 'junit:junit:4.11'
testCompile 'org.assertj:assertj-core:1.7.0'
// Additional test compile dependencies
testCompile 'joda-time:joda-time:2.2'
}
One solution is to add the dependency like the joda-time library with testCompile
scope, but I don't want to duplicate any entries. I'm sure it can be achieved with proper configuration.
Solution
Fixed with one additional line in configurations
. Don't know if it's the best and a proper solution but works as intended.
configurations {
provided
testCompile.extendsFrom(provided)
}
Answered By - tomrozb
Answer Checked By - Mary Flores (JavaFixing Volunteer)