Upgraded to java7 language features

This commit is contained in:
Kristian Rosenvold 2015-03-06 07:12:21 +01:00
parent 40d5087b6b
commit 7badeb5b5b
235 changed files with 941 additions and 1086 deletions

View File

@ -45,15 +45,10 @@ public class GlobalSettingsTest
File globalSettingsFile = new File( basedir, "src/conf/settings.xml" ); File globalSettingsFile = new File( basedir, "src/conf/settings.xml" );
assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() ); assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() );
Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ); try (Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ))
try
{ {
new SettingsXpp3Reader().read( reader ); new SettingsXpp3Reader().read( reader );
} }
finally
{
reader.close();
}
} }
} }

View File

@ -74,7 +74,7 @@ public class ArtifactDescriptorReaderDelegate
} }
} }
Map<String, Object> properties = new LinkedHashMap<String, Object>(); Map<String, Object> properties = new LinkedHashMap<>();
Prerequisites prerequisites = model.getPrerequisites(); Prerequisites prerequisites = model.getPrerequisites();
if ( prerequisites != null ) if ( prerequisites != null )
@ -118,7 +118,7 @@ public class ArtifactDescriptorReaderDelegate
new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
dependency.getVersion(), props, stereotype ); 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() ) for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
{ {
exclusions.add( convert( exclusion ) ); exclusions.add( convert( exclusion ) );
@ -145,7 +145,7 @@ public class ArtifactDescriptorReaderDelegate
if ( downloadUrl != null && downloadUrl.length() > 0 ) if ( downloadUrl != null && downloadUrl.length() > 0 )
{ {
Artifact artifact = result.getArtifact(); Artifact artifact = result.getArtifact();
Map<String, String> props = new HashMap<String, String>( artifact.getProperties() ); Map<String, String> props = new HashMap<>( artifact.getProperties() );
props.put( ArtifactProperties.DOWNLOAD_URL, downloadUrl ); props.put( ArtifactProperties.DOWNLOAD_URL, downloadUrl );
result.setArtifact( artifact.setProperties( props ) ); result.setArtifact( artifact.setProperties( props ) );
} }

View File

@ -239,7 +239,7 @@ public class DefaultArtifactDescriptorReader
{ {
RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
Set<String> visited = new LinkedHashSet<String>(); Set<String> visited = new LinkedHashSet<>();
for ( Artifact a = request.getArtifact();; ) for ( Artifact a = request.getArtifact();; )
{ {
Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( a ); Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( a );

View File

@ -89,11 +89,11 @@ class DefaultModelResolver
this.versionRangeResolver = versionRangeResolver; this.versionRangeResolver = versionRangeResolver;
this.remoteRepositoryManager = remoteRepositoryManager; this.remoteRepositoryManager = remoteRepositoryManager;
this.repositories = repositories; this.repositories = repositories;
List<RemoteRepository> externalRepositories = new ArrayList<RemoteRepository>(); List<RemoteRepository> externalRepositories = new ArrayList<>();
externalRepositories.addAll( repositories ); externalRepositories.addAll( repositories );
this.externalRepositories = Collections.unmodifiableList( externalRepositories ); this.externalRepositories = Collections.unmodifiableList( externalRepositories );
this.repositoryIds = new HashSet<String>(); this.repositoryIds = new HashSet<>();
} }
private DefaultModelResolver( DefaultModelResolver original ) private DefaultModelResolver( DefaultModelResolver original )
@ -104,9 +104,9 @@ class DefaultModelResolver
this.resolver = original.resolver; this.resolver = original.resolver;
this.versionRangeResolver = original.versionRangeResolver; this.versionRangeResolver = original.versionRangeResolver;
this.remoteRepositoryManager = original.remoteRepositoryManager; this.remoteRepositoryManager = original.remoteRepositoryManager;
this.repositories = new ArrayList<RemoteRepository>( original.repositories ); this.repositories = new ArrayList<>( original.repositories );
this.externalRepositories = original.externalRepositories; this.externalRepositories = original.externalRepositories;
this.repositoryIds = new HashSet<String>( original.repositoryIds ); this.repositoryIds = new HashSet<>( original.repositoryIds );
} }
@Override @Override

View File

@ -19,23 +19,13 @@ package org.apache.maven.repository.internal;
* under the License. * under the License.
*/ */
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.IOUtil;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace; import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.SyncContext; import org.eclipse.aether.SyncContext;
@ -64,6 +54,15 @@ import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint; import org.eclipse.aether.version.VersionConstraint;
import org.eclipse.aether.version.VersionScheme; import org.eclipse.aether.version.VersionScheme;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@ -181,7 +180,7 @@ public class DefaultVersionRangeResolver
{ {
Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request ); Map<String, ArtifactRepository> versionIndex = getVersions( session, result, request );
List<Version> versions = new ArrayList<Version>(); List<Version> versions = new ArrayList<>();
for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() ) for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
{ {
try try
@ -211,13 +210,13 @@ public class DefaultVersionRangeResolver
{ {
RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); RequestTrace trace = RequestTrace.newChild( request.getTrace(), request );
Map<String, ArtifactRepository> versionIndex = new HashMap<String, ArtifactRepository>(); Map<String, ArtifactRepository> versionIndex = new HashMap<>();
Metadata metadata = Metadata metadata =
new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(),
MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() ); List<MetadataRequest> metadataRequests = new ArrayList<>( request.getRepositories().size() );
metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) ); metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
@ -274,9 +273,8 @@ public class DefaultVersionRangeResolver
{ {
if ( metadata != null ) if ( metadata != null )
{ {
SyncContext syncContext = syncContextFactory.newInstance( session, true );
try try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
{ {
syncContext.acquire( null, Collections.singleton( metadata ) ); syncContext.acquire( null, Collections.singleton( metadata ) );
@ -288,10 +286,6 @@ public class DefaultVersionRangeResolver
versioning = m.getVersioning(); versioning = m.getVersioning();
} }
} }
finally
{
syncContext.close();
}
} }
} }
catch ( Exception e ) catch ( Exception e )

View File

@ -19,18 +19,6 @@ package org.apache.maven.repository.internal;
* under the License. * under the License.
*/ */
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotVersion; import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
@ -40,8 +28,8 @@ import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositoryCache; import org.eclipse.aether.RepositoryCache;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace; import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.SyncContext; import org.eclipse.aether.SyncContext;
@ -70,6 +58,17 @@ import org.eclipse.aether.spi.log.LoggerFactory;
import org.eclipse.aether.spi.log.NullLoggerFactory; import org.eclipse.aether.spi.log.NullLoggerFactory;
import org.eclipse.aether.util.ConfigUtils; import org.eclipse.aether.util.ConfigUtils;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@ -187,8 +186,8 @@ public class DefaultVersionResolver
{ {
Record record = (Record) obj; Record record = (Record) obj;
result.setVersion( record.version ); result.setVersion( record.version );
result.setRepository( CacheUtils.getRepository( session, request.getRepositories(), record.repoClass, result.setRepository(
record.repoId ) ); CacheUtils.getRepository( session, request.getRepositories(), record.repoClass, record.repoId ) );
return result; return result;
} }
} }
@ -197,15 +196,13 @@ public class DefaultVersionResolver
if ( RELEASE.equals( version ) ) if ( RELEASE.equals( version ) )
{ {
metadata = metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE );
Metadata.Nature.RELEASE );
} }
else if ( LATEST.equals( version ) ) else if ( LATEST.equals( version ) )
{ {
metadata = metadata = new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
Metadata.Nature.RELEASE_OR_SNAPSHOT );
} }
else if ( version.endsWith( SNAPSHOT ) ) else if ( version.endsWith( SNAPSHOT ) )
{ {
@ -233,7 +230,7 @@ public class DefaultVersionResolver
} }
else else
{ {
List<MetadataRequest> metadataReqs = new ArrayList<MetadataRequest>( request.getRepositories().size() ); List<MetadataRequest> metadataReqs = new ArrayList<>( request.getRepositories().size() );
metadataReqs.add( new MetadataRequest( metadata, null, request.getRequestContext() ) ); metadataReqs.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
@ -249,7 +246,7 @@ public class DefaultVersionResolver
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataReqs ); List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataReqs );
Map<String, VersionInfo> infos = new HashMap<String, VersionInfo>(); Map<String, VersionInfo> infos = new HashMap<>();
for ( MetadataResult metadataResult : metadataResults ) for ( MetadataResult metadataResult : metadataResults )
{ {
@ -343,9 +340,8 @@ public class DefaultVersionResolver
{ {
if ( metadata != null ) if ( metadata != null )
{ {
SyncContext syncContext = syncContextFactory.newInstance( session, true );
try try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) )
{ {
syncContext.acquire( null, Collections.singleton( metadata ) ); syncContext.acquire( null, Collections.singleton( metadata ) );
@ -373,16 +369,12 @@ public class DefaultVersionResolver
versioning = repaired; versioning = repaired;
throw new IOException( "Snapshot information corrupted with remote repository data" throw new IOException( "Snapshot information corrupted with remote repository data"
+ ", please verify that no remote repository uses the id '" + repository.getId() + ", please verify that no remote repository uses the id '"
+ "'" ); + repository.getId() + "'" );
} }
} }
} }
} }
finally
{
syncContext.close();
}
} }
} }
catch ( Exception e ) catch ( Exception e )
@ -467,9 +459,8 @@ public class DefaultVersionResolver
VersionInfo srcInfo = infos.get( srcKey ); VersionInfo srcInfo = infos.get( srcKey );
VersionInfo dstInfo = infos.get( dstKey ); VersionInfo dstInfo = infos.get( dstKey );
if ( dstInfo == null if ( dstInfo == null || ( srcInfo != null && dstInfo.isOutdated( srcInfo.timestamp )
|| ( srcInfo != null && dstInfo.isOutdated( srcInfo.timestamp ) && srcInfo.repository != dstInfo.repository ) )
&& srcInfo.repository != dstInfo.repository ) )
{ {
infos.put( dstKey, srcInfo ); infos.put( dstKey, srcInfo );
} }
@ -554,7 +545,7 @@ public class DefaultVersionResolver
version = artifact.getVersion(); version = artifact.getVersion();
localRepo = session.getLocalRepository().getBasedir(); localRepo = session.getLocalRepository().getBasedir();
workspace = CacheUtils.getWorkspace( session ); workspace = CacheUtils.getWorkspace( session );
repositories = new ArrayList<RemoteRepository>( request.getRepositories().size() ); repositories = new ArrayList<>( request.getRepositories().size() );
boolean repoMan = false; boolean repoMan = false;
for ( RemoteRepository repository : request.getRepositories() ) for ( RemoteRepository repository : request.getRepositories() )
{ {
@ -594,10 +585,10 @@ public class DefaultVersionResolver
} }
Key that = (Key) obj; Key that = (Key) obj;
return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && classifier.equals(
&& classifier.equals( that.classifier ) && extension.equals( that.extension ) that.classifier ) && extension.equals( that.extension ) && version.equals( that.version )
&& version.equals( that.version ) && context.equals( that.context ) && context.equals( that.context ) && localRepo.equals( that.localRepo )
&& localRepo.equals( that.localRepo ) && CacheUtils.eq( workspace, that.workspace ) && CacheUtils.eq( workspace, that.workspace )
&& CacheUtils.repositoriesEquals( repositories, that.repositories ); && CacheUtils.repositoriesEquals( repositories, that.repositories );
} }

View File

@ -38,7 +38,7 @@ final class LocalSnapshotMetadata
extends MavenMetadata extends MavenMetadata
{ {
private final Collection<Artifact> artifacts = new ArrayList<Artifact>(); private final Collection<Artifact> artifacts = new ArrayList<>();
private final boolean legacyFormat; private final boolean legacyFormat;
@ -104,7 +104,7 @@ final class LocalSnapshotMetadata
{ {
String lastUpdated = metadata.getVersioning().getLastUpdated(); String lastUpdated = metadata.getVersioning().getLastUpdated();
Map<String, SnapshotVersion> versions = new LinkedHashMap<String, SnapshotVersion>(); Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
for ( Artifact artifact : artifacts ) for ( Artifact artifact : artifacts )
{ {
@ -129,7 +129,7 @@ final class LocalSnapshotMetadata
} }
} }
metadata.getVersioning().setSnapshotVersions( new ArrayList<SnapshotVersion>( versions.values() ) ); metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
} }
artifacts.clear(); artifacts.clear();

View File

@ -46,7 +46,7 @@ class LocalSnapshotMetadataGenerator
{ {
legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" ); legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
snapshots = new LinkedHashMap<Object, LocalSnapshotMetadata>(); snapshots = new LinkedHashMap<>();
} }
public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts ) public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )

View File

