Skip to content

Commit

Permalink
[MSHARED-974] Remove obsolete code and references to Sonatype Aether
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Feb 1, 2021
1 parent 1f67266 commit 17819fe
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 727 deletions.
14 changes: 1 addition & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</distributionManagement>

<properties>
<maven.version>3.1.0</maven.version>
<maven.version>3.1.1</maven.version>
<javaVersion>7</javaVersion>
<project.build.outputTimestamp>2021-01-23T01:12:59Z</project.build.outputTimestamp>
</properties>
Expand Down Expand Up @@ -105,18 +105,6 @@
<version>2.6</version>
</dependency>

<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-util</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
import org.eclipse.aether.graph.Dependency;

import java.lang.reflect.InvocationTargetException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
Expand Down Expand Up @@ -79,85 +78,19 @@ public ArtifactTransitivityFilter( Artifact artifact, ProjectBuildingRequest bui
DependencyResolutionResult resolutionResult = buildingResult.getDependencyResolutionResult();
if ( resolutionResult != null )
{
if ( isMaven31() )
for ( Dependency dependency : resolutionResult.getDependencies() )
{
try
{
@SuppressWarnings( "unchecked" ) List<org.eclipse.aether.graph.Dependency> dependencies =
(List<org.eclipse.aether.graph.Dependency>) Invoker.invoke( resolutionResult,
"getDependencies" );

for ( org.eclipse.aether.graph.Dependency dependency : dependencies )
{
Artifact mavenArtifact =
(Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
org.eclipse.aether.artifact.Artifact.class,
dependency.getArtifact() );

transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
}
else
{
try
{
@SuppressWarnings( "unchecked" ) List<org.sonatype.aether.graph.Dependency> dependencies =
(List<org.sonatype.aether.graph.Dependency>) Invoker.invoke( resolutionResult,
"getDependencies" );

for ( org.sonatype.aether.graph.Dependency dependency : dependencies )
{
Artifact mavenArtifact =
(Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
org.sonatype.aether.artifact.Artifact.class,
dependency.getArtifact() );

transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
}
Artifact mavenArtifact = RepositoryUtils.toArtifact( dependency.getArtifact() );
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
}

/**
* @return true if the current Maven version is Maven 3.1.
*/
protected static boolean isMaven31()
{
return canFindCoreClass( "org.eclipse.aether.artifact.Artifact" ); // Maven 3.1 specific
}

private static boolean canFindCoreClass( String className )
{
try
{
Thread.currentThread().getContextClassLoader().loadClass( className );

return true;
}
catch ( ClassNotFoundException e )
{
return false;
}
}

/**
* {@inheritDoc}
*/
public Set<Artifact> filter( Set<Artifact> artifacts )
{

Set<Artifact> result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.AndDependencyFilter
* @see org.eclipse.aether.util.filter.AndDependencyFilter
*/
public class AndFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.ExclusionsDependencyFilter
* @see org.eclipse.aether.util.filter.ExclusionsDependencyFilter
*/
public class ExclusionsFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.OrDependencyFilter
* @see org.eclipse.aether.util.filter.OrDependencyFilter
*/
public class OrFilter implements TransformableFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter
* @see org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter
* @see org.sonatype.aether.version.VersionScheme
* @see org.eclipse.aether.version.VersionScheme
*/
public class PatternExclusionsFilter implements TransformableFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.PatternInclusionsDependencyFilter
* @see org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter
* @see org.sonatype.aether.version.VersionScheme
* @see org.eclipse.aether.version.VersionScheme
*/
public class PatternInclusionsFilter implements TransformableFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @author Robert Scholte
* @since 3.0
*
* @see org.sonatype.aether.util.filter.ScopeDependencyFilter
* @see org.eclipse.aether.util.filter.ScopeDependencyFilter
*/
public class ScopeFilter implements TransformableFilter
Expand Down
Loading

0 comments on commit 17819fe

Please sign in to comment.