Yes, the rootproject class loader is the parent of the subproject class loader and thus the classes on it win.
The question is, what nature is the dependency?
Is it just a "do something if plugin 2 is applied too"? If so, you can probably make it provided. If plugin 1 needs to apply plugin 2 I guess there is not much you can do on the plugin side, because plugin 1 would not see the classes of plugin 2 in the subproject.
😒 1
t
Tapchicoma
04/07/2022, 9:25 PM
We don't control plugin1
v
Vampire
04/07/2022, 9:39 PM
Ah I understood you ask how you "fix" it from plugin 1, which plugin did you mean then?
t
Tapchicoma
04/07/2022, 9:39 PM
plugin2
v
Vampire
04/07/2022, 9:39 PM
I see, let me think about it
Vampire
04/07/2022, 9:41 PM
Hm, I have no real idea.
I don't think there is much you can do about it from plugin2.
Where you apply plugin1 and plugin2 you can add the newer plugin2 to the class path of the root build script.
But from within plugin2 I don't think you can do anything, as the parent class loader will always win.
Except for using a different plugin ID in the newer version maybe.
thank you 1
l
Louis Jacomet
04/08/2022, 9:14 AM
I agree with the above and to add to it, changing the plugin Id will not be enough. You effectively have to change the package of the classes in the plugin JAR, otherwise classloader shadowing will still apply.