http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java index 2c4a60e..6fa72ce 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java @@ -569,9 +569,9 @@ public class DefaultWagonManager wagon.addTransferListener( downloadMonitor ); } - Map<String, ChecksumObserver> checksums = new HashMap<String, ChecksumObserver>( 2 ); + Map<String, ChecksumObserver> checksums = new HashMap<>( 2 ); - Map<String, String> sums = new HashMap<String, String>( 2 ); + Map<String, String> sums = new HashMap<>( 2 ); // TODO: configure these on the repository for ( int i = 0; i < CHECKSUM_IDS.length; i++ ) @@ -579,7 +579,7 @@ public class DefaultWagonManager checksums.put( CHECKSUM_IDS[i], addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i] ) ); } - List<File> temporaryFiles = new ArrayList<File>(); + List<File> temporaryFiles = new ArrayList<>(); try {
http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index 6dd84db..866968b 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -158,7 +158,7 @@ public class LegacyRepositorySystem if ( !d.getExclusions().isEmpty() ) { - List<String> exclusions = new ArrayList<String>(); + List<String> exclusions = new ArrayList<>(); for ( Exclusion exclusion : d.getExclusions() ) { @@ -377,7 +377,7 @@ public class LegacyRepositorySystem return null; } - Map<String, List<ArtifactRepository>> reposByKey = new LinkedHashMap<String, List<ArtifactRepository>>(); + Map<String, List<ArtifactRepository>> reposByKey = new LinkedHashMap<>(); for ( ArtifactRepository repository : repositories ) { @@ -387,21 +387,21 @@ public class LegacyRepositorySystem if ( aliasedRepos == null ) { - aliasedRepos = new ArrayList<ArtifactRepository>(); + aliasedRepos = new ArrayList<>(); reposByKey.put( key, aliasedRepos ); } aliasedRepos.add( repository ); } - List<ArtifactRepository> effectiveRepositories = new ArrayList<ArtifactRepository>(); + List<ArtifactRepository> effectiveRepositories = new ArrayList<>(); for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() ) { - List<ArtifactRepository> mirroredRepos = new ArrayList<ArtifactRepository>(); + List<ArtifactRepository> mirroredRepos = new ArrayList<>(); List<ArtifactRepositoryPolicy> releasePolicies = - new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() ); + new ArrayList<>( aliasedRepos.size() ); for ( ArtifactRepository aliasedRepo : aliasedRepos ) { @@ -412,7 +412,7 @@ public class LegacyRepositorySystem ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies ); List<ArtifactRepositoryPolicy> snapshotPolicies = - new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() ); + new ArrayList<>( aliasedRepos.size() ); for ( ArtifactRepository aliasedRepo : aliasedRepos ) { @@ -532,7 +532,7 @@ public class LegacyRepositorySystem { if ( repositories != null ) { - Map<String, Server> serversById = new HashMap<String, Server>(); + Map<String, Server> serversById = new HashMap<>(); if ( servers != null ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java index b20bd72..017dd9b 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java @@ -55,8 +55,8 @@ public class TransferListenerAdapter private TransferListenerAdapter( ArtifactTransferListener listener ) { this.listener = listener; - this.artifacts = new IdentityHashMap<Resource, ArtifactTransferResource>(); - this.transfers = new IdentityHashMap<Resource, Long>(); + this.artifacts = new IdentityHashMap<>(); + this.transfers = new IdentityHashMap<>(); } public void debug( String message ) http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java index f734416..04d0d6b7 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java @@ -87,7 +87,7 @@ public class DefaultLegacyArtifactCollector } public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, + Map<String, Artifact> managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, @@ -102,7 +102,7 @@ public class DefaultLegacyArtifactCollector } public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactResolutionRequest repositoryRequest, + Map<String, Artifact> managedVersions, ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers ) @@ -116,7 +116,7 @@ public class DefaultLegacyArtifactCollector conflictResolvers = Collections.singletonList( defaultConflictResolver ); } - Map<Object, List<ResolutionNode>> resolvedArtifacts = new LinkedHashMap<Object, List<ResolutionNode>>(); + Map<Object, List<ResolutionNode>> resolvedArtifacts = new LinkedHashMap<>(); ResolutionNode root = new ResolutionNode( originatingArtifact, repositoryRequest.getRemoteRepositories() ); @@ -160,7 +160,7 @@ public class DefaultLegacyArtifactCollector result.addErrorArtifactException( e ); } - Set<ResolutionNode> set = new LinkedHashSet<ResolutionNode>(); + Set<ResolutionNode> set = new LinkedHashSet<>(); for ( List<ResolutionNode> nodes : resolvedArtifacts.values() ) { @@ -206,7 +206,7 @@ public class DefaultLegacyArtifactCollector * @param originatingArtifact artifact we are processing * @param managedVersions original managed versions */ - private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map managedVersions ) + private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map<String,Artifact> managedVersions ) { ManagedVersionMap versionMap; if ( ( managedVersions != null ) && ( managedVersions instanceof ManagedVersionMap ) ) @@ -406,7 +406,7 @@ public class DefaultLegacyArtifactCollector } else { - previousNodes = new ArrayList<ResolutionNode>(); + previousNodes = new ArrayList<>(); resolvedArtifacts.put( key, previousNodes ); } @@ -774,7 +774,7 @@ public class DefaultLegacyArtifactCollector } public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, - Map managedVersions, ArtifactRepository localRepository, + Map<String, Artifact> managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners ) http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java index fa7fb7a..133bd58 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/LegacyArtifactCollector.java @@ -42,19 +42,19 @@ import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; public interface LegacyArtifactCollector { - ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, + ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map<String, Artifact> managedVersions, ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers ); - ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, + ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map<String, Artifact> managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers ); // used by maven-dependency-tree and maven-dependency-plugin @Deprecated - ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, + ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map<String, Artifact> managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java index b0cb5b2..0630b68 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ClasspathContainer.java @@ -62,7 +62,7 @@ implements Iterable<ArtifactMetadata> { if ( classpath == null ) { - classpath = new ArrayList<ArtifactMetadata>( 16 ); + classpath = new ArrayList<>( 16 ); } classpath.add( md ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java index 03984fb..b6e3c0c 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java @@ -101,7 +101,7 @@ public class DefaultClasspathTransformation this.cpc = cpc; this.graph = cleanGraph; - visited = new ArrayList<MetadataGraphVertex>( cleanGraph.getVertices().size() ); + visited = new ArrayList<>( cleanGraph.getVertices().size() ); } // ----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java index 7706029..9a27bf4 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolver.java @@ -153,10 +153,10 @@ public class DefaultGraphConflictResolver return g; } - List<MetadataGraphVertex> visited = new ArrayList<MetadataGraphVertex>( g.getVertices().size() ); + List<MetadataGraphVertex> visited = new ArrayList<>( g.getVertices().size() ); visit( g.getEntry(), visited, g ); - List<MetadataGraphVertex> dropList = new ArrayList<MetadataGraphVertex>( g.getVertices().size() ); + List<MetadataGraphVertex> dropList = new ArrayList<>( g.getVertices().size() ); // collect drop list for ( MetadataGraphVertex v : g.getVertices() ) http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java index 55b0250..3f13888 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java @@ -244,7 +244,7 @@ public class MetadataGraph { if ( vertices == null ) { - vertices = new TreeSet<MetadataGraphVertex>(); + vertices = new TreeSet<>(); } } private void checkEdges() @@ -262,11 +262,11 @@ public class MetadataGraph { if ( incidentEdges == null ) { - incidentEdges = new HashMap<MetadataGraphVertex, List<MetadataGraphEdge>>( nEdges ); + incidentEdges = new HashMap<>( nEdges ); } if ( excidentEdges == null ) { - excidentEdges = new HashMap<MetadataGraphVertex, List<MetadataGraphEdge>>( nEdges ); + excidentEdges = new HashMap<>( nEdges ); } } //------------------------------------------------------------------------ @@ -300,7 +300,7 @@ public class MetadataGraph return null; } - List<MetadataGraphEdge> res = new ArrayList<MetadataGraphEdge>( edges.size() ); + List<MetadataGraphEdge> res = new ArrayList<>( edges.size() ); for ( MetadataGraphEdge e : edges ) { @@ -333,7 +333,7 @@ public class MetadataGraph List<MetadataGraphEdge> exList = excidentEdges.get( vFrom ); if ( exList == null ) { - exList = new ArrayList<MetadataGraphEdge>(); + exList = new ArrayList<>(); excidentEdges.put( vFrom, exList ); } @@ -345,7 +345,7 @@ public class MetadataGraph List<MetadataGraphEdge> inList = incidentEdges.get( vTo ); if ( inList == null ) { - inList = new ArrayList<MetadataGraphEdge>(); + inList = new ArrayList<>(); incidentEdges.put( vTo, inList ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java index 0e98b0c..99c0b0b 100644 --- a/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java +++ b/maven-compat/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java @@ -43,14 +43,14 @@ public class ExpressionDocumenter private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/"; - private static Map expressionDocumentation; + private static Map<String, Expression> expressionDocumentation; public static Map load() throws ExpressionDocumentationException { if ( expressionDocumentation == null ) { - expressionDocumentation = new HashMap(); + expressionDocumentation = new HashMap<>(); ClassLoader docLoader = initializeDocLoader(); @@ -64,7 +64,7 @@ public class ExpressionDocumenter if ( docStream != null ) { - Map doco = parseExpressionDocumentation( docStream ); + Map<String, Expression> doco = parseExpressionDocumentation( docStream ); expressionDocumentation.putAll( doco ); } @@ -114,7 +114,7 @@ public class ExpressionDocumenter * @throws IOException * @throws XmlPullParserException */ - private static Map parseExpressionDocumentation( InputStream docStream ) + private static Map<String, Expression> parseExpressionDocumentation( InputStream docStream ) throws IOException, XmlPullParserException { Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) ); @@ -125,7 +125,7 @@ public class ExpressionDocumenter List expressions = documentation.getExpressions(); - Map bySyntax = new HashMap(); + Map<String, Expression> bySyntax = new HashMap<>(); if ( expressions != null && !expressions.isEmpty() ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java index 010c566..fc2fde0 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java @@ -236,7 +236,7 @@ public abstract class AbstractArtifactComponentTestCase protected List<ArtifactRepository> remoteRepositories() throws Exception { - List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>(); + List<ArtifactRepository> remoteRepositories = new ArrayList<>(); remoteRepositories.add( remoteRepository() ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java index 7b20eb5..a80f337 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java @@ -64,7 +64,7 @@ public class ArtifactUtilsTest public void testArtifactMapByVersionlessIdOrdering() throws Exception { - List<Artifact> list = new ArrayList<Artifact>(); + List<Artifact> list = new ArrayList<>(); list.add( newArtifact( "b" ) ); list.add( newArtifact( "a" ) ); list.add( newArtifact( "c" ) ); @@ -73,7 +73,7 @@ public class ArtifactUtilsTest Map<String, Artifact> map = ArtifactUtils.artifactMapByVersionlessId( list ); assertNotNull( map ); - assertEquals( list, new ArrayList<Artifact>( map.values() ) ); + assertEquals( list, new ArrayList<>( map.values() ) ); } } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java index f8bb167..e3e385e 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java @@ -41,7 +41,7 @@ public class TestMetadataSource public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) throws ArtifactMetadataRetrievalException { - Set dependencies = new HashSet(); + Set<Artifact> dependencies = new HashSet<>(); if ( "g".equals( artifact.getArtifactId() ) ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java index aeacfb8..059aa2c 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java @@ -44,7 +44,7 @@ public class ArtifactResolutionExceptionTest String type = "jar"; String classifier = "aClassifier"; String downloadUrl = "http://somewhere.com/download"; - List path = Arrays.asList( "dependency1", "dependency2" ); + List<String> path = Arrays.asList( "dependency1", "dependency2" ); String expected = "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java index 117c0e2..df49dbd 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java @@ -35,7 +35,6 @@ import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.codehaus.plexus.component.repository.ComponentDescriptor; // It would be cool if there was a hook that i could use to setup a test environment. // I want to setup a local/remote repositories for testing but i don't want to have @@ -174,7 +173,7 @@ public class ArtifactResolverTest Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" ); deleteLocalArtifact( l ); - List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>(); + List<ArtifactRepository> repositories = new ArrayList<>(); repositories.add( remoteRepository() ); repositories.add( badRemoteRepository() ); @@ -196,7 +195,7 @@ public class ArtifactResolverTest List<ArtifactRepository> remoteRepositories ) throws ArtifactMetadataRetrievalException { - Set dependencies = new HashSet(); + Set<Artifact> dependencies = new HashSet<>(); return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } @@ -233,7 +232,7 @@ public class ArtifactResolverTest ArtifactResolutionResult result = null; - Set set = new LinkedHashSet(); + Set<Artifact> set = new LinkedHashSet<>(); set.add( n ); set.add( m ); @@ -247,7 +246,7 @@ public class ArtifactResolverTest assertEquals( "m should be second", m, i.next() ); // inverse order - set = new LinkedHashSet(); + set = new LinkedHashSet<>(); set.add( m ); set.add( n ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java index afec3ef..82ee63e 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java @@ -28,7 +28,7 @@ public class TestTransferListener extends AbstractTransferListener { - private final List<String> transfers = new ArrayList<String>(); + private final List<String> transfers = new ArrayList<>(); public List<String> getTransfers() { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java index a9f1ab7..3cadd29 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java @@ -53,7 +53,7 @@ public class TestFileManager public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); - private List<File> filesToDelete = new ArrayList<File>(); + private List<File> filesToDelete = new ArrayList<>(); private final String baseFilename; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java index 36eaee8..90df8cb 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java @@ -46,7 +46,7 @@ public class ClasspathArtifactResolver Collection<? extends ArtifactRequest> requests ) throws ArtifactResolutionException { - List<ArtifactResult> results = new ArrayList<ArtifactResult>(); + List<ArtifactResult> results = new ArrayList<>(); for ( ArtifactRequest request : requests ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java index 024917d..21c7349 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java +++ b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java @@ -63,7 +63,7 @@ public class EmptyLifecycleExecutor // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { - plugins = new LinkedHashSet<Plugin>(); + plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java index 5a78a7e..672e07b 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java +++ b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java @@ -40,7 +40,7 @@ public class EmptyLifecyclePluginAnalyzer // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { - plugins = new LinkedHashSet<Plugin>(); + plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java index 6c3df9a..b2750b9 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index d9e7beb..d7ae86e 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -20,7 +20,6 @@ package org.apache.maven.project; */ import java.io.File; -import java.util.Iterator; import org.apache.maven.artifact.Artifact; import org.apache.maven.repository.RepositorySystem; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java index 0ee7980..8e4f39d 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java @@ -19,7 +19,6 @@ package org.apache.maven.project.inheritance.t00; * under the License. */ -import org.apache.maven.model.MailingList; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java index 339c81f..6e9a7a3 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java @@ -21,12 +21,10 @@ package org.apache.maven.project.inheritance.t02; import java.io.File; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.model.Build; -import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; @@ -118,7 +116,7 @@ public class ProjectInheritanceTest Build build = project4.getBuild(); List<Plugin> plugins = build.getPlugins(); - Map validPluginCounts = new HashMap(); + Map<String, Integer> validPluginCounts = new HashMap<>(); String testPluginArtifactId = "maven-compiler-plugin"; @@ -147,7 +145,7 @@ public class ProjectInheritanceTest testPlugin = plugin; } - Integer count = (Integer) validPluginCounts.get( pluginArtifactId ); + Integer count = validPluginCounts.get( pluginArtifactId ); if ( count > 0 ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java index e24262f..1bb4ef8 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java @@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t04; */ import java.io.File; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java index 1d2bd18..2773c19 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java @@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t05; */ import java.io.File; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java index 68586aa..d0d013e 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java @@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t07; */ import java.io.File; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java index 068c0e0..b9bcf9b 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java @@ -83,7 +83,7 @@ public class DefaultWagonManagerTest { Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); - List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>(); + List<ArtifactRepository> repos = new ArrayList<>(); repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1", new ArtifactRepositoryLayoutStub(), null, null ) ); repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", @@ -96,7 +96,7 @@ public class DefaultWagonManagerTest class TransferListener extends AbstractTransferListener { - public List<TransferEvent> events = new ArrayList<TransferEvent>(); + public List<TransferEvent> events = new ArrayList<>(); @Override public void transferInitiated( TransferEvent transferEvent ) http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java index d0325db..944cce6 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java @@ -41,7 +41,7 @@ import org.codehaus.plexus.component.annotations.Component; public class StringWagon extends StreamWagon { - private Map<String, String> expectedContent = new HashMap<String, String>(); + private Map<String, String> expectedContent = new HashMap<>(); public void addExpectedContent( String resourceName, String expectedContent ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java index 58dd3fa..39084fe 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java @@ -19,17 +19,6 @@ package org.apache.maven.repository.legacy.resolver; * under the License. */ -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -39,6 +28,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.CyclicDependencyException; +import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; @@ -50,6 +40,16 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.codehaus.plexus.PlexusTestCase; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * Test the default artifact collector. * @@ -730,31 +730,31 @@ public class DefaultArtifactCollectorTest return null; } - private ArtifactResolutionResult collect( Set artifacts ) + private ArtifactResolutionResult collect( Set<Artifact> artifacts ) throws ArtifactResolutionException { return collect( artifacts, null ); } - private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) + private ArtifactResolutionResult collect( Set<Artifact> artifacts, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter, - Collections.EMPTY_LIST, null ); + Collections.<ResolutionListener>emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, - null, source, null, Collections.EMPTY_LIST, null ); + null, source, null, Collections.<ResolutionListener>emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, - null, source, filter, Collections.EMPTY_LIST, null ); + null, source, filter, Collections.<ResolutionListener>emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion ) @@ -762,7 +762,7 @@ public class DefaultArtifactCollectorTest { Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, - managedVersions, null, null, source, null, Collections.EMPTY_LIST, null ); + managedVersions, null, null, source, null, Collections.<ResolutionListener>emptyList(), null ); } private ArtifactSpec createArtifactSpec( String id, String version ) @@ -801,7 +801,8 @@ public class DefaultArtifactCollectorTest return spec; } - private static Set createSet( Object[] x ) + @SuppressWarnings( "unchecked" ) + private static Set<Artifact> createSet( Object[] x ) { return new LinkedHashSet( Arrays.asList( x ) ); } @@ -810,7 +811,7 @@ public class DefaultArtifactCollectorTest { private Artifact artifact; - private Set dependencies = new HashSet(); + private Set<Artifact> dependencies = new HashSet<>(); public ArtifactSpec addDependency( String id, String version ) throws InvalidVersionSpecificationException @@ -851,9 +852,9 @@ public class DefaultArtifactCollectorTest private class Source implements ArtifactMetadataSource { - private Map artifacts = new HashMap(); + private Map<String, ArtifactSpec> artifacts = new HashMap<>(); - private Map versions = new HashMap(); + private Map<String, List<ArtifactVersion>> versions = new HashMap<>(); public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) @@ -880,16 +881,14 @@ public class DefaultArtifactCollectorTest return artifact.getDependencyConflictId(); } - private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope, + private Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, Set<Artifact> dependencies, String inheritedScope, ArtifactFilter dependencyFilter ) throws InvalidVersionSpecificationException { - Set projectArtifacts = new HashSet(); + Set<Artifact> projectArtifacts = new HashSet<>(); - for ( Object dependency : dependencies ) + for ( Artifact d : dependencies ) { - Artifact d = (Artifact) dependency; - VersionRange versionRange; if ( d.getVersionRange() != null ) { @@ -931,10 +930,10 @@ public class DefaultArtifactCollectorTest artifacts.put( getKey( spec.artifact ), spec ); String key = spec.artifact.getDependencyConflictId(); - List artifactVersions = (List) versions.get( key ); + List<ArtifactVersion> artifactVersions = versions.get( key ); if ( artifactVersions == null ) { - artifactVersions = new ArrayList(); + artifactVersions = new ArrayList<>(); versions.put( key, artifactVersions ); } if ( spec.artifact.getVersion() != null ) @@ -961,10 +960,10 @@ public class DefaultArtifactCollectorTest private List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact ) { - List artifactVersions = (List) versions.get( artifact.getDependencyConflictId() ); + List<ArtifactVersion> artifactVersions = versions.get( artifact.getDependencyConflictId() ); if ( artifactVersions == null ) { - artifactVersions = Collections.EMPTY_LIST; + artifactVersions = Collections.emptyList(); } return artifactVersions; } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java index bfab0d2..12a0c57 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java @@ -21,12 +21,15 @@ package org.apache.maven.repository.legacy.resolver.conflict; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.codehaus.plexus.PlexusTestCase; +import java.util.Collections; + /** * Provides a basis for testing conflict resolvers. * @@ -108,24 +111,11 @@ public abstract class AbstractConflictResolverTest assertEquals( "Resolution node", expectedNode, resolvedNode ); } - protected void assertUnresolvableConflict( ResolutionNode actualNode1, ResolutionNode actualNode2 ) - { - ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 ); - - assertNull( "Expected unresolvable", resolvedNode ); - } - protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException { return createArtifact( id, version, Artifact.SCOPE_COMPILE ); } - protected Artifact createArtifact( String id, String version, boolean optional ) - throws InvalidVersionSpecificationException - { - return createArtifact( id, version, Artifact.SCOPE_COMPILE, null, optional ); - } - protected Artifact createArtifact( String id, String version, String scope ) throws InvalidVersionSpecificationException { @@ -140,4 +130,14 @@ public abstract class AbstractConflictResolverTest return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope, optional ); } + + protected ResolutionNode createResolutionNode( Artifact Artifact ) + { + return new ResolutionNode( Artifact, Collections.<ArtifactRepository>emptyList() ); + } + protected ResolutionNode createResolutionNode( Artifact Artifact, ResolutionNode parent ) + { + return new ResolutionNode( Artifact, Collections.<ArtifactRepository>emptyList(), parent ); + } + } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java index 96e283d..5ca3a47 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java @@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict; * under the License. */ -import java.util.Collections; - import org.apache.maven.artifact.resolver.ResolutionNode; -import org.apache.maven.repository.legacy.resolver.conflict.FarthestConflictResolver; /** * Tests <code>FarthestConflictResolver</code>. @@ -52,9 +49,9 @@ public class FarthestConflictResolverTest */ public void testDepth() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); + ResolutionNode a1n = createResolutionNode( a1); + ResolutionNode b1n = createResolutionNode( b1); + ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a2n, a1n, a2n ); } @@ -68,9 +65,9 @@ public class FarthestConflictResolverTest */ public void testDepthReversed() { - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode b1n = createResolutionNode( b1 ); + ResolutionNode a2n = createResolutionNode( a2, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } @@ -84,8 +81,8 @@ public class FarthestConflictResolverTest */ public void testEqual() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } @@ -99,8 +96,8 @@ public class FarthestConflictResolverTest */ public void testEqualReversed() { - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode a2n = createResolutionNode( a2); + ResolutionNode a1n = createResolutionNode( a1); assertResolveConflict( a2n, a2n, a1n ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java index 0c7b035..69d93d2 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java @@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict; * under the License. */ -import java.util.Collections; - import org.apache.maven.artifact.resolver.ResolutionNode; -import org.apache.maven.repository.legacy.resolver.conflict.NearestConflictResolver; /** * Tests <code>NearestConflictResolver</code>. @@ -52,9 +49,9 @@ public class NearestConflictResolverTest */ public void testDepth() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); + ResolutionNode a1n = createResolutionNode( a1); + ResolutionNode b1n = createResolutionNode( b1); + ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a1n, a1n, a2n ); } @@ -68,9 +65,9 @@ public class NearestConflictResolverTest */ public void testDepthReversed() { - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode b1n = createResolutionNode( b1 ); + ResolutionNode a2n = createResolutionNode( a2, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } @@ -84,8 +81,8 @@ public class NearestConflictResolverTest */ public void testEqual() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } @@ -99,8 +96,8 @@ public class NearestConflictResolverTest */ public void testEqualReversed() { - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode a2n = createResolutionNode( a2); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java index 68d19d6..c98f1e1 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java @@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict; * under the License. */ -import java.util.Collections; - import org.apache.maven.artifact.resolver.ResolutionNode; -import org.apache.maven.repository.legacy.resolver.conflict.NewestConflictResolver; /** * Tests <code>NewestConflictResolver</code>. @@ -52,9 +49,9 @@ public class NewestConflictResolverTest */ public void testDepth() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode b1n = createResolutionNode( b1 ); + ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a2n, a1n, a2n ); } @@ -68,9 +65,9 @@ public class NewestConflictResolverTest */ public void testDepthReversed() { - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode b1n = createResolutionNode( b1 ); + ResolutionNode a2n = createResolutionNode( a2, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } @@ -84,8 +81,8 @@ public class NewestConflictResolverTest */ public void testEqual() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a2n, a1n, a2n ); } @@ -99,8 +96,8 @@ public class NewestConflictResolverTest */ public void testEqualReversed() { - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode a2n = createResolutionNode( a2 ); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java index 6b06d34..cef78f9 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java @@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict; * under the License. */ -import java.util.Collections; - import org.apache.maven.artifact.resolver.ResolutionNode; -import org.apache.maven.repository.legacy.resolver.conflict.OldestConflictResolver; /** * Tests <code>OldestConflictResolver</code>. @@ -52,13 +49,14 @@ public class OldestConflictResolverTest */ public void testDepth() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode b1n = createResolutionNode( b1); + ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a1n, a1n, a2n ); } + /** * Tests that <code>a:1.0</code> wins in the scenario: * <pre> @@ -68,9 +66,9 @@ public class OldestConflictResolverTest */ public void testDepthReversed() { - ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode b1n = createResolutionNode( b1 ); + ResolutionNode a2n = createResolutionNode( a2, b1n ); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } @@ -84,8 +82,8 @@ public class OldestConflictResolverTest */ public void testEqual() { - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); + ResolutionNode a1n = createResolutionNode( a1 ); + ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } @@ -99,8 +97,8 @@ public class OldestConflictResolverTest */ public void testEqualReversed() { - ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); - ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); + ResolutionNode a2n = createResolutionNode( a2); + ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java index dd9a900..2293e21 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java @@ -19,10 +19,6 @@ package org.apache.maven.repository.metadata; * under the License. */ -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -34,6 +30,10 @@ import org.apache.maven.repository.legacy.metadata.ResolutionGroup; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + @Component(role = ArtifactMetadataSource.class) public class TestMetadataSource implements ArtifactMetadataSource @@ -44,7 +44,7 @@ public class TestMetadataSource public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) throws ArtifactMetadataRetrievalException { - Set dependencies = new HashSet(); + Set<Artifact> dependencies = new HashSet<>(); if ( "g".equals( artifact.getArtifactId() ) ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java b/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java index 1962f91..503dcdb 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java @@ -60,7 +60,7 @@ public class DefaultArtifactFilterManager { if ( excludedArtifacts == null ) { - excludedArtifacts = new LinkedHashSet<String>( coreArtifacts ); + excludedArtifacts = new LinkedHashSet<>( coreArtifacts ); } return excludedArtifacts; } @@ -72,7 +72,7 @@ public class DefaultArtifactFilterManager */ public ArtifactFilter getArtifactFilter() { - Set<String> excludes = new LinkedHashSet<String>( getExcludedArtifacts() ); + Set<String> excludes = new LinkedHashSet<>( getExcludedArtifacts() ); for ( ArtifactFilterManagerDelegate delegate : delegates ) { @@ -99,7 +99,7 @@ public class DefaultArtifactFilterManager public Set<String> getCoreArtifactExcludes() { - Set<String> excludes = new LinkedHashSet<String>( coreArtifacts ); + Set<String> excludes = new LinkedHashSet<>( coreArtifacts ); for ( ArtifactFilterManagerDelegate delegate : delegates ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 94e75e0..da17830 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -370,7 +370,7 @@ public class DefaultMaven private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects ) { Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = - new LinkedHashSet<AbstractMavenLifecycleParticipant>(); + new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try @@ -385,7 +385,7 @@ public class DefaultMaven logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); } - Collection<ClassLoader> scannedRealms = new HashSet<ClassLoader>(); + Collection<ClassLoader> scannedRealms = new HashSet<>(); for ( MavenProject project : projects ) { @@ -427,7 +427,7 @@ public class DefaultMaven private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds ) { - Collection<String> notActivatedProfileIds = new LinkedHashSet<String>( activeProfileIds ); + Collection<String> notActivatedProfileIds = new LinkedHashSet<>( activeProfileIds ); for ( MavenProject project : projects ) { @@ -447,8 +447,8 @@ public class DefaultMaven private Map<String, MavenProject> getProjectMap( Collection<MavenProject> projects ) throws DuplicateProjectException { - Map<String, MavenProject> index = new LinkedHashMap<String, MavenProject>(); - Map<String, List<File>> collisions = new LinkedHashMap<String, List<File>>(); + Map<String, MavenProject> index = new LinkedHashMap<>(); + Map<String, List<File>> collisions = new LinkedHashMap<>(); for ( MavenProject project : projects ) { @@ -466,7 +466,7 @@ public class DefaultMaven if ( pomFiles == null ) { - pomFiles = new ArrayList<File>( Arrays.asList( collision.getFile(), project.getFile() ) ); + pomFiles = new ArrayList<>( Arrays.asList( collision.getFile(), project.getFile() ) ); collisions.put( projectId, pomFiles ); } else http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java index fa8be38..be7c97a 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java @@ -91,7 +91,7 @@ public class DefaultProjectDependenciesResolver Set<String> projectIds ) throws ArtifactResolutionException, ArtifactNotFoundException { - Set<Artifact> resolved = new LinkedHashSet<Artifact>(); + Set<Artifact> resolved = new LinkedHashSet<>(); if ( projects == null || projects.isEmpty() ) { @@ -166,7 +166,7 @@ public class DefaultProjectDependenciesResolver catch ( MultipleArtifactsNotFoundException e ) { - Collection<Artifact> missing = new HashSet<Artifact>( e.getMissingArtifacts() ); + Collection<Artifact> missing = new HashSet<>( e.getMissingArtifacts() ); for ( Iterator<Artifact> it = missing.iterator(); it.hasNext(); ) { @@ -192,7 +192,7 @@ public class DefaultProjectDependenciesResolver private Set<String> getIgnorableArtifacts( Collection<? extends MavenProject> projects ) { - Set<String> projectIds = new HashSet<String>( projects.size() * 2 ); + Set<String> projectIds = new HashSet<>( projects.size() * 2 ); for ( MavenProject p : projects ) { @@ -204,7 +204,7 @@ public class DefaultProjectDependenciesResolver private Set<String> getIgnorableArtifacts( Iterable<Artifact> artifactIterable ) { - Set<String> projectIds = new HashSet<String>(); + Set<String> projectIds = new HashSet<>(); for ( Artifact artifact : artifactIterable ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/ReactorReader.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index 252bdd0..7fd89e4 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -67,7 +67,7 @@ class ReactorReader { projectsByGAV = session.getProjectMap(); - projectsByGA = new HashMap<String, List<MavenProject>>( projectsByGAV.size() * 2 ); + projectsByGA = new HashMap<>( projectsByGAV.size() * 2 ); for ( MavenProject project : projectsByGAV.values() ) { String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); @@ -76,14 +76,14 @@ class ReactorReader if ( projects == null ) { - projects = new ArrayList<MavenProject>( 1 ); + projects = new ArrayList<>( 1 ); projectsByGA.put( key, projects ); } projects.add( project ); } - repository = new WorkspaceRepository( "reactor", new HashSet<String>( projectsByGAV.keySet() ) ); + repository = new WorkspaceRepository( "reactor", new HashSet<>( projectsByGAV.keySet() ) ); } // @@ -124,7 +124,7 @@ class ReactorReader return Collections.emptyList(); } - List<String> versions = new ArrayList<String>(); + List<String> versions = new ArrayList<>(); for ( MavenProject project : projects ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java index d7fd88e..86eab4e 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -97,7 +97,7 @@ public class RepositoryUtils result.setFile( artifact.getFile() ); result.setResolved( artifact.getFile() != null ); - List<String> trail = new ArrayList<String>( 1 ); + List<String> trail = new ArrayList<>( 1 ); trail.add( result.getId() ); result.setDependencyTrail( trail ); @@ -112,7 +112,7 @@ public class RepositoryUtils { org.apache.maven.artifact.Artifact artifact = toArtifact( node.getDependency() ); - List<String> nodeTrail = new ArrayList<String>( trail.size() + 1 ); + List<String> nodeTrail = new ArrayList<>( trail.size() + 1 ); nodeTrail.addAll( trail ); nodeTrail.add( artifact.getId() ); @@ -168,7 +168,7 @@ public class RepositoryUtils List<Exclusion> excl = null; if ( exclusions != null ) { - excl = new ArrayList<Exclusion>( exclusions.size() ); + excl = new ArrayList<>( exclusions.size() ); for ( org.apache.maven.model.Exclusion exclusion : exclusions ) { excl.add( toExclusion( exclusion ) ); @@ -185,7 +185,7 @@ public class RepositoryUtils return null; } - List<RemoteRepository> results = new ArrayList<RemoteRepository>( repos.size() ); + List<RemoteRepository> results = new ArrayList<>( repos.size() ); for ( ArtifactRepository repo : repos ) { results.add( toRepo( repo ) ); @@ -310,7 +310,7 @@ public class RepositoryUtils new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); - List<Exclusion> exclusions = new ArrayList<Exclusion>( dependency.getExclusions().size() ); + List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( toExclusion( exclusion ) ); @@ -352,7 +352,7 @@ public class RepositoryUtils public static Collection<Artifact> toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifactsToConvert ) { - List<Artifact> artifacts = new ArrayList<Artifact>(); + List<Artifact> artifacts = new ArrayList<>(); for ( org.apache.maven.artifact.Artifact a : artifactsToConvert ) { artifacts.add( toArtifact( a ) ); http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java index 6be636b..9394132 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java @@ -39,7 +39,7 @@ public class DefaultArtifactHandlerManager @Requirement( role = ArtifactHandler.class ) private Map<String, ArtifactHandler> artifactHandlers; - private Map<String, ArtifactHandler> unmanagedHandlers = new ConcurrentHashMap<String, ArtifactHandler>(); + private Map<String, ArtifactHandler> unmanagedHandlers = new ConcurrentHashMap<>(); public ArtifactHandler getArtifactHandler( String type ) { http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java index 6b18789..839094f 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java @@ -118,7 +118,7 @@ public class DefaultRepositoryRequest { if ( remoteRepositories == null ) { - remoteRepositories = new ArrayList<ArtifactRepository>(); + remoteRepositories = new ArrayList<>(); } return remoteRepositories; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java index e1e5fe3..537fbe5 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java @@ -68,11 +68,7 @@ public abstract class AbstractRepositoryMetadata { updateRepositoryMetadata( localRepository, remoteRepository ); } - catch ( IOException e ) - { - throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); - } - catch ( XmlPullParserException e ) + catch ( IOException | XmlPullParserException e ) { throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java index 050ec47..df17200 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java @@ -59,7 +59,7 @@ public class ArtifactResolutionRequest private ArtifactFilter resolutionFilter; // Needs to go away - private List<ResolutionListener> listeners = new ArrayList<ResolutionListener>(); + private List<ResolutionListener> listeners = new ArrayList<>(); // This is like a filter but overrides all transitive versions private Map<String, Artifact> managedVersionMap; @@ -278,7 +278,7 @@ public class ArtifactResolutionRequest { if ( servers == null ) { - servers = new ArrayList<Server>(); + servers = new ArrayList<>(); } return servers; @@ -295,7 +295,7 @@ public class ArtifactResolutionRequest { if ( mirrors == null ) { - mirrors = new ArrayList<Mirror>(); + mirrors = new ArrayList<>(); } return mirrors; @@ -312,7 +312,7 @@ public class ArtifactResolutionRequest { if ( proxies == null ) { - proxies = new ArrayList<Proxy>(); + proxies = new ArrayList<>(); } return proxies; http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java index 86bfdb6..7795dec 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java @@ -82,7 +82,7 @@ public class ArtifactResolutionResult { if ( artifacts == null ) { - artifacts = new LinkedHashSet<Artifact>(); + artifacts = new LinkedHashSet<>(); } artifacts.add( artifact ); @@ -92,7 +92,7 @@ public class ArtifactResolutionResult { if ( artifacts == null ) { - artifacts = new LinkedHashSet<Artifact>(); + artifacts = new LinkedHashSet<>(); } return artifacts; @@ -107,7 +107,7 @@ public class ArtifactResolutionResult { if ( resolutionNodes == null ) { - resolutionNodes = new LinkedHashSet<ResolutionNode>(); + resolutionNodes = new LinkedHashSet<>(); } return resolutionNodes; @@ -331,7 +331,7 @@ public class ArtifactResolutionResult { if ( l == null ) { - return new ArrayList<T>(); + return new ArrayList<>(); } return l; } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/resolver/DefaultResolutionErrorHandler.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/DefaultResolutionErrorHandler.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/DefaultResolutionErrorHandler.java index a8caa79..178335a 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/DefaultResolutionErrorHandler.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/DefaultResolutionErrorHandler.java @@ -83,7 +83,7 @@ public class DefaultResolutionErrorHandler private static <T> List<T> toList( Collection<T> items ) { - return ( items != null ) ? new ArrayList<T>( items ) : null; + return ( items != null ) ? new ArrayList<>( items ) : null; } } http://git-wip-us.apache.org/repos/asf/maven/blob/7badeb5b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java index ae6c921..5651641 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java @@ -64,7 +64,7 @@ public class ResolutionNode this.artifact = artifact; this.remoteRepositories = remoteRepositories; depth = parent.depth + 1; - parents = new ArrayList<Object>(); + parents = new ArrayList<>(); parents.addAll( parent.parents ); parents.add( parent.getKey() ); this.parent = parent; @@ -86,7 +86,7 @@ public class ResolutionNode { if ( artifacts != null && !artifacts.isEmpty() ) { - children = new ArrayList<ResolutionNode>( artifacts.size() ); + children = new ArrayList<>( artifacts.size() ); for ( Artifact a : artifacts ) { @@ -116,7 +116,7 @@ public class ResolutionNode { List<Artifact> trial = getTrail(); - List<String> ret = new ArrayList<String>( trial.size() ); + List<String> ret = new ArrayList<>( trial.size() ); for ( Artifact artifact : trial ) { @@ -131,7 +131,7 @@ public class ResolutionNode { if ( trail == null ) { - List<Artifact> ids = new LinkedList<Artifact>(); + List<Artifact> ids = new LinkedList<>(); ResolutionNode node = this; while ( node != null ) {