It appears the final bug when using r4m-maven-extension with Eclipse is caused by m2e modifying the ClassLoader-Tree and executing the MvnCorePatcher.patchMaven(...) from outside the expected Plexus ClassRealm ClassLoader-Tree.
Stacktrace
java.lang.ClassCastException: class org.eclipse.osgi.internal.framework.ContextFinder cannot be cast to class org.codehaus.plexus.classworlds.realm.ClassRealm (org.eclipse.osgi.internal.framework.ContextFinder is in unnamed module of loader org.eclipse.equinox.launcher.Main$StartupClassLoader @75bd9247; org.codehaus.plexus.classworlds.realm.ClassRealm is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @76512190)
at net.runeduniverse.lib.utils.maven3.ext.MvnCorePatcher.patchMaven(MvnCorePatcher.java:122)
at net.runeduniverse.tools.maven.r4m.R4MLifecycleParticipant.afterProjectsRead(R4MLifecycleParticipant.java:163)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.executeParticipants(ProjectRegistryManager.java:824)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.lambda$11(ProjectRegistryManager.java:787)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.readMavenProjectFacades(ProjectRegistryManager.java:760)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:392)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:366)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob.lambda$4(ProjectRegistryRefreshJob.java:154)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1097)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob.lambda$0(ProjectRegistryRefreshJob.java:153)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob.run(ProjectRegistryRefreshJob.java:106)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Solution
It seems the best way to solve this issue is by first finding back into the ClassWorld.
Sadly there's the issue that Eclipse doesn't correctly initialize maven core extensions, as they are supposed to be first initialized before the MavenProject instances are constructed!
It appears the final bug when using r4m-maven-extension with Eclipse is caused by m2e modifying the ClassLoader-Tree and executing the
MvnCorePatcher.patchMaven(...)from outside the expected Plexus ClassRealm ClassLoader-Tree.Stacktrace
Solution
It seems the best way to solve this issue is by first finding back into the ClassWorld.
Sadly there's the issue that Eclipse doesn't correctly initialize maven core extensions, as they are supposed to be first initialized before the MavenProject instances are constructed!