@ -67,7 +67,7 @@ public final class MavenAetherModule
@Named( "versions" ) @Named( "versions" )
MetadataGeneratorFactory versions ) MetadataGeneratorFactory versions )
{ {
Set<MetadataGeneratorFactory> factories = new HashSet<MetadataGeneratorFactory>(); Set<MetadataGeneratorFactory> factories = new HashSet<>();
factories.add( snapshot ); factories.add( snapshot );
factories.add( versions ); factories.add( versions );
return Collections.unmodifiableSet( factories ); return Collections.unmodifiableSet( factories );

View File

@ -34,7 +34,7 @@ abstract class MavenSnapshotMetadata
{ {
static final String SNAPSHOT = "SNAPSHOT"; static final String SNAPSHOT = "SNAPSHOT";
protected final Collection<Artifact> artifacts = new ArrayList<Artifact>(); protected final Collection<Artifact> artifacts = new ArrayList<>();
protected final boolean legacyFormat; protected final boolean legacyFormat;

View File

@ -41,7 +41,7 @@ final class RemoteSnapshotMetadata
extends MavenSnapshotMetadata extends MavenSnapshotMetadata
{ {
private final Map<String, SnapshotVersion> versions = new LinkedHashMap<String, SnapshotVersion>(); private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat ) public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat )
{ {
@ -128,7 +128,7 @@ final class RemoteSnapshotMetadata
if ( !legacyFormat ) if ( !legacyFormat )
{ {
metadata.getVersioning().setSnapshotVersions( new ArrayList<SnapshotVersion>( versions.values() ) ); metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );
} }
} }

View File

@ -46,7 +46,7 @@ class RemoteSnapshotMetadataGenerator
{ {
legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" ); legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" );
snapshots = new LinkedHashMap<Object, RemoteSnapshotMetadata>(); snapshots = new LinkedHashMap<>();
/* /*
* NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which

View File

@ -89,9 +89,9 @@ final class VersionsMetadata
versioning.setRelease( recessive.getVersioning().getRelease() ); versioning.setRelease( recessive.getVersioning().getRelease() );
} }
Collection<String> versions = new LinkedHashSet<String>( recessive.getVersioning().getVersions() ); Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
versions.addAll( versioning.getVersions() ); versions.addAll( versioning.getVersions() );
versioning.setVersions( new ArrayList<String>( versions ) ); versioning.setVersions( new ArrayList<>( versions ) );
} }
} }

View File

@ -55,8 +55,8 @@ class VersionsMetadataGenerator
private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas ) private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas )
{ {
versions = new LinkedHashMap<Object, VersionsMetadata>(); versions = new LinkedHashMap<>();
processedVersions = new LinkedHashMap<Object, VersionsMetadata>(); processedVersions = new LinkedHashMap<>();
/* /*
* NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which

View File

@ -36,7 +36,7 @@ public class ConsoleTransferListener
private PrintStream out; private PrintStream out;
private Map<TransferResource, Long> downloads = new ConcurrentHashMap<TransferResource, Long>(); private Map<TransferResource, Long> downloads = new ConcurrentHashMap<>();
private int lastLength; private int lastLength;

View File

@ -109,7 +109,7 @@ public final class ArtifactUtils
public static Map<String, Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts ) public static Map<String, Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts )
{ {
Map<String, Artifact> artifactMap = new LinkedHashMap<String, Artifact>(); Map<String, Artifact> artifactMap = new LinkedHashMap<>();
if ( artifacts != null ) if ( artifacts != null )
{ {
@ -201,7 +201,7 @@ public final class ArtifactUtils
if ( original != null ) if ( original != null )
{ {
copy = new ArrayList<T>(); copy = new ArrayList<>();
if ( !original.isEmpty() ) if ( !original.isEmpty() )
{ {

View File

@ -251,7 +251,7 @@ public class DefaultArtifact
{ {
if ( metadataMap == null ) if ( metadataMap == null )
{ {
metadataMap = new HashMap<Object, ArtifactMetadata>(); metadataMap = new HashMap<>();
} }
ArtifactMetadata m = metadataMap.get( metadata.getKey() ); ArtifactMetadata m = metadataMap.get( metadata.getKey() );

View File

@ -331,9 +331,8 @@ public class ComparableVersion
public String toString() public String toString()
{ {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
for ( Iterator<Item> iter = iterator(); iter.hasNext(); ) for ( Item item : this )
{ {
Item item = iter.next();
if ( buffer.length() > 0 ) if ( buffer.length() > 0 )
{ {
buffer.append( ( item instanceof ListItem ) ? '-' : '.' ); buffer.append( ( item instanceof ListItem ) ? '-' : '.' );
@ -359,7 +358,7 @@ public class ComparableVersion
ListItem list = items; ListItem list = items;
Stack<Item> stack = new Stack<Item>(); Stack<Item> stack = new Stack<>();
stack.push( list ); stack.push( list );
boolean isDigit = false; boolean isDigit = false;

View File

@ -60,7 +60,7 @@ public class VersionRange
if ( restrictions != null ) if ( restrictions != null )
{ {
copiedRestrictions = new ArrayList<Restriction>(); copiedRestrictions = new ArrayList<>();
if ( !restrictions.isEmpty() ) if ( !restrictions.isEmpty() )
{ {
@ -96,7 +96,7 @@ public class VersionRange
return null; return null;
} }
List<Restriction> restrictions = new ArrayList<Restriction>(); List<Restriction> restrictions = new ArrayList<>();
String process = spec; String process = spec;
ArtifactVersion version = null; ArtifactVersion version = null;
ArtifactVersion upperBound = null; ArtifactVersion upperBound = null;
@ -307,7 +307,7 @@ public class VersionRange
private List<Restriction> intersection( List<Restriction> r1, List<Restriction> r2 ) private List<Restriction> intersection( List<Restriction> r1, List<Restriction> r2 )
{ {
List<Restriction> restrictions = new ArrayList<Restriction>( r1.size() + r2.size() ); List<Restriction> restrictions = new ArrayList<>( r1.size() + r2.size() );
Iterator<Restriction> i1 = r1.iterator(); Iterator<Restriction> i1 = r1.iterator();
Iterator<Restriction> i2 = r2.iterator(); Iterator<Restriction> i2 = r2.iterator();
Restriction res1 = i1.next(); Restriction res1 = i1.next();

View File

@ -73,7 +73,7 @@ public final class ArtifactStatus
if ( map == null ) if ( map == null )
{ {
map = new HashMap<String, ArtifactStatus>(); map = new HashMap<>();
} }
map.put( key, this ); map.put( key, this );
} }

View File

@ -59,7 +59,7 @@ public class DefaultArtifactDeployer
@Requirement @Requirement
private LegacySupport legacySupport; private LegacySupport legacySupport;
private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<Object, MergeableMetadata>(); private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<>();
/** /**
* @deprecated we want to use the artifact method only, and ensure artifact.file is set * @deprecated we want to use the artifact method only, and ensure artifact.file is set

View File

@ -204,7 +204,7 @@ public class DefaultRepositoryMetadataManager
// TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata // TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata
// - we'd be much better having a pristine input, and an ongoing metadata for merging instead // - we'd be much better having a pristine input, and an ongoing metadata for merging instead
Map<ArtifactRepository, Metadata> previousMetadata = new HashMap<ArtifactRepository, Metadata>(); Map<ArtifactRepository, Metadata> previousMetadata = new HashMap<>();
ArtifactRepository selected = null; ArtifactRepository selected = null;
for ( ArtifactRepository repository : remoteRepositories ) for ( ArtifactRepository repository : remoteRepositories )
{ {
@ -334,12 +334,7 @@ public class DefaultRepositoryMetadataManager
{ {
throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e ); throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e );
} }
catch ( IOException e ) catch ( IOException | XmlPullParserException e )
{
throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
+ e.getMessage(), e );
}
catch ( XmlPullParserException e )
{ {
throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
+ e.getMessage(), e ); + e.getMessage(), e );

View File

@ -55,7 +55,7 @@ public interface ArtifactResolver
// USED BY MAVEN ASSEMBLY PLUGIN // USED BY MAVEN ASSEMBLY PLUGIN
@Deprecated @Deprecated
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException, ArtifactNotFoundException; throws ArtifactResolutionException, ArtifactNotFoundException;
@ -63,7 +63,7 @@ public interface ArtifactResolver
// USED BY MAVEN ASSEMBLY PLUGIN // USED BY MAVEN ASSEMBLY PLUGIN
@Deprecated @Deprecated
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException; throws ArtifactResolutionException, ArtifactNotFoundException;
@ -77,7 +77,7 @@ public interface ArtifactResolver
@Deprecated @Deprecated
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners ) List<ResolutionListener> listeners )

View File

@ -38,7 +38,7 @@ public class DebugResolutionListener
private String indent = ""; private String indent = "";
private static Set<Artifact> ignoredArtifacts = new HashSet<Artifact>(); private static Set<Artifact> ignoredArtifacts = new HashSet<>();
public DebugResolutionListener( Logger logger ) public DebugResolutionListener( Logger logger )
{ {

View File

@ -260,7 +260,7 @@ public class DefaultArtifactResolver
} }
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
@ -270,7 +270,7 @@ public class DefaultArtifactResolver
} }
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
@ -300,7 +300,7 @@ public class DefaultArtifactResolver
} }
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners ) List<ResolutionListener> listeners )
@ -311,7 +311,7 @@ public class DefaultArtifactResolver
} }
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String,Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ResolutionListener> listeners,
@ -377,7 +377,7 @@ public class DefaultArtifactResolver
if ( listeners == null ) if ( listeners == null )
{ {
listeners = new ArrayList<ResolutionListener>(); listeners = new ArrayList<>();
if ( logger.isDebugEnabled() ) if ( logger.isDebugEnabled() )
{ {
@ -438,11 +438,11 @@ public class DefaultArtifactResolver
} }
else else
{ {
List<Artifact> allArtifacts = new ArrayList<Artifact>(); List<Artifact> allArtifacts = new ArrayList<>();
allArtifacts.addAll( artifacts ); allArtifacts.addAll( artifacts );
allArtifacts.addAll( directArtifacts ); allArtifacts.addAll( directArtifacts );
Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>(); Map<String, Artifact> mergedArtifacts = new LinkedHashMap<>();
for ( Artifact artifact : allArtifacts ) for ( Artifact artifact : allArtifacts )
{ {
String conflictId = artifact.getDependencyConflictId(); String conflictId = artifact.getDependencyConflictId();
@ -452,7 +452,7 @@ public class DefaultArtifactResolver
} }
} }
artifacts = new LinkedHashSet<Artifact>( mergedArtifacts.values() ); artifacts = new LinkedHashSet<>( mergedArtifacts.values() );
} }
collectionRequest = new ArtifactResolutionRequest( request ); collectionRequest = new ArtifactResolutionRequest( request );
@ -530,7 +530,7 @@ public class DefaultArtifactResolver
if ( request.isResolveRoot() ) if ( request.isResolveRoot() )
{ {
// Add the root artifact (as the first artifact to retain logical order of class path!) // Add the root artifact (as the first artifact to retain logical order of class path!)
Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>(); Set<Artifact> allArtifacts = new LinkedHashSet<>();
allArtifacts.add( rootArtifact ); allArtifacts.add( rootArtifact );
allArtifacts.addAll( result.getArtifacts() ); allArtifacts.addAll( result.getArtifacts() );
result.setArtifacts( allArtifacts ); result.setArtifacts( allArtifacts );

View File

@ -38,12 +38,12 @@ public class OrArtifactFilter
public OrArtifactFilter() public OrArtifactFilter()
{ {
this.filters = new LinkedHashSet<ArtifactFilter>(); this.filters = new LinkedHashSet<>();
} }
public OrArtifactFilter( Collection<ArtifactFilter> filters ) public OrArtifactFilter( Collection<ArtifactFilter> filters )
{ {
this.filters = new LinkedHashSet<ArtifactFilter>( filters ); this.filters = new LinkedHashSet<>( filters );
} }
public boolean include( Artifact artifact ) public boolean include( Artifact artifact )

View File

@ -50,13 +50,13 @@ public class DefaultProfileManager
@Requirement @Requirement
private ProfileSelector profileSelector; private ProfileSelector profileSelector;
private List activatedIds = new ArrayList(); private List<String> activatedIds = new ArrayList<>();
private List deactivatedIds = new ArrayList(); private List<String> deactivatedIds = new ArrayList<>();
private List defaultIds = new ArrayList(); private List<String> defaultIds = new ArrayList<>();
private Map profilesById = new LinkedHashMap(); private Map<String, Profile> profilesById = new LinkedHashMap<>();
private Properties requestProperties; private Properties requestProperties;
@ -105,7 +105,7 @@ public class DefaultProfileManager
{ {
String profileId = profile.getId(); String profileId = profile.getId();
Profile existing = (Profile) profilesById.get( profileId ); Profile existing = profilesById.get( profileId );
if ( existing != null ) if ( existing != null )
{ {
logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource()
@ -186,7 +186,7 @@ public class DefaultProfileManager
context.setSystemProperties( System.getProperties() ); context.setSystemProperties( System.getProperties() );
context.setUserProperties( requestProperties ); context.setUserProperties( requestProperties );
final List<ProfileActivationException> errors = new ArrayList<ProfileActivationException>(); final List<ProfileActivationException> errors = new ArrayList<>();
List<Profile> profiles = List<Profile> profiles =
profileSelector.getActiveProfiles( profilesById.values(), context, new ModelProblemCollector() profileSelector.getActiveProfiles( profilesById.values(), context, new ModelProblemCollector()
@ -230,12 +230,12 @@ public class DefaultProfileManager
} }
} }
public List getExplicitlyActivatedIds() public List<String> getExplicitlyActivatedIds()
{ {
return activatedIds; return activatedIds;
} }
public List getExplicitlyDeactivatedIds() public List<String> getExplicitlyDeactivatedIds()
{ {
return deactivatedIds; return deactivatedIds;
} }

View File

@ -47,9 +47,9 @@ public interface ProfileManager
Map getProfilesById(); Map getProfilesById();
List getExplicitlyActivatedIds(); List<String> getExplicitlyActivatedIds();
List getExplicitlyDeactivatedIds(); List<String> getExplicitlyDeactivatedIds();
List getIdsActivatedByDefault(); List getIdsActivatedByDefault();

View File

@ -151,7 +151,7 @@ public class DefaultMavenProjectBuilder
{ {
boolean normalized = false; boolean normalized = false;
List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>( repositories.size() ); List<ArtifactRepository> repos = new ArrayList<>( repositories.size() );
for ( Object repository : repositories ) for ( Object repository : repositories )
{ {

View File

@ -63,7 +63,7 @@ public final class ModelUtils
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
{ {
parentPlugins = new ArrayList<Plugin>( parentPlugins ); parentPlugins = new ArrayList<>( parentPlugins );
// If we're processing this merge as an inheritance, we have to build up a list of // If we're processing this merge as an inheritance, we have to build up a list of
// plugins that were considered for inheritance. // plugins that were considered for inheritance.
@ -82,7 +82,7 @@ public final class ModelUtils
} }
} }
List<Plugin> assembledPlugins = new ArrayList<Plugin>(); List<Plugin> assembledPlugins = new ArrayList<>();
Map<String, Plugin> childPlugins = childContainer.getPluginsAsMap(); Map<String, Plugin> childPlugins = childContainer.getPluginsAsMap();
@ -134,16 +134,16 @@ public final class ModelUtils
public static List<Plugin> orderAfterMerge( List<Plugin> merged, List<Plugin> highPrioritySource, public static List<Plugin> orderAfterMerge( List<Plugin> merged, List<Plugin> highPrioritySource,
List<Plugin> lowPrioritySource ) List<Plugin> lowPrioritySource )
{ {
List<Plugin> results = new ArrayList<Plugin>(); List<Plugin> results = new ArrayList<>();
if ( !merged.isEmpty() ) if ( !merged.isEmpty() )
{ {
results.addAll( merged ); results.addAll( merged );
} }
List<Plugin> missingFromResults = new ArrayList<Plugin>(); List<Plugin> missingFromResults = new ArrayList<>();
List<List<Plugin>> sources = new ArrayList<List<Plugin>>(); List<List<Plugin>> sources = new ArrayList<>();
sources.add( highPrioritySource ); sources.add( highPrioritySource );
sources.add( lowPrioritySource ); sources.add( lowPrioritySource );
@ -222,9 +222,9 @@ public final class ModelUtils
if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() ) if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() )
{ {
List<PluginExecution> mergedExecutions = new ArrayList<PluginExecution>(); List<PluginExecution> mergedExecutions = new ArrayList<>();
Map<String, PluginExecution> assembledExecutions = new TreeMap<String, PluginExecution>(); Map<String, PluginExecution> assembledExecutions = new TreeMap<>();
Map<String, PluginExecution> childExecutions = child.getExecutionsAsMap(); Map<String, PluginExecution> childExecutions = child.getExecutionsAsMap();
@ -282,7 +282,7 @@ public final class ModelUtils
List<String> parentGoals = parent.getGoals(); List<String> parentGoals = parent.getGoals();
List<String> childGoals = child.getGoals(); List<String> childGoals = child.getGoals();
List<String> goals = new ArrayList<String>(); List<String> goals = new ArrayList<>();
if ( ( childGoals != null ) && !childGoals.isEmpty() ) if ( ( childGoals != null ) && !childGoals.isEmpty() )
{ {
@ -312,7 +312,7 @@ public final class ModelUtils
public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive ) public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive )
{ {
List<Repository> repositories = new ArrayList<Repository>(); List<Repository> repositories = new ArrayList<>();
for ( Repository repository : dominant ) for ( Repository repository : dominant )
{ {
@ -343,7 +343,7 @@ public final class ModelUtils
private static List<Dependency> mergeDependencyList( List<Dependency> child, List<Dependency> parent ) private static List<Dependency> mergeDependencyList( List<Dependency> child, List<Dependency> parent )
{ {
Map<String, Dependency> depsMap = new LinkedHashMap<String, Dependency>(); Map<String, Dependency> depsMap = new LinkedHashMap<>();
if ( parent != null ) if ( parent != null )
{ {
@ -361,7 +361,7 @@ public final class ModelUtils
} }
} }
return new ArrayList<Dependency>( depsMap.values() ); return new ArrayList<>( depsMap.values() );
} }
} }

View File

@ -51,7 +51,7 @@ public final class ProjectUtils
throws InvalidRepositoryException throws InvalidRepositoryException
{ {
List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>(); List<ArtifactRepository> remoteRepositories = new ArrayList<>();
for ( Repository r : repositories ) for ( Repository r : repositories )
{ {

View File

@ -20,8 +20,6 @@ package org.apache.maven.project.inheritance;
*/ */
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -323,7 +321,7 @@ public class DefaultModelInheritanceAssembler
{ {
List<Dependency> childDeps = childDepMgmt.getDependencies(); List<Dependency> childDeps = childDepMgmt.getDependencies();
Map<String, Dependency> mappedChildDeps = new TreeMap<String, Dependency>(); Map<String, Dependency> mappedChildDeps = new TreeMap<>();
for ( Dependency dep : childDeps ) for ( Dependency dep : childDeps )
{ {
mappedChildDeps.put( dep.getManagementKey(), dep ); mappedChildDeps.put( dep.getManagementKey(), dep );
@ -377,7 +375,7 @@ public class DefaultModelInheritanceAssembler
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
{ {
Map<String, ReportPlugin> assembledPlugins = new TreeMap<String, ReportPlugin>(); Map<String, ReportPlugin> assembledPlugins = new TreeMap<>();
Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap(); Map<String, ReportPlugin> childPlugins = child.getReportPluginsAsMap();
@ -416,7 +414,7 @@ public class DefaultModelInheritanceAssembler
} }
} }
child.setPlugins( new ArrayList<ReportPlugin>( assembledPlugins.values() ) ); child.setPlugins( new ArrayList<>( assembledPlugins.values() ) );
child.flushReportPluginMap(); child.flushReportPluginMap();
} }
@ -427,7 +425,7 @@ public class DefaultModelInheritanceAssembler
List<String> parentReports = parent.getReports(); List<String> parentReports = parent.getReports();
List<String> childReports = child.getReports(); List<String> childReports = child.getReports();
List<String> reports = new ArrayList<String>(); List<String> reports = new ArrayList<>();
if ( ( childReports != null ) && !childReports.isEmpty() ) if ( ( childReports != null ) && !childReports.isEmpty() )
{ {
@ -479,7 +477,7 @@ public class DefaultModelInheritanceAssembler
if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
{ {
Map<String, ReportSet> assembledReportSets = new TreeMap<String, ReportSet>(); Map<String, ReportSet> assembledReportSets = new TreeMap<>();
Map<String, ReportSet> childReportSets = child.getReportSetsAsMap(); Map<String, ReportSet> childReportSets = child.getReportSetsAsMap();
@ -518,7 +516,7 @@ public class DefaultModelInheritanceAssembler
} }
} }
child.setReportSets( new ArrayList<ReportSet>( assembledReportSets.values() ) ); child.setReportSets( new ArrayList<>( assembledReportSets.values() ) );
child.flushReportSetMap(); child.flushReportSetMap();
} }
@ -529,7 +527,7 @@ public class DefaultModelInheritanceAssembler
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
private void assembleDependencyInheritance( Model child, Model parent ) private void assembleDependencyInheritance( Model child, Model parent )
{ {
Map<String, Dependency> depsMap = new LinkedHashMap<String, Dependency>(); Map<String, Dependency> depsMap = new LinkedHashMap<>();
List<Dependency> deps = parent.getDependencies(); List<Dependency> deps = parent.getDependencies();
@ -551,7 +549,7 @@ public class DefaultModelInheritanceAssembler
} }
} }
child.setDependencies( new ArrayList<Dependency>( depsMap.values() ) ); child.setDependencies( new ArrayList<>( depsMap.values() ) );
} }
private void assembleBuildInheritance( Model child, Model parent ) private void assembleBuildInheritance( Model child, Model parent )
@ -694,7 +692,7 @@ public class DefaultModelInheritanceAssembler
// TODO: Move this to plexus-utils' PathTool. // TODO: Move this to plexus-utils' PathTool.
private static String resolvePath( String uncleanPath ) private static String resolvePath( String uncleanPath )
{ {
LinkedList<String> pathElements = new LinkedList<String>(); LinkedList<String> pathElements = new LinkedList<>();
StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" ); StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" );
@ -702,26 +700,26 @@ public class DefaultModelInheritanceAssembler
{ {
String token = tokenizer.nextToken(); String token = tokenizer.nextToken();
if ( token.equals( "" ) ) switch ( token )
{ {
// Empty path entry ("...//.."), remove. case "":
} // Empty path entry ("...//.."), remove.
else if ( token.equals( ".." ) ) break;
{ case "..":
if ( pathElements.isEmpty() ) if ( pathElements.isEmpty() )
{ {
// FIXME: somehow report to the user // FIXME: somehow report to the user
// that there are too many '..' elements. // that there are too many '..' elements.
// For now, ignore the extra '..'. // For now, ignore the extra '..'.
} }
else else
{ {
pathElements.removeLast(); pathElements.removeLast();
} }
} break;
else default:
{ pathElements.addLast( token );
pathElements.addLast( token ); break;
} }
} }

View File

@ -71,7 +71,7 @@ public abstract class AbstractStringBasedModelInterpolator
static static
{ {
List<String> translatedPrefixes = new ArrayList<String>(); List<String> translatedPrefixes = new ArrayList<>();
// MNG-1927, MNG-2124, MNG-3355: // MNG-1927, MNG-2124, MNG-3355:
// If the build section is present and the project directory is non-null, we should make // If the build section is present and the project directory is non-null, we should make
@ -168,12 +168,7 @@ public abstract class AbstractStringBasedModelInterpolator
{ {
model = modelReader.read( sReader ); model = modelReader.read( sReader );
} }
catch ( IOException e ) catch ( IOException | XmlPullParserException e )
{
throw new ModelInterpolationException(
"Cannot read project model from interpolating filter of serialized version.", e );
}
catch ( XmlPullParserException e )
{ {
throw new ModelInterpolationException( throw new ModelInterpolationException(
"Cannot read project model from interpolating filter of serialized version.", e ); "Cannot read project model from interpolating filter of serialized version.", e );
@ -253,7 +248,7 @@ public abstract class AbstractStringBasedModelInterpolator
} }
}, PROJECT_PREFIXES, false ); }, PROJECT_PREFIXES, false );
List<ValueSource> valueSources = new ArrayList<ValueSource>( 9 ); List<ValueSource> valueSources = new ArrayList<>( 9 );
// NOTE: Order counts here! // NOTE: Order counts here!
valueSources.add( basedirValueSource ); valueSources.add( basedirValueSource );

