Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 33 additions & 54 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
</distributionManagement>

<properties>
<mavenVersion>3.0</mavenVersion>
<mavenVersion>3.2.5</mavenVersion>
Comment thread
michael-o marked this conversation as resolved.
<aetherVersion>1.0.0.v20140518</aetherVersion>
Comment thread
gnodet marked this conversation as resolved.
<javaVersion>7</javaVersion>
<plexusVersion>1.5.4</plexusVersion>
<project.build.outputTimestamp>2020-06-16T19:43:55Z</project.build.outputTimestamp>
</properties>

Expand Down Expand Up @@ -103,7 +103,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.2.1</version>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -116,49 +116,24 @@
<version>3.1.0</version><!-- do not upgrade to 3.2.0+ because it adds Xpp3Dom.getInputLocation(): see MSHARED-921 -->
</dependency>

<!-- Sonatype Aether for Maven 3.0.x -->
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.7</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-util</artifactId>
<version>1.7</version>
<exclusions>
<exclusion>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Eclipse Aether for Maven 3.1.x -->
<!-- Eclipse Aether for Maven 3.1+ -->
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>0.9.0.M2</version>
<version>${aetherVersion}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<version>0.9.0.M2</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
</exclusion>
</exclusions>
<version>${aetherVersion}</version>
</dependency>

<!-- test -->
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>2.1</version>
<version>3.3.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -170,7 +145,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
Comment thread
gnodet marked this conversation as resolved.
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -191,29 +172,18 @@
<version>${mavenVersion}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-connector-wagon</artifactId>
<version>1.7</version>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>1.0</version>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-http</artifactId>
<version>${aetherVersion}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -234,15 +204,24 @@
</dependency>

<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
<version>2.2.0</version>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.5</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin><!-- shade Xpp3DomUtils that does not require Xpp3Dom.getInputLocation(): see MSHARED-921 -->
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* under the License.
*/

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import org.apache.maven.execution.MavenSession;
Expand All @@ -34,6 +32,10 @@
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
Comment thread
gnodet marked this conversation as resolved.

/**
* <p>DefaultMavenPluginManagerHelper class.</p>
Expand All @@ -48,134 +50,20 @@ public class DefaultMavenPluginManagerHelper
@Requirement
protected MavenPluginManager mavenPluginManager;
Comment thread
gnodet marked this conversation as resolved.

private Boolean isEclipseAether;

private Method setupPluginRealm;

private Method getPluginDescriptor;

private Method getRepositorySession;

/**
* <p>Constructor for DefaultMavenPluginManagerHelper.</p>
*/
public DefaultMavenPluginManagerHelper()
private DependencyFilter createExclusionsDependencyFilter( List<String> artifactIdsList )
{
try
{
for ( Method m : MavenPluginManager.class.getMethods() )
{
if ( "setupPluginRealm".equals( m.getName() ) )
{
setupPluginRealm = m;
}
else if ( "getPluginDescriptor".equals( m.getName() ) )
{
getPluginDescriptor = m;
}
}
}
catch ( SecurityException e )
{
logger.warn( "unable to find MavenPluginManager.setupPluginRealm() method", e );
}

try
{
for ( Method m : MavenSession.class.getMethods() )
{
if ( "getRepositorySession".equals( m.getName() ) )
{
getRepositorySession = m;
break;
}
}
}
catch ( SecurityException e )
{
logger.warn( "unable to find MavenSession.getRepositorySession() method", e );
}
}

private boolean isEclipseAether()
{
if ( isEclipseAether == null )
{
try
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
cl.loadClass( "org.sonatype.aether.graph.DependencyFilter" );
isEclipseAether = false;
}
catch ( ClassNotFoundException e )
{
isEclipseAether = true;
}
}

return isEclipseAether;
}

