jenkins-pipeline-shared-libraries-gradle-plugin icon indicating copy to clipboard operation
jenkins-pipeline-shared-libraries-gradle-plugin copied to clipboard

Add possibility to exclude (transitive) dependencies

Open sruehl opened this issue 6 years ago • 3 comments

If this dependency is added: dependency("com.openshift.jenkins", "openshift-pipeline", "1.0.54") the integrationTests fail in a java.lang.StackOverflowError. This answer here indicates that this might be a problem of an unwanted dependency. We might need the ability to exclude dependencies from plugins.

sruehl avatar Feb 26 '18 13:02 sruehl

For those who land here by a google search, here is a workaround:

// TODO: workaround for missing dependency exclude mechanism is pipeline plugin.
configurations.all {
    exclude("org.slf4j", "slf4j-log4j12")
    exclude("log4j", "log4j")
}

sruehl avatar Feb 26 '18 14:02 sruehl

I agree it should be more straightforward., and have better alignment with how Gradle users expect to exclude dependencies using https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html. I'd like the UX to feel more "Gradle native" by just using the existing dependencies idioms, but haven't quite figured out the right balance between DSL-friendly dependencies for Jenkins and using the built-in Gradle concepts

However, there should be a workaround for your use-case.

You can exclude the bad dependency from all configurations (if that is useful):

configurations {
  all { 
    exclude("org.slf4j", "slf4j-log4j12") 
    exclude("log4j", "log4j")
  }
}

Or exclude them specifically from the configurations created by the plugin or the integrationTest runtime. The configurations.all I think is better for now to not rely on the internal configuration changes while I try and figure out a better way to represent dependencies.

mkobit avatar Feb 26 '18 14:02 mkobit

Looks like you already figured out the workaround, thanks for posting it.

mkobit avatar Feb 26 '18 14:02 mkobit