View File

@ -47,8 +47,8 @@ public class StringSearchModelInterpolator
extends AbstractStringBasedModelInterpolator extends AbstractStringBasedModelInterpolator
{ {
private static final Map<Class<?>, Field[]> fieldsByClass = new WeakHashMap<Class<?>, Field[]>(); private static final Map<Class<?>, Field[]> fieldsByClass = new WeakHashMap<>();
private static final Map<Class<?>, Boolean> fieldIsPrimitiveByClass = new WeakHashMap<Class<?>, Boolean>(); private static final Map<Class<?>, Boolean> fieldIsPrimitiveByClass = new WeakHashMap<>();
public StringSearchModelInterpolator() public StringSearchModelInterpolator()
{ {
@ -119,7 +119,7 @@ public class StringSearchModelInterpolator
this.postProcessors = postProcessors; this.postProcessors = postProcessors;
this.debugEnabled = debugEnabled; this.debugEnabled = debugEnabled;
this.interpolationTargets = new LinkedList<Object>(); this.interpolationTargets = new LinkedList<>();
interpolationTargets.add( target ); interpolationTargets.add( target );
this.modelInterpolator = modelInterpolator; this.modelInterpolator = modelInterpolator;
@ -199,7 +199,7 @@ public class StringSearchModelInterpolator
Collection<Object> c = (Collection<Object>) field.get( target ); Collection<Object> c = (Collection<Object>) field.get( target );
if ( c != null && !c.isEmpty() ) if ( c != null && !c.isEmpty() )
{ {
List<Object> originalValues = new ArrayList<Object>( c ); List<Object> originalValues = new ArrayList<>( c );
try try
{ {
c.clear(); c.clear();
@ -326,12 +326,7 @@ public class StringSearchModelInterpolator
} }
} }
} }
catch ( IllegalArgumentException e ) catch ( IllegalArgumentException | IllegalAccessException e )
{
throw new ModelInterpolationException(
"Failed to interpolate field: " + field + " on class: " + cls.getName(), e );
}
catch ( IllegalAccessException e )
{ {
throw new ModelInterpolationException( throw new ModelInterpolationException(
"Failed to interpolate field: " + field + " on class: " + cls.getName(), e ); "Failed to interpolate field: " + field + " on class: " + cls.getName(), e );

View File

@ -65,7 +65,7 @@ public class DefaultPathTranslator
if ( build.getFilters() != null ) if ( build.getFilters() != null )
{ {
List<String> filters = new ArrayList<String>(); List<String> filters = new ArrayList<>();
for ( String filter : build.getFilters() ) for ( String filter : build.getFilters() )
{ {
filters.add( alignToBaseDirectory( filter, basedir ) ); filters.add( alignToBaseDirectory( filter, basedir ) );
@ -203,7 +203,7 @@ public class DefaultPathTranslator
if ( build.getFilters() != null ) if ( build.getFilters() != null )
{ {
List<String> filters = new ArrayList<String>(); List<String> filters = new ArrayList<>();
for ( String filter : build.getFilters() ) for ( String filter : build.getFilters() )
{ {
filters.add( unalignFromBaseDirectory( filter, basedir ) ); filters.add( unalignFromBaseDirectory( filter, basedir ) );

View File

@ -37,7 +37,7 @@ public class ModelValidationResult
public ModelValidationResult() public ModelValidationResult()
{ {
messages = new ArrayList<String>(); messages = new ArrayList<>();
} }
public int getMessageCount() public int getMessageCount()

View File

@ -45,7 +45,7 @@ public class MetadataGraph
public MetadataGraph() public MetadataGraph()
{ {
nodes = new ArrayList<MetadataGraphNode>( 64 ); nodes = new ArrayList<>( 64 );
} }
public void addNode( MetadataGraphNode node ) public void addNode( MetadataGraphNode node )

View File

@ -41,8 +41,8 @@ public class MetadataGraphNode
public MetadataGraphNode() public MetadataGraphNode()
{ {
inNodes = new ArrayList<MetadataGraphNode>( 4 ); inNodes = new ArrayList<>( 4 );
exNodes = new ArrayList<MetadataGraphNode>( 8 ); exNodes = new ArrayList<>( 8 );
} }
public MetadataGraphNode( MavenArtifactMetadata metadata ) public MetadataGraphNode( MavenArtifactMetadata metadata )

View File

@ -85,7 +85,7 @@ public class MetadataResolutionResult
{ {
if ( artifacts == null ) if ( artifacts == null )
{ {
artifacts = new LinkedHashSet<Artifact>(); artifacts = new LinkedHashSet<>();
} }
artifacts.add( artifact ); artifacts.add( artifact );
@ -100,7 +100,7 @@ public class MetadataResolutionResult
{ {
if ( requestedArtifacts == null ) if ( requestedArtifacts == null )
{ {
requestedArtifacts = new LinkedHashSet<Artifact>(); requestedArtifacts = new LinkedHashSet<>();
} }
requestedArtifacts.add( artifact ); requestedArtifacts.add( artifact );
@ -318,7 +318,7 @@ public class MetadataResolutionResult
{ {
if ( l == null ) if ( l == null )
{ {
return new ArrayList<T>(); return new ArrayList<>();
} }
return l; return l;
} }

View File

@ -569,9 +569,9 @@ public class DefaultWagonManager
wagon.addTransferListener( downloadMonitor ); 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 // TODO: configure these on the repository
for ( int i = 0; i < CHECKSUM_IDS.length; i++ ) 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] ) ); checksums.put( CHECKSUM_IDS[i], addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i] ) );
} }
List<File> temporaryFiles = new ArrayList<File>(); List<File> temporaryFiles = new ArrayList<>();
try try
{ {

View File

@ -158,7 +158,7 @@ public class LegacyRepositorySystem
if ( !d.getExclusions().isEmpty() ) if ( !d.getExclusions().isEmpty() )
{ {
List<String> exclusions = new ArrayList<String>(); List<String> exclusions = new ArrayList<>();
for ( Exclusion exclusion : d.getExclusions() ) for ( Exclusion exclusion : d.getExclusions() )
{ {
@ -377,7 +377,7 @@ public class LegacyRepositorySystem
return null; return null;
} }
Map<String, List<ArtifactRepository>> reposByKey = new LinkedHashMap<String, List<ArtifactRepository>>(); Map<String, List<ArtifactRepository>> reposByKey = new LinkedHashMap<>();
for ( ArtifactRepository repository : repositories ) for ( ArtifactRepository repository : repositories )
{ {
@ -387,21 +387,21 @@ public class LegacyRepositorySystem
if ( aliasedRepos == null ) if ( aliasedRepos == null )
{ {
aliasedRepos = new ArrayList<ArtifactRepository>(); aliasedRepos = new ArrayList<>();
reposByKey.put( key, aliasedRepos ); reposByKey.put( key, aliasedRepos );
} }
aliasedRepos.add( repository ); aliasedRepos.add( repository );
} }
List<ArtifactRepository> effectiveRepositories = new ArrayList<ArtifactRepository>(); List<ArtifactRepository> effectiveRepositories = new ArrayList<>();
for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() ) for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() )
{ {
List<ArtifactRepository> mirroredRepos = new ArrayList<ArtifactRepository>(); List<ArtifactRepository> mirroredRepos = new ArrayList<>();
List<ArtifactRepositoryPolicy> releasePolicies = List<ArtifactRepositoryPolicy> releasePolicies =
new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() ); new ArrayList<>( aliasedRepos.size() );
for ( ArtifactRepository aliasedRepo : aliasedRepos ) for ( ArtifactRepository aliasedRepo : aliasedRepos )
{ {
@ -412,7 +412,7 @@ public class LegacyRepositorySystem
ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies ); ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies );
List<ArtifactRepositoryPolicy> snapshotPolicies = List<ArtifactRepositoryPolicy> snapshotPolicies =
new ArrayList<ArtifactRepositoryPolicy>( aliasedRepos.size() ); new ArrayList<>( aliasedRepos.size() );
for ( ArtifactRepository aliasedRepo : aliasedRepos ) for ( ArtifactRepository aliasedRepo : aliasedRepos )
{ {
@ -532,7 +532,7 @@ public class LegacyRepositorySystem
{ {
if ( repositories != null ) if ( repositories != null )
{ {
Map<String, Server> serversById = new HashMap<String, Server>(); Map<String, Server> serversById = new HashMap<>();
if ( servers != null ) if ( servers != null )
{ {

View File

@ -55,8 +55,8 @@ public class TransferListenerAdapter
private TransferListenerAdapter( ArtifactTransferListener listener ) private TransferListenerAdapter( ArtifactTransferListener listener )
{ {
this.listener = listener; this.listener = listener;
this.artifacts = new IdentityHashMap<Resource, ArtifactTransferResource>(); this.artifacts = new IdentityHashMap<>();
this.transfers = new IdentityHashMap<Resource, Long>(); this.transfers = new IdentityHashMap<>();
} }
public void debug( String message ) public void debug( String message )

View File

@ -87,7 +87,7 @@ public class DefaultLegacyArtifactCollector
} }
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String, Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ResolutionListener> listeners,
@ -102,7 +102,7 @@ public class DefaultLegacyArtifactCollector
} }
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactResolutionRequest repositoryRequest, Map<String, Artifact> managedVersions, ArtifactResolutionRequest repositoryRequest,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers ) List<ConflictResolver> conflictResolvers )
@ -116,7 +116,7 @@ public class DefaultLegacyArtifactCollector
conflictResolvers = Collections.singletonList( defaultConflictResolver ); 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() ); ResolutionNode root = new ResolutionNode( originatingArtifact, repositoryRequest.getRemoteRepositories() );
@ -160,7 +160,7 @@ public class DefaultLegacyArtifactCollector
result.addErrorArtifactException( e ); result.addErrorArtifactException( e );
} }
Set<ResolutionNode> set = new LinkedHashSet<ResolutionNode>(); Set<ResolutionNode> set = new LinkedHashSet<>();
for ( List<ResolutionNode> nodes : resolvedArtifacts.values() ) for ( List<ResolutionNode> nodes : resolvedArtifacts.values() )
{ {
@ -206,7 +206,7 @@ public class DefaultLegacyArtifactCollector
* @param originatingArtifact artifact we are processing * @param originatingArtifact artifact we are processing
* @param managedVersions original managed versions * @param managedVersions original managed versions
*/ */
private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map managedVersions ) private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map<String,Artifact> managedVersions )
{ {
ManagedVersionMap versionMap; ManagedVersionMap versionMap;
if ( ( managedVersions != null ) && ( managedVersions instanceof ManagedVersionMap ) ) if ( ( managedVersions != null ) && ( managedVersions instanceof ManagedVersionMap ) )
@ -406,7 +406,7 @@ public class DefaultLegacyArtifactCollector
} }
else else
{ {
previousNodes = new ArrayList<ResolutionNode>(); previousNodes = new ArrayList<>();
resolvedArtifacts.put( key, previousNodes ); resolvedArtifacts.put( key, previousNodes );
} }
@ -774,7 +774,7 @@ public class DefaultLegacyArtifactCollector
} }
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map<String, Artifact> managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners ) List<ResolutionListener> listeners )

View File

@ -42,19 +42,19 @@ import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
public interface LegacyArtifactCollector 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, ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source,
ArtifactFilter filter, List<ResolutionListener> listeners, ArtifactFilter filter, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers ); 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, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers ); List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers );
// used by maven-dependency-tree and maven-dependency-plugin // used by maven-dependency-tree and maven-dependency-plugin
@Deprecated @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, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners ); List<ResolutionListener> listeners );

View File

@ -62,7 +62,7 @@ implements Iterable<ArtifactMetadata>
{ {
if ( classpath == null ) if ( classpath == null )
{ {
classpath = new ArrayList<ArtifactMetadata>( 16 ); classpath = new ArrayList<>( 16 );
} }
classpath.add( md ); classpath.add( md );

View File

@ -101,7 +101,7 @@ public class DefaultClasspathTransformation
this.cpc = cpc; this.cpc = cpc;
this.graph = cleanGraph; this.graph = cleanGraph;
visited = new ArrayList<MetadataGraphVertex>( cleanGraph.getVertices().size() ); visited = new ArrayList<>( cleanGraph.getVertices().size() );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@ -153,10 +153,10 @@ public class DefaultGraphConflictResolver
return g; return g;
} }
List<MetadataGraphVertex> visited = new ArrayList<MetadataGraphVertex>( g.getVertices().size() ); List<MetadataGraphVertex> visited = new ArrayList<>( g.getVertices().size() );
visit( g.getEntry(), visited, g ); 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 // collect drop list
for ( MetadataGraphVertex v : g.getVertices() ) for ( MetadataGraphVertex v : g.getVertices() )

View File

@ -244,7 +244,7 @@ public class MetadataGraph
{ {
if ( vertices == null ) if ( vertices == null )
{ {
vertices = new TreeSet<MetadataGraphVertex>(); vertices = new TreeSet<>();
} }
} }
private void checkEdges() private void checkEdges()
@ -262,11 +262,11 @@ public class MetadataGraph
{ {
if ( incidentEdges == null ) if ( incidentEdges == null )
{ {
incidentEdges = new HashMap<MetadataGraphVertex, List<MetadataGraphEdge>>( nEdges ); incidentEdges = new HashMap<>( nEdges );
} }
if ( excidentEdges == null ) if ( excidentEdges == null )
{ {
excidentEdges = new HashMap<MetadataGraphVertex, List<MetadataGraphEdge>>( nEdges ); excidentEdges = new HashMap<>( nEdges );
} }
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -300,7 +300,7 @@ public class MetadataGraph
return null; return null;
} }
List<MetadataGraphEdge> res = new ArrayList<MetadataGraphEdge>( edges.size() ); List<MetadataGraphEdge> res = new ArrayList<>( edges.size() );
for ( MetadataGraphEdge e : edges ) for ( MetadataGraphEdge e : edges )
{ {
@ -333,7 +333,7 @@ public class MetadataGraph
List<MetadataGraphEdge> exList = excidentEdges.get( vFrom ); List<MetadataGraphEdge> exList = excidentEdges.get( vFrom );
if ( exList == null ) if ( exList == null )
{ {
exList = new ArrayList<MetadataGraphEdge>(); exList = new ArrayList<>();
excidentEdges.put( vFrom, exList ); excidentEdges.put( vFrom, exList );
} }
@ -345,7 +345,7 @@ public class MetadataGraph
List<MetadataGraphEdge> inList = incidentEdges.get( vTo ); List<MetadataGraphEdge> inList = incidentEdges.get( vTo );
if ( inList == null ) if ( inList == null )
{ {
inList = new ArrayList<MetadataGraphEdge>(); inList = new ArrayList<>();
incidentEdges.put( vTo, inList ); incidentEdges.put( vTo, inList );
} }

View File

@ -43,14 +43,14 @@ public class ExpressionDocumenter
private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/"; 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() public static Map load()
throws ExpressionDocumentationException throws ExpressionDocumentationException
{ {
if ( expressionDocumentation == null ) if ( expressionDocumentation == null )
{ {
expressionDocumentation = new HashMap(); expressionDocumentation = new HashMap<>();
ClassLoader docLoader = initializeDocLoader(); ClassLoader docLoader = initializeDocLoader();
@ -64,7 +64,7 @@ public class ExpressionDocumenter
if ( docStream != null ) if ( docStream != null )
{ {
Map doco = parseExpressionDocumentation( docStream ); Map<String, Expression> doco = parseExpressionDocumentation( docStream );
expressionDocumentation.putAll( doco ); expressionDocumentation.putAll( doco );
} }
@ -114,7 +114,7 @@ public class ExpressionDocumenter
* @throws IOException * @throws IOException
* @throws XmlPullParserException * @throws XmlPullParserException
*/ */
private static Map parseExpressionDocumentation( InputStream docStream ) private static Map<String, Expression> parseExpressionDocumentation( InputStream docStream )
throws IOException, XmlPullParserException throws IOException, XmlPullParserException
{ {
Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) ); Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) );
@ -125,7 +125,7 @@ public class ExpressionDocumenter
List expressions = documentation.getExpressions(); List expressions = documentation.getExpressions();
Map bySyntax = new HashMap(); Map<String, Expression> bySyntax = new HashMap<>();
if ( expressions != null && !expressions.isEmpty() ) if ( expressions != null && !expressions.isEmpty() )
{ {

View File

@ -236,7 +236,7 @@ public abstract class AbstractArtifactComponentTestCase
protected List<ArtifactRepository> remoteRepositories() protected List<ArtifactRepository> remoteRepositories()
throws Exception throws Exception
{ {
List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>(); List<ArtifactRepository> remoteRepositories = new ArrayList<>();
remoteRepositories.add( remoteRepository() ); remoteRepositories.add( remoteRepository() );

View File

@ -64,7 +64,7 @@ public class ArtifactUtilsTest
public void testArtifactMapByVersionlessIdOrdering() public void testArtifactMapByVersionlessIdOrdering()
throws Exception throws Exception
{ {
List<Artifact> list = new ArrayList<Artifact>(); List<Artifact> list = new ArrayList<>();
list.add( newArtifact( "b" ) ); list.add( newArtifact( "b" ) );
list.add( newArtifact( "a" ) ); list.add( newArtifact( "a" ) );
list.add( newArtifact( "c" ) ); list.add( newArtifact( "c" ) );
@ -73,7 +73,7 @@ public class ArtifactUtilsTest
Map<String, Artifact> map = ArtifactUtils.artifactMapByVersionlessId( list ); Map<String, Artifact> map = ArtifactUtils.artifactMapByVersionlessId( list );
assertNotNull( map ); assertNotNull( map );
assertEquals( list, new ArrayList<Artifact>( map.values() ) ); assertEquals( list, new ArrayList<>( map.values() ) );
} }
} }

View File

@ -41,7 +41,7 @@ public class TestMetadataSource
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
Set dependencies = new HashSet(); Set<Artifact> dependencies = new HashSet<>();
if ( "g".equals( artifact.getArtifactId() ) ) if ( "g".equals( artifact.getArtifactId() ) )
{ {

View File

@ -44,7 +44,7 @@ public class ArtifactResolutionExceptionTest
String type = "jar"; String type = "jar";
String classifier = "aClassifier"; String classifier = "aClassifier";
String downloadUrl = "http://somewhere.com/download"; String downloadUrl = "http://somewhere.com/download";
List path = Arrays.asList( "dependency1", "dependency2" ); List<String> path = Arrays.asList( "dependency1", "dependency2" );
String expected = String expected =
"Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS "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://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS

View File

@ -35,7 +35,6 @@ import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; 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. // 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 // 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" ); Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" );
deleteLocalArtifact( l ); deleteLocalArtifact( l );
List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>(); List<ArtifactRepository> repositories = new ArrayList<>();
repositories.add( remoteRepository() ); repositories.add( remoteRepository() );
repositories.add( badRemoteRepository() ); repositories.add( badRemoteRepository() );
@ -196,7 +195,7 @@ public class ArtifactResolverTest
List<ArtifactRepository> remoteRepositories ) List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
Set dependencies = new HashSet(); Set<Artifact> dependencies = new HashSet<>();
return new ResolutionGroup( artifact, dependencies, remoteRepositories ); return new ResolutionGroup( artifact, dependencies, remoteRepositories );
} }
@ -233,7 +232,7 @@ public class ArtifactResolverTest
ArtifactResolutionResult result = null; ArtifactResolutionResult result = null;
Set set = new LinkedHashSet(); Set<Artifact> set = new LinkedHashSet<>();
set.add( n ); set.add( n );
set.add( m ); set.add( m );
@ -247,7 +246,7 @@ public class ArtifactResolverTest
assertEquals( "m should be second", m, i.next() ); assertEquals( "m should be second", m, i.next() );
// inverse order // inverse order
set = new LinkedHashSet(); set = new LinkedHashSet<>();
set.add( m ); set.add( m );
set.add( n ); set.add( n );

View File

@ -28,7 +28,7 @@ public class TestTransferListener
extends AbstractTransferListener extends AbstractTransferListener
{ {
private final List<String> transfers = new ArrayList<String>(); private final List<String> transfers = new ArrayList<>();
public List<String> getTransfers() public List<String> getTransfers()
{ {

View File

@ -53,7 +53,7 @@ public class TestFileManager
public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); 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; private final String baseFilename;

View File

@ -46,7 +46,7 @@ public class ClasspathArtifactResolver
Collection<? extends ArtifactRequest> requests ) Collection<? extends ArtifactRequest> requests )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
List<ArtifactResult> results = new ArrayList<ArtifactResult>(); List<ArtifactResult> results = new ArrayList<>();
for ( ArtifactRequest request : requests ) for ( ArtifactRequest request : requests )
{ {

View File

@ -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 // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
if ( "JAR".equals( packaging ) ) if ( "JAR".equals( packaging ) )
{ {
plugins = new LinkedHashSet<Plugin>(); plugins = new LinkedHashSet<>();
plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );

View File

@ -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 // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
if ( "JAR".equals( packaging ) ) if ( "JAR".equals( packaging ) )
{ {
plugins = new LinkedHashSet<Plugin>(); plugins = new LinkedHashSet<>();
plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );

View File

@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -20,7 +20,6 @@ package org.apache.maven.project;
*/ */
import java.io.File; import java.io.File;
import java.util.Iterator;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.RepositorySystem;

View File

@ -19,7 +19,6 @@ package org.apache.maven.project.inheritance.t00;
* under the License. * under the License.
*/ */
import org.apache.maven.model.MailingList;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;

View File

@ -21,12 +21,10 @@ package org.apache.maven.project.inheritance.t02;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.MailingList;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
@ -118,7 +116,7 @@ public class ProjectInheritanceTest
Build build = project4.getBuild(); Build build = project4.getBuild();
List<Plugin> plugins = build.getPlugins(); List<Plugin> plugins = build.getPlugins();
Map validPluginCounts = new HashMap(); Map<String, Integer> validPluginCounts = new HashMap<>();
String testPluginArtifactId = "maven-compiler-plugin"; String testPluginArtifactId = "maven-compiler-plugin";
@ -147,7 +145,7 @@ public class ProjectInheritanceTest
testPlugin = plugin; testPlugin = plugin;
} }
Integer count = (Integer) validPluginCounts.get( pluginArtifactId ); Integer count = validPluginCounts.get( pluginArtifactId );
if ( count > 0 ) if ( count > 0 )
{ {

View File

@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t04;
*/ */
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;

View File

@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t05;
*/ */
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;

View File

@ -20,7 +20,6 @@ package org.apache.maven.project.inheritance.t07;
*/ */
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;

View File

@ -83,7 +83,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); 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", repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1",
new ArtifactRepositoryLayoutStub(), null, null ) ); new ArtifactRepositoryLayoutStub(), null, null ) );
repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2",
@ -96,7 +96,7 @@ public class DefaultWagonManagerTest
class TransferListener class TransferListener
extends AbstractTransferListener extends AbstractTransferListener
{ {
public List<TransferEvent> events = new ArrayList<TransferEvent>(); public List<TransferEvent> events = new ArrayList<>();
@Override @Override
public void transferInitiated( TransferEvent transferEvent ) public void transferInitiated( TransferEvent transferEvent )

View File

@ -41,7 +41,7 @@ import org.codehaus.plexus.component.annotations.Component;
public class StringWagon public class StringWagon
extends StreamWagon 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 ) public void addExpectedContent( String resourceName, String expectedContent )
{ {

View File

@ -19,17 +19,6 @@ package org.apache.maven.repository.legacy.resolver;
* under the License. * 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.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; 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.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.CyclicDependencyException; 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.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; 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.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.codehaus.plexus.PlexusTestCase; 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. * Test the default artifact collector.
* *
@ -730,31 +730,31 @@ public class DefaultArtifactCollectorTest
return null; return null;
} }
private ArtifactResolutionResult collect( Set artifacts ) private ArtifactResolutionResult collect( Set<Artifact> artifacts )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return collect( artifacts, null ); return collect( artifacts, null );
} }
private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) private ArtifactResolutionResult collect( Set<Artifact> artifacts, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter, return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter,
Collections.EMPTY_LIST, null ); Collections.<ResolutionListener>emptyList(), null );
} }
private ArtifactResolutionResult collect( ArtifactSpec a ) private ArtifactResolutionResult collect( ArtifactSpec a )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, 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 ) private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, 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 ) private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion )
@ -762,7 +762,7 @@ public class DefaultArtifactCollectorTest
{ {
Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion );
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, 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 ) private ArtifactSpec createArtifactSpec( String id, String version )
@ -801,7 +801,8 @@ public class DefaultArtifactCollectorTest
return spec; return spec;
} }
private static Set createSet( Object[] x ) @SuppressWarnings( "unchecked" )
private static Set<Artifact> createSet( Object[] x )
{ {
return new LinkedHashSet( Arrays.asList( x ) ); return new LinkedHashSet( Arrays.asList( x ) );
} }
@ -810,7 +811,7 @@ public class DefaultArtifactCollectorTest
{ {
private Artifact artifact; private Artifact artifact;
private Set dependencies = new HashSet(); private Set<Artifact> dependencies = new HashSet<>();
public ArtifactSpec addDependency( String id, String version ) public ArtifactSpec addDependency( String id, String version )
throws InvalidVersionSpecificationException throws InvalidVersionSpecificationException
@ -851,9 +852,9 @@ public class DefaultArtifactCollectorTest
private class Source private class Source
implements ArtifactMetadataSource 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, public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories ) List<ArtifactRepository> remoteRepositories )
@ -880,16 +881,14 @@ public class DefaultArtifactCollectorTest
return artifact.getDependencyConflictId(); 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 ) ArtifactFilter dependencyFilter )
throws InvalidVersionSpecificationException 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; VersionRange versionRange;
if ( d.getVersionRange() != null ) if ( d.getVersionRange() != null )
{ {
@ -931,10 +930,10 @@ public class DefaultArtifactCollectorTest
artifacts.put( getKey( spec.artifact ), spec ); artifacts.put( getKey( spec.artifact ), spec );
String key = spec.artifact.getDependencyConflictId(); String key = spec.artifact.getDependencyConflictId();
List artifactVersions = (List) versions.get( key ); List<ArtifactVersion> artifactVersions = versions.get( key );
if ( artifactVersions == null ) if ( artifactVersions == null )
{ {
artifactVersions = new ArrayList(); artifactVersions = new ArrayList<>();
versions.put( key, artifactVersions ); versions.put( key, artifactVersions );
} }
if ( spec.artifact.getVersion() != null ) if ( spec.artifact.getVersion() != null )
@ -961,10 +960,10 @@ public class DefaultArtifactCollectorTest
private List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact ) private List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact )
{ {
List artifactVersions = (List) versions.get( artifact.getDependencyConflictId() ); List<ArtifactVersion> artifactVersions = versions.get( artifact.getDependencyConflictId() );
if ( artifactVersions == null ) if ( artifactVersions == null )
{ {
artifactVersions = Collections.EMPTY_LIST; artifactVersions = Collections.emptyList();
} }
return artifactVersions; return artifactVersions;
} }