private Object createExclusionsDependencyFilter( List<String> artifactIdsList )
{
if ( isEclipseAether() )
{
return new org.eclipse.aether.util.filter.ExclusionsDependencyFilter( artifactIdsList );
}
else
{
return new org.sonatype.aether.util.filter.ExclusionsDependencyFilter( artifactIdsList );
}
return new ExclusionsDependencyFilter( artifactIdsList );
}

/** {@inheritDoc} */
@Override
public PluginDescriptor getPluginDescriptor( Plugin plugin, MavenSession session )
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
{
try
{
Object repositorySession = getRepositorySession.invoke( session );
List<?> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories();

return (PluginDescriptor) getPluginDescriptor.invoke( mavenPluginManager, plugin, remoteRepositories,
repositorySession );
}
catch ( IllegalArgumentException e )
{
logger.warn( "IllegalArgumentException during MavenPluginManager.getPluginDescriptor() call", e );
}
catch ( IllegalAccessException e )
{
logger.warn( "IllegalAccessException during MavenPluginManager.getPluginDescriptor() call", e );
}
catch ( InvocationTargetException e )
{
Throwable target = e.getTargetException();
if ( target instanceof PluginResolutionException )
{
throw (PluginResolutionException) target;
}
if ( target instanceof PluginDescriptorParsingException )
{
throw (PluginDescriptorParsingException) target;
}
if ( target instanceof InvalidPluginDescriptorException )
{
throw (InvalidPluginDescriptorException) target;
}
if ( target instanceof RuntimeException )
{
throw (RuntimeException) target;
}
if ( target instanceof Error )
{
throw (Error) target;
}
logger.warn( "Exception during MavenPluginManager.getPluginDescriptor() call", e );
}
RepositorySystemSession repositorySystemSession = session.getRepositorySession();
List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories();

return null;
return mavenPluginManager.getPluginDescriptor( plugin, remoteRepositories, repositorySystemSession );
}

/** {@inheritDoc} */
Expand All @@ -184,39 +72,7 @@ public void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession se
List<String> imports, List<String> excludeArtifactIds )
throws PluginResolutionException, PluginContainerException
{
try
{
setupPluginRealm.invoke( mavenPluginManager, pluginDescriptor, session, parent, imports,
createExclusionsDependencyFilter( excludeArtifactIds ) );
}
catch ( IllegalArgumentException e )
{
logger.warn( "IllegalArgumentException during MavenPluginManager.setupPluginRealm() call", e );
}
catch ( IllegalAccessException e )
{
logger.warn( "IllegalAccessException during MavenPluginManager.setupPluginRealm() call", e );
}
catch ( InvocationTargetException e )
{
Throwable target = e.getTargetException();
if ( target instanceof PluginResolutionException )
{
throw (PluginResolutionException) target;
}
if ( target instanceof PluginContainerException )
{
throw (PluginContainerException) target;
}
if ( target instanceof RuntimeException )
{
throw (RuntimeException) target;
}
if ( target instanceof Error )
{
throw (Error) target;
}
logger.warn( "Exception during MavenPluginManager.setupPluginRealm() call", e );
}
mavenPluginManager.setupPluginRealm(
pluginDescriptor, session, parent, imports, createExclusionsDependencyFilter( excludeArtifactIds ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@
import org.apache.maven.settings.building.SettingsBuilder;
import org.apache.maven.settings.building.SettingsBuildingException;
import org.apache.maven.settings.building.SettingsBuildingRequest;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.repository.WorkspaceReader;
import org.sonatype.aether.repository.WorkspaceRepository;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.repository.WorkspaceRepository;

import java.io.File;
import java.util.Arrays;
Expand All @@ -64,6 +66,12 @@
public class TestDefaultMavenReportExecutor
extends PlexusTestCase
{
@Override
protected void customizeContainerConfiguration( @SuppressWarnings( "unused" ) final ContainerConfiguration configuration )
{
super.customizeContainerConfiguration( configuration );
configuration.setAutoWiring( true ).setClassPathScanning( PlexusConstants.SCANNING_CACHE );
}

MavenExecutionRequest request = null;

Expand Down