Closed frengor closed 9 months ago
There are two possible solution to this I think:
IsolatedClassLoader
, for example this method would become:
public Library toLibrary() {
return Library.builder()
.groupId(groupId)
.artifactId(artifactId)
.version(version)
.checksum(checksum)
.repository(Repositories.MAVEN_CENTRAL)
.relocate("org{}eclipse{}aether", "org.eclipse.aether")
.relocate("org{}apache{}maven", "org.apache.maven")
// etc etc
.build();
}
TransitiveDependencyCollector
to another module which is NOT shaded, but published separately and then downloaded and loaded at runtime into the IsolatedClassLoader
like it was a dependency. This would fix every issue with relocations, but it puts more effort into the publishing and testing process.
(Didn't actually happened, but I think it's possible to encounter this)
TransitiveDependencyCollector
is loaded by anIsolatedClassLoader
with its dependencies already loaded.However, maven and gradle do apply relocations also to
TransitiveDependencyCollector
, so relocating, for example,org.eclipse.aether
tomy.libs.org.eclipse.aether
would break it, since the dependencies are loaded but not relocated inside theIsolatedClassLoader
.Practically, this would happen if a project which is using Libby also makes use of
maven-resolver
(or similar) and decides to relocate it.