View File

@ -21,12 +21,15 @@ package org.apache.maven.repository.legacy.resolver.conflict;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; 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.resolver.ResolutionNode;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.util.Collections;
/** /**
* Provides a basis for testing conflict resolvers. * Provides a basis for testing conflict resolvers.
* *
@ -108,24 +111,11 @@ public abstract class AbstractConflictResolverTest
assertEquals( "Resolution node", expectedNode, resolvedNode ); 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 protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException
{ {
return createArtifact( id, version, Artifact.SCOPE_COMPILE ); 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 ) protected Artifact createArtifact( String id, String version, String scope )
throws InvalidVersionSpecificationException throws InvalidVersionSpecificationException
{ {
@ -140,4 +130,14 @@ public abstract class AbstractConflictResolverTest
return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope,
inheritedScope, optional ); 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 );
}
} }

View File

@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
* under the License. * under the License.
*/ */
import java.util.Collections;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.repository.legacy.resolver.conflict.FarthestConflictResolver;
/** /**
* Tests <code>FarthestConflictResolver</code>. * Tests <code>FarthestConflictResolver</code>.
@ -52,9 +49,9 @@ public class FarthestConflictResolverTest
*/ */
public void testDepth() public void testDepth()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1);
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1);
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
assertResolveConflict( a2n, a1n, a2n ); assertResolveConflict( a2n, a1n, a2n );
} }
@ -68,9 +65,9 @@ public class FarthestConflictResolverTest
*/ */
public void testDepthReversed() public void testDepthReversed()
{ {
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a2n, a2n, a1n ); assertResolveConflict( a2n, a2n, a1n );
} }
@ -84,8 +81,8 @@ public class FarthestConflictResolverTest
*/ */
public void testEqual() public void testEqual()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2 );
assertResolveConflict( a1n, a1n, a2n ); assertResolveConflict( a1n, a1n, a2n );
} }
@ -99,8 +96,8 @@ public class FarthestConflictResolverTest
*/ */
public void testEqualReversed() public void testEqualReversed()
{ {
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2);
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1);
assertResolveConflict( a2n, a2n, a1n ); assertResolveConflict( a2n, a2n, a1n );
} }

