I'm using two gradle plugins in a project :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'pluginA:1'
classpath 'pluginB:1'
}
}
apply plugin: 'pluginA'
apply plugin: 'pluginB'
Both pluginA and pluginB relies on xerces but in uncompatible versions... The problem is that execution of pluginA fails because the wrong version of xerces is used.
Is it possible to separate the classpath used for each plugin task execution (each plugin having only its own classpath during the execution of one of its task) ?
You might be able to use something like the ClassLoadersPlugin from here to create different classloaders for your tasks based on different configurations, and then specify your dependencies against those configurations. Not sure if this extends to a plugin scenario though, but it might, as the plugins are just creating tasks presumably, the eventual running of them would use different classloaders.
Alternatively the apply method takes a map, and you can specify what the objects it is applying to, so that not everything is done on the same project object.
Edit: Another avenue might be to look at excluding the dependency as detailed in Excluding transitive dependencies and creating configurations that specifically include the two xerces libs, and basing your tasks to run off those configurations, which would seem more "OOTB".