diff --git a/pom.xml b/pom.xml
index 76664a2..3d1b8aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@
- 3.1.0
+ 3.1.1
7
2021-01-23T01:12:59Z
@@ -105,18 +105,6 @@
2.6
-
- org.sonatype.aether
- aether-api
- 1.7
- provided
-
-
- org.sonatype.aether
- aether-util
- 1.7
- provided
-
org.apache.maven.resolver
maven-resolver-api
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
index e238f57..74e50ca 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
@@ -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;
/**
@@ -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 dependencies =
- (List) 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 dependencies =
- (List) 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 filter( Set artifacts )
{
-
Set result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/Invoker.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/Invoker.java
deleted file mode 100644
index 8f49ef7..0000000
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/Invoker.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Invokes method on objects using reflection.
- */
-final class Invoker
-{
- private Invoker()
- {
- // do not instantiate
- }
-
- public static Object invoke( Object object, String method )
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
- {
- return invoke( object.getClass(), object, method );
- }
-
- public static Object invoke( Class> objectClazz, Object object, String method )
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
- {
- return objectClazz.getMethod( method ).invoke( object );
- }
-
- public static Object invoke( Object object, String method, Class> clazz, Object arg )
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
- {
- final Class> objectClazz = object.getClass();
- return objectClazz.getMethod( method, clazz ).invoke( object, arg );
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
index 0d8d416..3ac97c5 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
index b9da1b0..9760bac 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
index 12b27ed..bc9c78a 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
index 1386638..f072a2e 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
index 78a8685..def075e 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
index 57d4788..1bc2cb4 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
@@ -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
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
deleted file mode 100644
index edce5d2..0000000
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter;
-import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
-import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.FilterTransformer;
-import org.apache.maven.shared.artifact.filter.resolve.OrFilter;
-import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
-import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.util.filter.AndDependencyFilter;
-import org.sonatype.aether.util.filter.ExclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.OrDependencyFilter;
-import org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.PatternInclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.ScopeDependencyFilter;
-
-/**
- * FilterTransformer implementation for Sonatype Aether
- *
- * @deprecated update to Maven 3.1.0 or later and replace Sonatype Aether with Eclipse Aether
- * @author Robert Scholte
- * @since 3.0
- */
-@Deprecated
-public class SonatypeAetherFilterTransformer
- implements FilterTransformer
-{
- /**
- * When using as regular expression, group(1) + group(3) will be the coordinate,
- * group(2) will be the classifier.
- */
- private static final String GAE_C_V = "(.*:.*:.*):(.+)(:.*)";
-
- @Override
- public AndDependencyFilter transform( AndFilter filter )
- {
- Collection filters = new ArrayList<>( filter.getFilters().size() );
- for ( TransformableFilter dependencyFilter : filter.getFilters() )
- {
- filters.add( dependencyFilter.transform( this ) );
- }
- return new AndDependencyFilter( filters );
- }
-
- @Override
- public ExclusionsDependencyFilter transform( ExclusionsFilter filter )
- {
- return new ExclusionsDependencyFilter( filter.getExcludes() );
- }
-
- @Override
- public OrDependencyFilter transform( OrFilter filter )
- {
- Collection filters = new ArrayList<>( filter.getFilters().size() );
- for ( TransformableFilter dependencyFilter : filter.getFilters() )
- {
- filters.add( dependencyFilter.transform( this ) );
- }
- return new OrDependencyFilter( filters );
- }
-
- @Override
- public ScopeDependencyFilter transform( ScopeFilter filter )
- {
- return new ScopeDependencyFilter( filter.getIncluded(), filter.getExcluded() );
- }
-
- @Override
- public DependencyFilter transform( PatternExclusionsFilter filter )
- {
- return new PatternExclusionsDependencyFilter( filter.getExcludes() );
- }
-
- @Override
- public DependencyFilter transform( PatternInclusionsFilter filter )
- {
- // if any include contains a classifier:
- // split all includes and make it an or-filter for every include
- // for the classifier, add an and-filter with a classifierfilter and patterninclusionfilter
-
- for ( String include : filter.getIncludes() )
- {
- if ( include.matches( GAE_C_V ) )
- {
- return newAdvancedPatternInclusionFilter( filter.getIncludes() );
- }
- }
-
- return new PatternInclusionsDependencyFilter( filter.getIncludes() );
- }
-
- @Override
- public DependencyFilter transform( final AbstractFilter filter )
- {
- return new DependencyFilter()
- {
- @Override
- public boolean accept( DependencyNode node, List parents )
- {
- return filter.accept( new SonatypeAetherNode( node ), null );
- }
- };
- }
-
- private DependencyFilter newAdvancedPatternInclusionFilter( Collection includes )
- {
- List filters = new ArrayList<>( includes.size() );
-
- Pattern pattern = Pattern.compile( GAE_C_V );
- for ( String include : includes )
- {
- Matcher matcher = pattern.matcher( include );
- if ( matcher.matches() )
- {
- DependencyFilter patternFilter =
- new PatternInclusionsDependencyFilter( matcher.group( 1 ) + matcher.group( 3 ) );
-
- final String classifier = matcher.group( 2 );
-
- DependencyFilter classifierFilter = new DependencyFilter()
- {
- @Override
- public boolean accept( DependencyNode node, List parents )
- {
- String nodeClassifier = node.getDependency().getArtifact().getClassifier();
-
- if ( nodeClassifier == null )
- {
- return false;
- }
- else
- {
- return "*".equals( classifier ) || nodeClassifier.matches( classifier );
- }
- }
- };
-
- filters.add( new AndDependencyFilter( patternFilter, classifierFilter ) );
- }
- else
- {
- filters.add( new PatternInclusionsDependencyFilter( include ) );
- }
- }
- return new OrDependencyFilter( filters );
- }
-}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
deleted file mode 100644
index 419f6fb..0000000
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.shared.artifact.filter.resolve.Node;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.util.artifact.ArtifactProperties;
-
-/**
- * Adapter of a Sonatype Aether DependencyNode for common Node
- *
- * @author Robert Scholte
- * @since 3.0
- */
-class SonatypeAetherNode implements Node
-{
-
- private final DependencyNode node;
-
- SonatypeAetherNode( DependencyNode node )
- {
- this.node = node;
- }
-
-
- @Override
- public org.apache.maven.model.Dependency getDependency()
- {
- Dependency nodeDependency = node.getDependency();
-
- if ( nodeDependency == null )
- {
- return null;
- }
-
- org.apache.maven.model.Dependency mavenDependency = new org.apache.maven.model.Dependency();
- mavenDependency.setGroupId( nodeDependency.getArtifact().getGroupId() );
- mavenDependency.setArtifactId( nodeDependency.getArtifact().getArtifactId() );
- mavenDependency.setVersion( nodeDependency.getArtifact().getVersion() );
- mavenDependency.setClassifier( nodeDependency.getArtifact().getClassifier() );
- mavenDependency.setType( nodeDependency.getArtifact().getProperty( ArtifactProperties.TYPE, null ) );
- mavenDependency.setScope( nodeDependency.getScope() );
- mavenDependency.setOptional( nodeDependency.isOptional() );
- if ( nodeDependency.getExclusions() != null )
- {
- List mavenExclusions =
- new ArrayList<>( nodeDependency.getExclusions().size() );
-
- for ( Exclusion aetherExclusion : nodeDependency.getExclusions() )
- {
- org.apache.maven.model.Exclusion mavenExclusion = new org.apache.maven.model.Exclusion();
-
- mavenExclusion.setGroupId( aetherExclusion.getGroupId() );
- mavenExclusion.setArtifactId( aetherExclusion.getArtifactId() );
- // that's all folks, although Aether has more metadata
-
- mavenExclusions.add( mavenExclusion );
- }
-
- mavenDependency.setExclusions( mavenExclusions );
- }
-
- return mavenDependency;
- }
-
-}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java
deleted file mode 100644
index fe4cd19..0000000
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter;
-import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
-import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.Node;
-import org.apache.maven.shared.artifact.filter.resolve.OrFilter;
-import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter;
-import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
-import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.filter.AndDependencyFilter;
-import org.sonatype.aether.util.filter.ExclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.OrDependencyFilter;
-import org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.PatternInclusionsDependencyFilter;
-import org.sonatype.aether.util.filter.ScopeDependencyFilter;
-import org.sonatype.aether.util.graph.DefaultDependencyNode;
-import org.junit.Test;
-
-public class SonatypeAetherFilterTransformerTest
-{
-
- private final SonatypeAetherFilterTransformer transformer = new SonatypeAetherFilterTransformer();
-
- @Test
- public void testTransformAndFilter()
- {
- AndFilter filter = new AndFilter(
- Arrays.asList( ScopeFilter.including( "compile" ),
- new ExclusionsFilter( Collections.singletonList( "x:a" ) ) ) );
-
- AndDependencyFilter dependencyFilter = (AndDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "compile" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v", "compile" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:v", "test" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v", "test" ), null ) );
- }
-
- @Test
- public void testTransformExclusionsFilter()
- {
- ExclusionsFilter filter = new ExclusionsFilter( Collections.singletonList( "x:a" ) );
-
- ExclusionsDependencyFilter dependencyFilter = (ExclusionsDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "compile" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v", "compile" ), null ) );
- }
-
- @Test
- public void testTransformOrFilter()
- {
- OrFilter filter = new OrFilter( Arrays.asList( ScopeFilter.including( "compile" ),
- ScopeFilter.including( "test" ) ) );
-
- OrDependencyFilter dependencyFilter = (OrDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "compile" ), null ) );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "test" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:v", "runtime" ), null ) );
- }
-
- @Test
- public void testTransformScopeFilter()
- {
- ScopeFilter filter = ScopeFilter.including( Collections.singletonList( "runtime" ) );
-
- ScopeDependencyFilter dependencyFilter = (ScopeDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "runtime" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:v", "compile" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:v", "test" ), null ) );
- }
-
- @Test
- public void testTransformPatternExclusionsFilter()
- {
- PatternExclusionsFilter filter =
- new PatternExclusionsFilter( Collections.singletonList( "x:*" ) );
-
- PatternExclusionsDependencyFilter dependencyFilter =
- (PatternExclusionsDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "runtime" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v", "runtime" ), null ) );
- }
-
- @Test
- public void testTransformPatternInclusionsFilter()
- {
- PatternInclusionsFilter filter =
- new PatternInclusionsFilter( Collections.singletonList( "g:*" ) );
-
- PatternInclusionsDependencyFilter dependencyFilter =
- (PatternInclusionsDependencyFilter) filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v", "runtime" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v", "runtime" ), null ) );
- }
-
-
- @Test
- public void testTransformClassifierPatternInclusionsFilter()
- {
- PatternInclusionsFilter filter =
- new PatternInclusionsFilter( Collections.singletonList( "g:*:*:c:*" ) );
-
- DependencyFilter dependencyFilter = filter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:v:c:*", "runtime" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:v", "runtime" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "x:a:v:c:*", "runtime" ), null ) );
- }
-
- @Test
- public void testTransformAbstractFilter()
- {
- AbstractFilter snapshotFilter = new AbstractFilter()
- {
- @Override
- public boolean accept( Node node, List parents )
- {
- return ArtifactUtils.isSnapshot( node.getDependency().getVersion() );
- }
- };
-
- DependencyFilter dependencyFilter = snapshotFilter.transform( transformer );
-
- assertTrue( dependencyFilter.accept( newDependencyNode( "g:a:1.0-SNAPSHOT", "compile" ), null ) );
-
- assertFalse( dependencyFilter.accept( newDependencyNode( "g:a:1.0", "compile" ), null ) );
- }
-
- private DependencyNode newDependencyNode( String string, String scope )
- {
- return new DefaultDependencyNode( new Dependency( new DefaultArtifact( string ), scope ) );
- }
-
-}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java
deleted file mode 100644
index 826e394..0000000
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.apache.maven.shared.artifact.filter.resolve.Node;
-import org.junit.Test;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.graph.DefaultDependencyNode;
-
-import static org.junit.Assert.*;
-
-public class SonatypeAetherNodeTest
-{
- @Test
- public void testGAV()
- {
- Node node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null ) );
-
- org.apache.maven.model.Dependency mavenDependency = node.getDependency();
-
- assertEquals( "g", mavenDependency.getGroupId() );
- assertEquals( "a", mavenDependency.getArtifactId() );
- assertEquals( "v", mavenDependency.getVersion() );
- assertEquals( "", mavenDependency.getClassifier() );
- assertNull( mavenDependency.getType() );
- assertEquals( "", mavenDependency.getScope() );
- }
-
- @Test
- public void testClassifier()
- {
- Node node = new SonatypeAetherNode( newDependencyNode( "g:a::c:v", null ) );
-
- org.apache.maven.model.Dependency mavenDependency = node.getDependency();
-
- assertEquals( "g", mavenDependency.getGroupId() );
- assertEquals( "a", mavenDependency.getArtifactId() );
- assertEquals( "v", mavenDependency.getVersion() );
- assertEquals( "c", mavenDependency.getClassifier() );
- assertNull( mavenDependency.getType() );
- assertEquals( "", mavenDependency.getScope() );
- }
-
- @Test
- public void testScope()
- {
- Node node = new SonatypeAetherNode( newDependencyNode( "g:a:v", "s" ) );
-
- org.apache.maven.model.Dependency mavenDependency = node.getDependency();
-
- assertEquals( "g", mavenDependency.getGroupId() );
- assertEquals( "a", mavenDependency.getArtifactId() );
- assertEquals( "v", mavenDependency.getVersion() );
- assertEquals( "", mavenDependency.getClassifier() );
- assertNull( mavenDependency.getType() );
- assertEquals( "s", mavenDependency.getScope() );
- }
-
- @Test
- public void testOptional()
- {
- Node node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null ) );
-
- assertEquals( "false", node.getDependency().getOptional() );
- assertFalse( node.getDependency().isOptional() );
-
- node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null, true ) );
- assertEquals( "true", node.getDependency().getOptional() );
- assertTrue( node.getDependency().isOptional() );
-
- node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null, false ) );
- assertEquals( "false", node.getDependency().getOptional() );
- assertFalse( node.getDependency().isOptional() );
- }
-
- @Test
- public void testExclusions()
- {
- Node node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null, Collections.singletonList( "eg:ea" ) ) );
- assertEquals( 1, node.getDependency().getExclusions().size() );
-
- org.apache.maven.model.Exclusion mavenExclusion = node.getDependency().getExclusions().get( 0 );
- assertEquals( "eg", mavenExclusion.getGroupId() );
- assertEquals( "ea", mavenExclusion.getArtifactId() );
- }
-
- private DependencyNode newDependencyNode( String string, String scope )
- {
- return new DefaultDependencyNode( new Dependency( new DefaultArtifact( string ), scope ) );
- }
-
- private DependencyNode newDependencyNode( String coor, String scope, boolean optional )
- {
- return new DefaultDependencyNode( new Dependency( new DefaultArtifact( coor ), scope, optional ) );
- }
-
- private DependencyNode newDependencyNode( String coor, String scope, Collection exclusions )
- {
- Dependency dependency = new Dependency( new DefaultArtifact( coor ), scope );
-
- Collection aetherExclusions = new ArrayList<>( exclusions.size() );
- for ( String exclusion : exclusions )
- {
- String[] ga = exclusion.split( ":" );
- aetherExclusions.add( new Exclusion( ga[0], ga[1], null, null ) );
- }
- dependency = dependency.setExclusions( aetherExclusions );
-
- return new DefaultDependencyNode( dependency );
- }
-}