View File

@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
* under the License. * under the License.
*/ */
import java.util.Collections;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.repository.legacy.resolver.conflict.NearestConflictResolver;
/** /**
* Tests <code>NearestConflictResolver</code>. * Tests <code>NearestConflictResolver</code>.
@ -52,9 +49,9 @@ public class NearestConflictResolverTest
*/ */
public void testDepth() public void testDepth()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1);
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1);
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
assertResolveConflict( a1n, a1n, a2n ); assertResolveConflict( a1n, a1n, a2n );
} }
@ -68,9 +65,9 @@ public class NearestConflictResolverTest
*/ */
public void testDepthReversed() public void testDepthReversed()
{ {
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a1n, a2n, a1n ); assertResolveConflict( a1n, a2n, a1n );
} }
@ -84,8 +81,8 @@ public class NearestConflictResolverTest
*/ */
public void testEqual() public void testEqual()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2 );
assertResolveConflict( a1n, a1n, a2n ); assertResolveConflict( a1n, a1n, a2n );
} }
@ -99,8 +96,8 @@ public class NearestConflictResolverTest
*/ */
public void testEqualReversed() public void testEqualReversed()
{ {
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2);
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a2n, a2n, a1n ); assertResolveConflict( a2n, a2n, a1n );
} }

View File

