maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Belingueres <belingue...@gmail.com>
Subject Avoiding to shade aether classes in shared/artifact-transfer
Date Mon, 22 Apr 2019 01:24:00 GMT
Hi!
I resumed work on MSHARED-801 and I saw that for collecting dependencies I
need access to many aether classes. The current strategy is to shade the
necessary classes into the artifact-transfer jar file but this won't work
for collecting because it will actually force to use that classes of the
specific aether 0.90M2 version shaded.

In contrast I found a solution without shading (that is, with all aether
dependencies with provided scope) but I need to import those aether classes
from the Maven core ClassRealm to be available to the caller plugin. This
require injecting a PluginDescriptor and executing something like this
before calling the particular artifact-transfer component:

    public static void importAetherLibrary( PluginDescriptor
pluginDescriptor )
        throws MojoExecutionException
    {
        try
        {
            pluginDescriptor.getClassRealm().importFrom( "plexus.core",
"org.eclipse.aether.util" );
        }
        catch ( NoSuchRealmException e )
        {
            throw new MojoExecutionException( "NoSuchRealmException", e );
        }
    }

The question is if there exists a better (more "automagic"?) way to gain
access to the aether classes in the user's maven distribution that not
depends on a plugin explicitly importing the classes from the core
classRealm?

BTW: it seems Maven 3.0.x does not require such a package import.

Kind regards,
Gabriel

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message