We have run into a problem during maven -> gradle migration. An upstream
project had a dependency on a certain library (servlet-api), with a scope of
provided. The artifacts built by gradle and deployed to the maven repo show
servlet-api as a dependency, and so it is added to the classpath of a
downstream project (dependency on upstream project is defined in the
"compile" configuration).
In order to get gradle to behave the same as maven did with the "provided"
scope set on this artifact, we have added a compile.exclude module:
'servlet-api' in configurations, and created a "provided" configuration that
includes servlet-api. The servlet-api also needs to be excluded from the
runtime classpath, but the configurations I am trying aren't working. how
would i correctly remove this from test runtime classpath?
configurations {
compile.exclude module: 'servlet-api'
testRuntime.exclude module: 'servlet-api'
provided
}
dependencies {
compile 'groupId:upstreamArtifact:version'
provided 'servlet-api'
testCompile 'junit:junit:version","servlet-api"
}
sourceSets {
main {
compileClasspath = compileClasspath + configurations.provided
}
test {
compileClasspath = sourceSets.main.class + configurations.testCompile +
configurations.provided
runtimeClasspath = runtimeClasspath + configurations.provided
}
}
the test sourceset's runtimeClasspath includes servlet-api, which fails. How
can i remove specific modules from the test runtimeClasspath?
been playing around with a runtimeClasspath.removeAll closure with a match
on this artifact, but that isn't working either.