@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
* under the License. * under the License.
*/ */
import java.util.Collections;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.repository.legacy.resolver.conflict.NewestConflictResolver;
/** /**
* Tests <code>NewestConflictResolver</code>. * Tests <code>NewestConflictResolver</code>.
@ -52,9 +49,9 @@ public class NewestConflictResolverTest
*/ */
public void testDepth() public void testDepth()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
assertResolveConflict( a2n, a1n, a2n ); assertResolveConflict( a2n, a1n, a2n );
} }
@ -68,9 +65,9 @@ public class NewestConflictResolverTest
*/ */
public void testDepthReversed() public void testDepthReversed()
{ {
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a2n, a2n, a1n ); assertResolveConflict( a2n, a2n, a1n );
} }
@ -84,8 +81,8 @@ public class NewestConflictResolverTest
*/ */
public void testEqual() public void testEqual()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2 );
assertResolveConflict( a2n, a1n, a2n ); assertResolveConflict( a2n, a1n, a2n );
} }
@ -99,8 +96,8 @@ public class NewestConflictResolverTest
*/ */
public void testEqualReversed() public void testEqualReversed()
{ {
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2 );
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a2n, a2n, a1n ); assertResolveConflict( a2n, a2n, a1n );
} }

View File

@ -19,10 +19,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
* under the License. * under the License.
*/ */
import java.util.Collections;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.repository.legacy.resolver.conflict.OldestConflictResolver;
/** /**
* Tests <code>OldestConflictResolver</code>. * Tests <code>OldestConflictResolver</code>.
@ -52,13 +49,14 @@ public class OldestConflictResolverTest
*/ */
public void testDepth() public void testDepth()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1);
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
assertResolveConflict( a1n, a1n, a2n ); assertResolveConflict( a1n, a1n, a2n );
} }
/** /**
* Tests that <code>a:1.0</code> wins in the scenario: * Tests that <code>a:1.0</code> wins in the scenario:
* <pre> * <pre>
@ -68,9 +66,9 @@ public class OldestConflictResolverTest
*/ */
public void testDepthReversed() public void testDepthReversed()
{ {
ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST ); ResolutionNode b1n = createResolutionNode( b1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n ); ResolutionNode a2n = createResolutionNode( a2, b1n );
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a1n, a2n, a1n ); assertResolveConflict( a1n, a2n, a1n );
} }
@ -84,8 +82,8 @@ public class OldestConflictResolverTest
*/ */
public void testEqual() public void testEqual()
{ {
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2 );
assertResolveConflict( a1n, a1n, a2n ); assertResolveConflict( a1n, a1n, a2n );
} }
@ -99,8 +97,8 @@ public class OldestConflictResolverTest
*/ */
public void testEqualReversed() public void testEqualReversed()
{ {
ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST ); ResolutionNode a2n = createResolutionNode( a2);
ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST ); ResolutionNode a1n = createResolutionNode( a1 );
assertResolveConflict( a1n, a2n, a1n ); assertResolveConflict( a1n, a2n, a1n );
} }

View File

@ -19,10 +19,6 @@ package org.apache.maven.repository.metadata;
* under the License. * 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.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository; 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.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Component(role = ArtifactMetadataSource.class) @Component(role = ArtifactMetadataSource.class)
public class TestMetadataSource public class TestMetadataSource
implements ArtifactMetadataSource implements ArtifactMetadataSource
@ -44,7 +44,7 @@ public class TestMetadataSource
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
Set dependencies = new HashSet(); Set<Artifact> dependencies = new HashSet<>();
if ( "g".equals( artifact.getArtifactId() ) ) if ( "g".equals( artifact.getArtifactId() ) )
{ {

View File

@ -60,7 +60,7 @@ public class DefaultArtifactFilterManager
{ {
if ( excludedArtifacts == null ) if ( excludedArtifacts == null )
{ {
excludedArtifacts = new LinkedHashSet<String>( coreArtifacts ); excludedArtifacts = new LinkedHashSet<>( coreArtifacts );
} }
return excludedArtifacts; return excludedArtifacts;
} }
@ -72,7 +72,7 @@ public class DefaultArtifactFilterManager
*/ */
public ArtifactFilter getArtifactFilter() public ArtifactFilter getArtifactFilter()
{ {
Set<String> excludes = new LinkedHashSet<String>( getExcludedArtifacts() ); Set<String> excludes = new LinkedHashSet<>( getExcludedArtifacts() );
for ( ArtifactFilterManagerDelegate delegate : delegates ) for ( ArtifactFilterManagerDelegate delegate : delegates )
{ {
@ -99,7 +99,7 @@ public class DefaultArtifactFilterManager
public Set<String> getCoreArtifactExcludes() public Set<String> getCoreArtifactExcludes()
{ {
Set<String> excludes = new LinkedHashSet<String>( coreArtifacts ); Set<String> excludes = new LinkedHashSet<>( coreArtifacts );
for ( ArtifactFilterManagerDelegate delegate : delegates ) for ( ArtifactFilterManagerDelegate delegate : delegates )
{ {

View File

@ -370,7 +370,7 @@ public class DefaultMaven
private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects ) private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects )
{ {
Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = Collection<AbstractMavenLifecycleParticipant> lifecycleListeners =
new LinkedHashSet<AbstractMavenLifecycleParticipant>(); new LinkedHashSet<>();
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try try
@ -385,7 +385,7 @@ public class DefaultMaven
logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() );
} }
Collection<ClassLoader> scannedRealms = new HashSet<ClassLoader>(); Collection<ClassLoader> scannedRealms = new HashSet<>();
for ( MavenProject project : projects ) for ( MavenProject project : projects )
{ {
@ -427,7 +427,7 @@ public class DefaultMaven
private void validateActivatedProfiles( List<MavenProject> projects, List<String> activeProfileIds ) 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 ) for ( MavenProject project : projects )
{ {
@ -447,8 +447,8 @@ public class DefaultMaven
private Map<String, MavenProject> getProjectMap( Collection<MavenProject> projects ) private Map<String, MavenProject> getProjectMap( Collection<MavenProject> projects )
throws DuplicateProjectException throws DuplicateProjectException
{ {
Map<String, MavenProject> index = new LinkedHashMap<String, MavenProject>(); Map<String, MavenProject> index = new LinkedHashMap<>();
Map<String, List<File>> collisions = new LinkedHashMap<String, List<File>>(); Map<String, List<File>> collisions = new LinkedHashMap<>();
for ( MavenProject project : projects ) for ( MavenProject project : projects )
{ {
@ -466,7 +466,7 @@ public class DefaultMaven
if ( pomFiles == null ) 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 ); collisions.put( projectId, pomFiles );
} }
else else

View File

@ -91,7 +91,7 @@ public class DefaultProjectDependenciesResolver
Set<String> projectIds ) Set<String> projectIds )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
Set<Artifact> resolved = new LinkedHashSet<Artifact>(); Set<Artifact> resolved = new LinkedHashSet<>();
if ( projects == null || projects.isEmpty() ) if ( projects == null || projects.isEmpty() )
{ {
@ -166,7 +166,7 @@ public class DefaultProjectDependenciesResolver
catch ( MultipleArtifactsNotFoundException e ) 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(); ) for ( Iterator<Artifact> it = missing.iterator(); it.hasNext(); )
{ {
@ -192,7 +192,7 @@ public class DefaultProjectDependenciesResolver
private Set<String> getIgnorableArtifacts( Collection<? extends MavenProject> projects ) 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 ) for ( MavenProject p : projects )
{ {
@ -204,7 +204,7 @@ public class DefaultProjectDependenciesResolver
private Set<String> getIgnorableArtifacts( Iterable<Artifact> artifactIterable ) private Set<String> getIgnorableArtifacts( Iterable<Artifact> artifactIterable )
{ {
Set<String> projectIds = new HashSet<String>(); Set<String> projectIds = new HashSet<>();
for ( Artifact artifact : artifactIterable ) for ( Artifact artifact : artifactIterable )
{ {

View File

@ -67,7 +67,7 @@ class ReactorReader
{ {
projectsByGAV = session.getProjectMap(); projectsByGAV = session.getProjectMap();
projectsByGA = new HashMap<String, List<MavenProject>>( projectsByGAV.size() * 2 ); projectsByGA = new HashMap<>( projectsByGAV.size() * 2 );
for ( MavenProject project : projectsByGAV.values() ) for ( MavenProject project : projectsByGAV.values() )
{ {
String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
@ -76,14 +76,14 @@ class ReactorReader
if ( projects == null ) if ( projects == null )
{ {
projects = new ArrayList<MavenProject>( 1 ); projects = new ArrayList<>( 1 );
projectsByGA.put( key, projects ); projectsByGA.put( key, projects );
} }
projects.add( project ); 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(); return Collections.emptyList();
} }
List<String> versions = new ArrayList<String>(); List<String> versions = new ArrayList<>();
for ( MavenProject project : projects ) for ( MavenProject project : projects )
{ {

View File

@ -97,7 +97,7 @@ public class RepositoryUtils
result.setFile( artifact.getFile() ); result.setFile( artifact.getFile() );
result.setResolved( artifact.getFile() != null ); result.setResolved( artifact.getFile() != null );
List<String> trail = new ArrayList<String>( 1 ); List<String> trail = new ArrayList<>( 1 );
trail.add( result.getId() ); trail.add( result.getId() );
result.setDependencyTrail( trail ); result.setDependencyTrail( trail );
@ -112,7 +112,7 @@ public class RepositoryUtils
{ {
org.apache.maven.artifact.Artifact artifact = toArtifact( node.getDependency() ); 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.addAll( trail );
nodeTrail.add( artifact.getId() ); nodeTrail.add( artifact.getId() );
@ -168,7 +168,7 @@ public class RepositoryUtils
List<Exclusion> excl = null; List<Exclusion> excl = null;
if ( exclusions != null ) if ( exclusions != null )
{ {
excl = new ArrayList<Exclusion>( exclusions.size() ); excl = new ArrayList<>( exclusions.size() );
for ( org.apache.maven.model.Exclusion exclusion : exclusions ) for ( org.apache.maven.model.Exclusion exclusion : exclusions )
{ {
excl.add( toExclusion( exclusion ) ); excl.add( toExclusion( exclusion ) );
@ -185,7 +185,7 @@ public class RepositoryUtils
return null; return null;
} }
List<RemoteRepository> results = new ArrayList<RemoteRepository>( repos.size() ); List<RemoteRepository> results = new ArrayList<>( repos.size() );
for ( ArtifactRepository repo : repos ) for ( ArtifactRepository repo : repos )
{ {
results.add( toRepo( repo ) ); results.add( toRepo( repo ) );
@ -310,7 +310,7 @@ public class RepositoryUtils
new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
dependency.getVersion(), props, stereotype ); 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() ) for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
{ {
exclusions.add( toExclusion( exclusion ) ); exclusions.add( toExclusion( exclusion ) );
@ -352,7 +352,7 @@ public class RepositoryUtils
public static Collection<Artifact> toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifactsToConvert ) 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 ) for ( org.apache.maven.artifact.Artifact a : artifactsToConvert )
{ {
artifacts.add( toArtifact( a ) ); artifacts.add( toArtifact( a ) );

View File

@ -39,7 +39,7 @@ public class DefaultArtifactHandlerManager
@Requirement( role = ArtifactHandler.class ) @Requirement( role = ArtifactHandler.class )
private Map<String, ArtifactHandler> artifactHandlers; 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 ) public ArtifactHandler getArtifactHandler( String type )
{ {

View File

@ -118,7 +118,7 @@ public class DefaultRepositoryRequest
{ {
if ( remoteRepositories == null ) if ( remoteRepositories == null )
{ {
remoteRepositories = new ArrayList<ArtifactRepository>(); remoteRepositories = new ArrayList<>();
} }
return remoteRepositories; return remoteRepositories;

View File

@ -68,11 +68,7 @@ public abstract class AbstractRepositoryMetadata
{ {
updateRepositoryMetadata( localRepository, remoteRepository ); updateRepositoryMetadata( localRepository, remoteRepository );
} }
catch ( IOException e ) catch ( IOException | XmlPullParserException e )
{
throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e );
}
catch ( XmlPullParserException e )
{ {
throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e );
} }

View File

@ -59,7 +59,7 @@ public class ArtifactResolutionRequest
private ArtifactFilter resolutionFilter; private ArtifactFilter resolutionFilter;
// Needs to go away // 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 // This is like a filter but overrides all transitive versions
private Map<String, Artifact> managedVersionMap; private Map<String, Artifact> managedVersionMap;
@ -278,7 +278,7 @@ public class ArtifactResolutionRequest
{ {
if ( servers == null ) if ( servers == null )
{ {
servers = new ArrayList<Server>(); servers = new ArrayList<>();
} }
return servers; return servers;
@ -295,7 +295,7 @@ public class ArtifactResolutionRequest
{ {
if ( mirrors == null ) if ( mirrors == null )
{ {
mirrors = new ArrayList<Mirror>(); mirrors = new ArrayList<>();
} }
return mirrors; return mirrors;
@ -312,7 +312,7 @@ public class ArtifactResolutionRequest
{ {
if ( proxies == null ) if ( proxies == null )
{ {
proxies = new ArrayList<Proxy>(); proxies = new ArrayList<>();
} }
return proxies; return proxies;

View File

@ -82,7 +82,7 @@ public class ArtifactResolutionResult
{ {
if ( artifacts == null ) if ( artifacts == null )
{ {
artifacts = new LinkedHashSet<Artifact>(); artifacts = new LinkedHashSet<>();
} }
artifacts.add( artifact ); artifacts.add( artifact );
@ -92,7 +92,7 @@ public class ArtifactResolutionResult
{ {
if ( artifacts == null ) if ( artifacts == null )
{ {
artifacts = new LinkedHashSet<Artifact>(); artifacts = new LinkedHashSet<>();
} }
return artifacts; return artifacts;
@ -107,7 +107,7 @@ public class ArtifactResolutionResult
{ {
if ( resolutionNodes == null ) if ( resolutionNodes == null )
{ {
resolutionNodes = new LinkedHashSet<ResolutionNode>(); resolutionNodes = new LinkedHashSet<>();
} }
return resolutionNodes; return resolutionNodes;
@ -331,7 +331,7 @@ public class ArtifactResolutionResult
{ {
if ( l == null ) if ( l == null )
{ {
return new ArrayList<T>(); return new ArrayList<>();
} }
return l; return l;
} }

View File

@ -83,7 +83,7 @@ public class DefaultResolutionErrorHandler
private static <T> List<T> toList( Collection<T> items ) private static <T> List<T> toList( Collection<T> items )
{ {
return ( items != null ) ? new ArrayList<T>( items ) : null; return ( items != null ) ? new ArrayList<>( items ) : null;
} }
} }

View File

@ -64,7 +64,7 @@ public class ResolutionNode
this.artifact = artifact; this.artifact = artifact;
this.remoteRepositories = remoteRepositories; this.remoteRepositories = remoteRepositories;
depth = parent.depth + 1; depth = parent.depth + 1;
parents = new ArrayList<Object>(); parents = new ArrayList<>();
parents.addAll( parent.parents ); parents.addAll( parent.parents );
parents.add( parent.getKey() ); parents.add( parent.getKey() );
this.parent = parent; this.parent = parent;
@ -86,7 +86,7 @@ public class ResolutionNode
{ {
if ( artifacts != null && !artifacts.isEmpty() ) if ( artifacts != null && !artifacts.isEmpty() )
{ {
children = new ArrayList<ResolutionNode>( artifacts.size() ); children = new ArrayList<>( artifacts.size() );
for ( Artifact a : artifacts ) for ( Artifact a : artifacts )
{ {
@ -116,7 +116,7 @@ public class ResolutionNode
{ {
List<Artifact> trial = getTrail(); List<Artifact> trial = getTrail();
List<String> ret = new ArrayList<String>( trial.size() ); List<String> ret = new ArrayList<>( trial.size() );
for ( Artifact artifact : trial ) for ( Artifact artifact : trial )
{ {
@ -131,7 +131,7 @@ public class ResolutionNode
{ {
if ( trail == null ) if ( trail == null )
{ {
List<Artifact> ids = new LinkedList<Artifact>(); List<Artifact> ids = new LinkedList<>();
ResolutionNode node = this; ResolutionNode node = this;
while ( node != null ) while ( node != null )
{ {

View File

@ -39,12 +39,12 @@ public class AndArtifactFilter
public AndArtifactFilter() public AndArtifactFilter()
{ {
this.filters = new LinkedHashSet<ArtifactFilter>(); this.filters = new LinkedHashSet<>();
} }
public AndArtifactFilter( List<ArtifactFilter> filters ) public AndArtifactFilter( List<ArtifactFilter> filters )
{ {
this.filters = new LinkedHashSet<ArtifactFilter>( filters ); this.filters = new LinkedHashSet<>( filters );
} }
public boolean include( Artifact artifact ) public boolean include( Artifact artifact )
@ -68,7 +68,7 @@ public class AndArtifactFilter
public List<ArtifactFilter> getFilters() public List<ArtifactFilter> getFilters()
{ {
return new ArrayList<ArtifactFilter>( filters ); return new ArrayList<>( filters );
} }
@Override @Override

View File

@ -45,7 +45,7 @@ public class CumulativeScopeArtifactFilter
*/ */
public CumulativeScopeArtifactFilter( Collection<String> scopes ) public CumulativeScopeArtifactFilter( Collection<String> scopes )
{ {
this.scopes = new HashSet<String>(); this.scopes = new HashSet<>();
addScopes( scopes ); addScopes( scopes );
} }
@ -57,7 +57,7 @@ public class CumulativeScopeArtifactFilter
*/ */
public CumulativeScopeArtifactFilter( CumulativeScopeArtifactFilter... filters ) public CumulativeScopeArtifactFilter( CumulativeScopeArtifactFilter... filters )
{ {
this.scopes = new HashSet<String>(); this.scopes = new HashSet<>();
if ( filters != null ) if ( filters != null )
{ {

View File

@ -35,7 +35,7 @@ public class ExclusionSetFilter
public ExclusionSetFilter( String[] excludes ) public ExclusionSetFilter( String[] excludes )
{ {
this.excludes = new LinkedHashSet<String>( Arrays.asList( excludes ) ); this.excludes = new LinkedHashSet<>( Arrays.asList( excludes ) );
} }
public ExclusionSetFilter( Set<String> excludes ) public ExclusionSetFilter( Set<String> excludes )

View File

@ -39,7 +39,7 @@ public class IncludesArtifactFilter
public IncludesArtifactFilter( List<String> patterns ) public IncludesArtifactFilter( List<String> patterns )
{ {
this.patterns = new LinkedHashSet<String>( patterns ); this.patterns = new LinkedHashSet<>( patterns );
} }
public boolean include( Artifact artifact ) public boolean include( Artifact artifact )
@ -60,7 +60,7 @@ public class IncludesArtifactFilter
public List<String> getPatterns() public List<String> getPatterns()
{ {
return new ArrayList<String>( patterns ); return new ArrayList<>( patterns );
} }
@Override @Override

View File

@ -114,7 +114,7 @@ public class MavenRepositorySystem
if ( !d.getExclusions().isEmpty() ) if ( !d.getExclusions().isEmpty() )
{ {
List<String> exclusions = new ArrayList<String>(); List<String> exclusions = new ArrayList<>();
for ( Exclusion exclusion : d.getExclusions() ) for ( Exclusion exclusion : d.getExclusions() )
{ {
@ -593,7 +593,7 @@ public class MavenRepositorySystem
public Set<String> getRepoIds( List<ArtifactRepository> repositories ) public Set<String> getRepoIds( List<ArtifactRepository> repositories )
{ {
Set<String> repoIds = new HashSet<String>(); Set<String> repoIds = new HashSet<>();
if ( repositories != null ) if ( repositories != null )
{ {

View File

@ -156,9 +156,9 @@ public class DefaultClassRealmManager
private ClassRealm createRealm( String baseRealmId, RealmType type, ClassLoader parent, List<String> parentImports, private ClassRealm createRealm( String baseRealmId, RealmType type, ClassLoader parent, List<String> parentImports,
Map<String, ClassLoader> foreignImports, List<Artifact> artifacts ) Map<String, ClassLoader> foreignImports, List<Artifact> artifacts )
{ {
Set<String> artifactIds = new LinkedHashSet<String>(); Set<String> artifactIds = new LinkedHashSet<>();
List<ClassRealmConstituent> constituents = new ArrayList<ClassRealmConstituent>(); List<ClassRealmConstituent> constituents = new ArrayList<>();
if ( artifacts != null ) if ( artifacts != null )
{ {
@ -177,20 +177,20 @@ public class DefaultClassRealmManager
if ( parentImports != null ) if ( parentImports != null )
{ {
parentImports = new ArrayList<String>( parentImports ); parentImports = new ArrayList<>( parentImports );
} }
else else
{ {
parentImports = new ArrayList<String>(); parentImports = new ArrayList<>();
} }
if ( foreignImports != null ) if ( foreignImports != null )
{ {
foreignImports = new TreeMap<String, ClassLoader>( foreignImports ); foreignImports = new TreeMap<>( foreignImports );
} }
else else
{ {
foreignImports = new TreeMap<String, ClassLoader>(); foreignImports = new TreeMap<>();
} }
ClassRealm classRealm = newRealm( baseRealmId ); ClassRealm classRealm = newRealm( baseRealmId );
@ -305,7 +305,7 @@ public class DefaultClassRealmManager
private void callDelegates( ClassRealm classRealm, RealmType type, ClassLoader parent, List<String> parentImports, private void callDelegates( ClassRealm classRealm, RealmType type, ClassLoader parent, List<String> parentImports,
Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents ) Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents )
{ {
List<ClassRealmManagerDelegate> delegates = new ArrayList<ClassRealmManagerDelegate>( this.delegates ); List<ClassRealmManagerDelegate> delegates = new ArrayList<>( this.delegates );
if ( !delegates.isEmpty() ) if ( !delegates.isEmpty() )
{ {
@ -329,7 +329,7 @@ public class DefaultClassRealmManager
private Set<String> populateRealm( ClassRealm classRealm, List<ClassRealmConstituent> constituents ) private Set<String> populateRealm( ClassRealm classRealm, List<ClassRealmConstituent> constituents )
{ {
Set<String> includedIds = new LinkedHashSet<String>(); Set<String> includedIds = new LinkedHashSet<>();
if ( logger.isDebugEnabled() ) if ( logger.isDebugEnabled() )
{ {

View File

@ -46,7 +46,7 @@ public class EventSpyDispatcher
public void setEventSpies( List<EventSpy> eventSpies ) public void setEventSpies( List<EventSpy> eventSpies )
{ {
// make copy to get rid of needless overhead for dynamic lookups // make copy to get rid of needless overhead for dynamic lookups
this.eventSpies = new ArrayList<EventSpy>( eventSpies ); this.eventSpies = new ArrayList<>( eventSpies );
} }
public List<EventSpy> getEventSpies() public List<EventSpy> getEventSpies()
@ -84,11 +84,7 @@ public class EventSpyDispatcher
{ {
eventSpy.init( context ); eventSpy.init( context );
} }
catch ( Exception e ) catch ( Exception | LinkageError e )
{
logError( "initialize", e, eventSpy );
}
catch ( LinkageError e )
{ {
logError( "initialize", e, eventSpy ); logError( "initialize", e, eventSpy );
} }
@ -107,11 +103,7 @@ public class EventSpyDispatcher
{ {
eventSpy.onEvent( event ); eventSpy.onEvent( event );
} }
catch ( Exception e ) catch ( Exception | LinkageError e )
{
logError( "notify", e, eventSpy );
}
catch ( LinkageError e )
{ {
logError( "notify", e, eventSpy ); logError( "notify", e, eventSpy );
} }
@ -130,11 +122,7 @@ public class EventSpyDispatcher
{ {
eventSpy.close(); eventSpy.close();
} }
catch ( Exception e ) catch ( Exception | LinkageError e )
{
logError( "close", e, eventSpy );
}
catch ( LinkageError e )
{ {
logError( "close", e, eventSpy ); logError( "close", e, eventSpy );
} }

View File

@ -103,7 +103,7 @@ public class DefaultExceptionHandler
{ {
List<ProjectBuildingResult> results = ( (ProjectBuildingException) exception ).getResults(); List<ProjectBuildingResult> results = ( (ProjectBuildingException) exception ).getResults();
children = new ArrayList<ExceptionSummary>(); children = new ArrayList<>();
for ( ProjectBuildingResult result : results ) for ( ProjectBuildingResult result : results )
{ {
@ -126,7 +126,7 @@ public class DefaultExceptionHandler
private ExceptionSummary handle( ProjectBuildingResult result ) private ExceptionSummary handle( ProjectBuildingResult result )
{ {
List<ExceptionSummary> children = new ArrayList<ExceptionSummary>(); List<ExceptionSummary> children = new ArrayList<>();
for ( ModelProblem problem : result.getProblems() ) for ( ModelProblem problem : result.getProblems() )
{ {

View File

@ -239,7 +239,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( goals == null ) if ( goals == null )
{ {
goals = new ArrayList<String>(); goals = new ArrayList<>();
} }
return goals; return goals;
} }
@ -283,7 +283,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( selectedProjects == null ) if ( selectedProjects == null )
{ {
selectedProjects = new ArrayList<String>(); selectedProjects = new ArrayList<>();
} }
return selectedProjects; return selectedProjects;
@ -294,7 +294,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( excludedProjects == null ) if ( excludedProjects == null )
{ {
excludedProjects = new ArrayList<String>(); excludedProjects = new ArrayList<>();
} }
return excludedProjects; return excludedProjects;
@ -335,7 +335,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( activeProfiles != null ) if ( activeProfiles != null )
{ {
this.activeProfiles = new ArrayList<String>( activeProfiles ); this.activeProfiles = new ArrayList<>( activeProfiles );
} }
else else
{ {
@ -350,7 +350,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( inactiveProfiles != null ) if ( inactiveProfiles != null )
{ {
this.inactiveProfiles = new ArrayList<String>( inactiveProfiles ); this.inactiveProfiles = new ArrayList<>( inactiveProfiles );
} }
else else
{ {
@ -365,7 +365,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( remoteRepositories != null ) if ( remoteRepositories != null )
{ {
this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories ); this.remoteRepositories = new ArrayList<>( remoteRepositories );
} }
else else
{ {
@ -380,7 +380,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( pluginArtifactRepositories != null ) if ( pluginArtifactRepositories != null )
{ {
this.pluginArtifactRepositories = new ArrayList<ArtifactRepository>( pluginArtifactRepositories ); this.pluginArtifactRepositories = new ArrayList<>( pluginArtifactRepositories );
} }
else else
{ {
@ -400,7 +400,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( activeProfiles == null ) if ( activeProfiles == null )
{ {
activeProfiles = new ArrayList<String>(); activeProfiles = new ArrayList<>();
} }
return activeProfiles; return activeProfiles;
} }
@ -410,7 +410,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( inactiveProfiles == null ) if ( inactiveProfiles == null )
{ {
inactiveProfiles = new ArrayList<String>(); inactiveProfiles = new ArrayList<>();
} }
return inactiveProfiles; return inactiveProfiles;
} }
@ -490,7 +490,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( goals != null ) if ( goals != null )
{ {
this.goals = new ArrayList<String>( goals ); this.goals = new ArrayList<>( goals );
} }
else else
{ {
@ -574,7 +574,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( selectedProjects != null ) if ( selectedProjects != null )
{ {
this.selectedProjects = new ArrayList<String>( selectedProjects ); this.selectedProjects = new ArrayList<>( selectedProjects );
} }
else else
{ {
@ -589,7 +589,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( excludedProjects != null ) if ( excludedProjects != null )
{ {
this.excludedProjects = new ArrayList<String>( excludedProjects ); this.excludedProjects = new ArrayList<>( excludedProjects );
} }
else else
{ {
@ -756,7 +756,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( proxies == null ) if ( proxies == null )
{ {
proxies = new ArrayList<Proxy>(); proxies = new ArrayList<>();
} }
return proxies; return proxies;
} }
@ -766,7 +766,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( proxies != null ) if ( proxies != null )
{ {
this.proxies = new ArrayList<Proxy>( proxies ); this.proxies = new ArrayList<>( proxies );
} }
else else
{ {
@ -802,7 +802,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( servers == null ) if ( servers == null )
{ {
servers = new ArrayList<Server>(); servers = new ArrayList<>();
} }
return servers; return servers;
} }
@ -812,7 +812,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( servers != null ) if ( servers != null )
{ {
this.servers = new ArrayList<Server>( servers ); this.servers = new ArrayList<>( servers );
} }
else else
{ {
@ -848,7 +848,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( mirrors == null ) if ( mirrors == null )
{ {
mirrors = new ArrayList<Mirror>(); mirrors = new ArrayList<>();
} }
return mirrors; return mirrors;
} }
@ -858,7 +858,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( mirrors != null ) if ( mirrors != null )
{ {
this.mirrors = new ArrayList<Mirror>( mirrors ); this.mirrors = new ArrayList<>( mirrors );
} }
else else
{ {
@ -894,7 +894,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( profiles == null ) if ( profiles == null )
{ {
profiles = new ArrayList<Profile>(); profiles = new ArrayList<>();
} }
return profiles; return profiles;
} }
@ -904,7 +904,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( profiles != null ) if ( profiles != null )
{ {
this.profiles = new ArrayList<Profile>( profiles ); this.profiles = new ArrayList<>( profiles );
} }
else else
{ {
@ -919,7 +919,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( pluginGroups == null ) if ( pluginGroups == null )
{ {
pluginGroups = new ArrayList<String>(); pluginGroups = new ArrayList<>();
} }
return pluginGroups; return pluginGroups;
@ -930,7 +930,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( pluginGroups != null ) if ( pluginGroups != null )
{ {
this.pluginGroups = new ArrayList<String>( pluginGroups ); this.pluginGroups = new ArrayList<>( pluginGroups );
} }
else else
{ {
@ -1065,7 +1065,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( remoteRepositories == null ) if ( remoteRepositories == null )
{ {
remoteRepositories = new ArrayList<ArtifactRepository>(); remoteRepositories = new ArrayList<>();
} }
return remoteRepositories; return remoteRepositories;
} }
@ -1091,7 +1091,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( pluginArtifactRepositories == null ) if ( pluginArtifactRepositories == null )
{ {
pluginArtifactRepositories = new ArrayList<ArtifactRepository>(); pluginArtifactRepositories = new ArrayList<>();
} }
return pluginArtifactRepositories; return pluginArtifactRepositories;
} }
@ -1249,7 +1249,7 @@ public class DefaultMavenExecutionRequest
{ {
if ( toolchains == null ) if ( toolchains == null )
{ {
toolchains = new HashMap<String, List<ToolchainModel>>(); toolchains = new HashMap<>();
} }
return toolchains; return toolchains;
} }

View File

@ -69,7 +69,7 @@ public class DefaultMavenExecutionRequestPopulator
{ {
if ( toolchains != null ) if ( toolchains != null )
{ {
Map<String, List<ToolchainModel>> groupedToolchains = new HashMap<String, List<ToolchainModel>>( 2 ); Map<String, List<ToolchainModel>> groupedToolchains = new HashMap<>( 2 );
for ( ToolchainModel model : toolchains.getToolchains() ) for ( ToolchainModel model : toolchains.getToolchains() )
{ {

View File

@ -38,7 +38,7 @@ public class DefaultMavenExecutionResult
private DependencyResolutionResult dependencyResolutionResult; private DependencyResolutionResult dependencyResolutionResult;
private final List<Throwable> exceptions = new CopyOnWriteArrayList<Throwable>(); private final List<Throwable> exceptions = new CopyOnWriteArrayList<>();
private final Map<MavenProject, BuildSummary> buildSummaries = private final Map<MavenProject, BuildSummary> buildSummaries =
Collections.synchronizedMap( new IdentityHashMap<MavenProject, BuildSummary>() ); Collections.synchronizedMap( new IdentityHashMap<MavenProject, BuildSummary>() );

View File

@ -74,7 +74,7 @@ public class MavenSession
private boolean parallel; private boolean parallel;
private final Map<String, Map<String, Map<String, Object>>> pluginContextsByProjectAndPluginKey = private final Map<String, Map<String, Map<String, Object>>> pluginContextsByProjectAndPluginKey =
new ConcurrentHashMap<String, Map<String, Map<String, Object>>>(); new ConcurrentHashMap<>();
public void setProjects( List<MavenProject> projects ) public void setProjects( List<MavenProject> projects )
@ -198,7 +198,7 @@ public class MavenSession
if ( pluginContextsByKey == null ) if ( pluginContextsByKey == null )
{ {
pluginContextsByKey = new ConcurrentHashMap<String, Map<String, Object>>(); pluginContextsByKey = new ConcurrentHashMap<>();
pluginContextsByProjectAndPluginKey.put( projectKey, pluginContextsByKey ); pluginContextsByProjectAndPluginKey.put( projectKey, pluginContextsByKey );
} }
@ -209,7 +209,7 @@ public class MavenSession
if ( pluginContext == null ) if ( pluginContext == null )
{ {
pluginContext = new ConcurrentHashMap<String, Object>(); pluginContext = new ConcurrentHashMap<>();
pluginContextsByKey.put( pluginKey, pluginContext ); pluginContextsByKey.put( pluginKey, pluginContext );
} }

View File

@ -47,17 +47,17 @@ public class ReactorManager
// make projects that depend on me, and projects that I depend on // make projects that depend on me, and projects that I depend on
public static final String MAKE_BOTH_MODE = "make-both"; public static final String MAKE_BOTH_MODE = "make-both";
private List<String> blackList = new ArrayList<String>(); private List<String> blackList = new ArrayList<>();
private Map<String, BuildFailure> buildFailuresByProject = new HashMap<String, BuildFailure>(); private Map<String, BuildFailure> buildFailuresByProject = new HashMap<>();
private Map pluginContextsByProjectAndPluginKey = new HashMap(); private Map<String, Map<String, Map>> pluginContextsByProjectAndPluginKey = new HashMap<>();
private String failureBehavior = FAIL_FAST; private String failureBehavior = FAIL_FAST;
private final ProjectSorter sorter; private final ProjectSorter sorter;
private Map<String, BuildSuccess> buildSuccessesByProject = new HashMap<String, BuildSuccess>(); private Map<String, BuildSuccess> buildSuccessesByProject = new HashMap<>();
public ReactorManager( List<MavenProject> projects ) public ReactorManager( List<MavenProject> projects )
throws CycleDetectedException, DuplicateProjectException throws CycleDetectedException, DuplicateProjectException
@ -67,15 +67,15 @@ public class ReactorManager
public Map getPluginContext( PluginDescriptor plugin, MavenProject project ) public Map getPluginContext( PluginDescriptor plugin, MavenProject project )
{ {
Map pluginContextsByKey = (Map) pluginContextsByProjectAndPluginKey.get( project.getId() ); Map<String, Map> pluginContextsByKey = pluginContextsByProjectAndPluginKey.get( project.getId() );
if ( pluginContextsByKey == null ) if ( pluginContextsByKey == null )
{ {
pluginContextsByKey = new HashMap(); pluginContextsByKey = new HashMap<>();
pluginContextsByProjectAndPluginKey.put( project.getId(), pluginContextsByKey ); pluginContextsByProjectAndPluginKey.put( project.getId(), pluginContextsByKey );
} }
Map pluginContext = (Map) pluginContextsByKey.get( plugin.getPluginLookupKey() ); Map pluginContext = pluginContextsByKey.get( plugin.getPluginLookupKey() );
if ( pluginContext == null ) if ( pluginContext == null )
{ {
@ -93,15 +93,16 @@ public class ReactorManager
this.failureBehavior = FAIL_FAST; // default this.failureBehavior = FAIL_FAST; // default
return; return;
} }
if ( FAIL_FAST.equals( failureBehavior ) || FAIL_AT_END.equals( failureBehavior ) if ( FAIL_FAST.equals( failureBehavior ) || FAIL_AT_END.equals( failureBehavior ) || FAIL_NEVER.equals(
|| FAIL_NEVER.equals( failureBehavior ) ) failureBehavior ) )
{ {
this.failureBehavior = failureBehavior; this.failureBehavior = failureBehavior;
} }
else else
{ {
throw new IllegalArgumentException( "Invalid failure behavior (must be one of: \'" + FAIL_FAST + "\', \'" throw new IllegalArgumentException(
+ FAIL_AT_END + "\', \'" + FAIL_NEVER + "\')." ); "Invalid failure behavior (must be one of: \'" + FAIL_FAST + "\', \'" + FAIL_AT_END + "\', \'"
+ FAIL_NEVER + "\')." );
} }
} }
@ -127,8 +128,8 @@ public class ReactorManager
{ {
for ( String dependentId : dependents ) for ( String dependentId : dependents )
{ {
if ( !buildSuccessesByProject.containsKey( dependentId ) if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey(
&& !buildFailuresByProject.containsKey( dependentId ) ) dependentId ) )
{ {
blackList( dependentId ); blackList( dependentId );
} }
@ -184,12 +185,12 @@ public class ReactorManager
public BuildFailure getBuildFailure( MavenProject project ) public BuildFailure getBuildFailure( MavenProject project )
{ {
return (BuildFailure) buildFailuresByProject.get( getProjectKey( project ) ); return buildFailuresByProject.get( getProjectKey( project ) );
} }
public BuildSuccess getBuildSuccess( MavenProject project ) public BuildSuccess getBuildSuccess( MavenProject project )
{ {
return (BuildSuccess) buildSuccessesByProject.get( getProjectKey( project ) ); return buildSuccessesByProject.get( getProjectKey( project ) );
} }
public boolean executedMultipleProjects() public boolean executedMultipleProjects()

Some files were not shown because too many files have changed in this diff Show More