From 2ee29d169fae2d49dec6f730d9bfc09054b3767c Mon Sep 17 00:00:00 2001
From: Robert Scholte
Date: Fri, 3 Aug 2018 10:04:31 +0200
Subject: [PATCH 01/24] [MASSEMBLY-893] Typo in FAQ
---
src/site/fml/faq.fml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/site/fml/faq.fml b/src/site/fml/faq.fml
index cdf39f755..cc9cad29c 100644
--- a/src/site/fml/faq.fml
+++ b/src/site/fml/faq.fml
@@ -99,7 +99,7 @@ under the License.
to be adjusted or have the files they reference moved into the new child module alongside the descriptor itself.
In cases where you absolutely must use module-binaries references, you should create an assembly-child POM mentioned above, then insert
- <useAllReactorProjects>true<useAllReactorProjects>
to each of your moduleSet
sections. Then, bind the assembly
+ <useAllReactorProjects>true</useAllReactorProjects>
to each of your moduleSet
sections. Then, bind the assembly
in your assembly-child POM (normally to the package
phase) using the single
goal. When you execute the build from the top-level POM,
Maven should generated your assembly in the new child project.
From 0d232afa0adb6db94663a5bd7e6cb9726204809a Mon Sep 17 00:00:00 2001
From: Andrey Turbanov
Date: Sat, 25 Aug 2018 19:03:45 +0300
Subject: [PATCH 02/24] collapse identical catch blocks
---
.../archive/DefaultAssemblyArchiver.java | 26 +++----------------
.../archive/ManifestCreationFinalizer.java | 6 +----
.../archive/phase/FileItemAssemblyPhase.java | 6 +----
.../assembly/io/DefaultAssemblyReader.java | 14 ++--------
.../assembly/mojos/AbstractAssemblyMojo.java | 6 +----
.../archive/DefaultAssemblyArchiverTest.java | 6 +----
6 files changed, 10 insertions(+), 54 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java b/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
index e54fc01b8..9cc75e152 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
@@ -183,12 +183,7 @@ public File createArchive( final Assembly assembly, final String fullName, final
archiver.createArchive();
}
- catch ( final ArchiverException e )
- {
- throw new ArchiveCreationException(
- "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e );
- }
- catch ( final IOException e )
+ catch ( final ArchiverException | IOException e )
{
throw new ArchiveCreationException(
"Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e );
@@ -385,12 +380,7 @@ private void configureArchiver( final Archiver archiver, final AssemblerConfigur
{
config = Xpp3DomBuilder.build( new StringReader( configSource.getArchiverConfig() ) );
}
- catch ( final XmlPullParserException e )
- {
- throw new ArchiverException( "Failed to parse archiver configuration for: " + archiver.getClass().getName(),
- e );
- }
- catch ( final IOException e )
+ catch ( final XmlPullParserException | IOException e )
{
throw new ArchiverException( "Failed to parse archiver configuration for: " + archiver.getClass().getName(),
e );
@@ -443,11 +433,7 @@ private void configureComponent( final Object component, final Xpp3Dom config,
configureComponent.invoke( configurator, component, configuration, expressionEvaluator, containerRealm[0],
listener );
}
- catch ( final NoSuchMethodException e )
- {
- throw new RuntimeException( e );
- }
- catch ( final IllegalAccessException e )
+ catch ( final NoSuchMethodException | IllegalAccessException e )
{
throw new RuntimeException( e );
}
@@ -472,11 +458,7 @@ private Object[] getContainerRealm()
final Method getContainerRealm = container.getClass().getMethod( "getContainerRealm" );
return new Object[]{ getContainerRealm.invoke( container ), getContainerRealm.getReturnType() };
}
- catch ( final NoSuchMethodException e )
- {
- throw new RuntimeException( e );
- }
- catch ( final IllegalAccessException e )
+ catch ( final NoSuchMethodException | IllegalAccessException e )
{
throw new RuntimeException( e );
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/ManifestCreationFinalizer.java b/src/main/java/org/apache/maven/plugins/assembly/archive/ManifestCreationFinalizer.java
index 4ed1d3e61..35229818c 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/ManifestCreationFinalizer.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/ManifestCreationFinalizer.java
@@ -136,11 +136,7 @@ public List getVirtualFiles()
return Collections.singletonList( "META-INF/MANIFEST.MF" );
}
}
- catch ( final ManifestException ignore )
- {
- // noop
- }
- catch ( final DependencyResolutionRequiredException ignore )
+ catch ( final ManifestException | DependencyResolutionRequiredException ignore )
{
// noop
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
index 799f39fde..67701a4ed 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
@@ -122,11 +122,7 @@ else if ( outputDirectory.length() < 1 )
int mode = TypeConversionUtils.modeToInt( fileItem.getFileMode(), getLogger() );
archiver.addResource( restoUse, target, mode );
}
- catch ( final ArchiverException e )
- {
- throw new ArchiveCreationException( "Error adding file to archive: " + e.getMessage(), e );
- }
- catch ( IOException e )
+ catch ( final ArchiverException | IOException e )
{
throw new ArchiveCreationException( "Error adding file to archive: " + e.getMessage(), e );
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
index 2dfd47a9f..7ef826e10 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
@@ -360,12 +360,7 @@ public Assembly readAssembly( Reader reader, final String locationDescription, f
reader.close();
reader = null;
}
- catch ( final IOException e )
- {
- throw new AssemblyReadException( "Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
- e );
- }
- catch ( final XmlPullParserException e )
+ catch ( final IOException | XmlPullParserException e )
{
throw new AssemblyReadException( "Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
e );
@@ -454,12 +449,7 @@ protected void mergeComponentsWithMainAssembly( final Assembly assembly, final F
reader = new InputStreamReader( resolvedLocation.getInputStream() );
component = new ComponentXpp3Reader( transformer ).read( reader );
}
- catch ( final IOException e )
- {
- throw new AssemblyReadException( "Error reading component descriptor: " + location + " (resolved to: "
- + resolvedLocation.getSpecification() + ")", e );
- }
- catch ( final XmlPullParserException e )
+ catch ( final IOException | XmlPullParserException e )
{
throw new AssemblyReadException( "Error reading component descriptor: " + location + " (resolved to: "
+ resolvedLocation.getSpecification() + ")", e );
diff --git a/src/main/java/org/apache/maven/plugins/assembly/mojos/AbstractAssemblyMojo.java b/src/main/java/org/apache/maven/plugins/assembly/mojos/AbstractAssemblyMojo.java
index c6a00ffff..d74da756c 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/mojos/AbstractAssemblyMojo.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/mojos/AbstractAssemblyMojo.java
@@ -527,11 +527,7 @@ else if ( attach )
}
}
}
- catch ( final ArchiveCreationException e )
- {
- throw new MojoExecutionException( "Failed to create assembly: " + e.getMessage(), e );
- }
- catch ( final AssemblyFormattingException e )
+ catch ( final ArchiveCreationException | AssemblyFormattingException e )
{
throw new MojoExecutionException( "Failed to create assembly: " + e.getMessage(), e );
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
index b404ab3b6..dbb6cf461 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
@@ -166,11 +166,7 @@ public void testCreateArchive()
{
macMgr.archiver.createArchive();
}
- catch ( final ArchiverException e )
- {
- fail( "Should never happen" );
- }
- catch ( final IOException e )
+ catch ( final ArchiverException | IOException e )
{
fail( "Should never happen" );
}
From 3076fd3adfecd7502f31e08aa4b7f4894b184426 Mon Sep 17 00:00:00 2001
From: Andrey Turbanov
Date: Sat, 25 Aug 2018 19:10:03 +0300
Subject: [PATCH 03/24] Use diamond operator from java 7
---
.../archive/DefaultAssemblyArchiver.java | 12 +-
.../archiver/AssemblyProxyArchiver.java | 8 +-
.../archive/phase/ModuleSetAssemblyPhase.java | 14 +-
.../phase/wrappers/RepoInfoWrapper.java | 2 +-
.../archive/task/AddDependencySetsTask.java | 4 +-
.../archive/task/AddDirectoryTask.java | 4 +-
.../archive/task/AddFileSetsTask.java | 2 +-
.../artifact/DefaultDependencyResolver.java | 4 +-
.../artifact/ResolutionManagementInfo.java | 2 +-
.../AbstractLineAggregatingHandler.java | 6 +-
.../ComponentsXmlArchiverFileFilter.java | 2 +-
.../SimpleAggregatingDescriptorHandler.java | 2 +-
.../assembly/format/ReaderFormatter.java | 2 +-
.../interpolation/AssemblyInterpolator.java | 6 +-
.../assembly/io/DefaultAssemblyReader.java | 8 +-
.../DefaultRepositoryAssembler.java | 544 +++++++++---------
.../assembly/utils/AssemblyFormatUtils.java | 2 +-
.../plugins/assembly/utils/FilterUtils.java | 8 +-
.../utils/InterpolationConstants.java | 4 +-
.../plugins/assembly/utils/ProjectUtils.java | 6 +-
.../archiver/AssemblyProxyArchiverTest.java | 4 +-
.../AssemblyArchiverPhaseComparatorTest.java | 2 +-
.../phase/ModuleSetAssemblyPhaseTest.java | 18 +-
.../task/AddDependencySetsTaskTest.java | 4 +-
.../ResolutionManagementInfoTest.java | 4 +-
.../ComponentsXmlArchiverFileFilterTest.java | 10 +-
.../io/DefaultAssemblyReaderTest.java | 8 +-
.../assembly/testutils/TestFileManager.java | 2 +-
.../assembly/utils/FilterUtilsTest.java | 8 +-
.../assembly/utils/ProjectUtilsTest.java | 16 +-
.../utils/TypeConversionUtilsTest.java | 4 +-
31 files changed, 361 insertions(+), 361 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java b/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
index 9cc75e152..f90292861 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java
@@ -123,7 +123,7 @@ protected DefaultAssemblyArchiver( final ArchiverManager archiverManager,
private List sortedPhases()
{
- List sorted = new ArrayList( assemblyPhases );
+ List sorted = new ArrayList<>( assemblyPhases );
Collections.sort( sorted, new AssemblyArchiverPhaseComparator() );
return sorted;
}
@@ -225,11 +225,11 @@ private List selectContainerDescriptorHandlers(
if ( requestedContainerDescriptorHandlers == null )
{
- requestedContainerDescriptorHandlers = new ArrayList();
+ requestedContainerDescriptorHandlers = new ArrayList<>();
}
- final List handlers = new ArrayList();
- final List hints = new ArrayList();
+ final List handlers = new ArrayList<>();
+ final List hints = new ArrayList<>();
if ( !requestedContainerDescriptorHandlers.isEmpty() )
{
@@ -306,8 +306,8 @@ else if ( "war".equals( format ) )
( (AbstractZipArchiver) archiver ).setRecompressAddedZips( recompressZippedFiles );
}
- final List extraSelectors = new ArrayList();
- final List extraFinalizers = new ArrayList();
+ final List extraSelectors = new ArrayList<>();
+ final List extraFinalizers = new ArrayList<>();
if ( archiver instanceof JarArchiver )
{
if ( mergeManifestMode != null )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiver.java b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiver.java
index 329b7b43f..2f6c805e0 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiver.java
@@ -64,7 +64,7 @@ public class AssemblyProxyArchiver
private final Archiver delegate;
- private final ThreadLocal inPublicApi = new ThreadLocal();
+ private final ThreadLocal inPublicApi = new ThreadLocal<>();
private final Logger logger;
@@ -98,7 +98,7 @@ public AssemblyProxyArchiver( final String rootPrefix, final Archiver delegate,
this.rootPrefix += "/";
}
- final List selectors = new ArrayList();
+ final List selectors = new ArrayList<>();
FinalizerEnabled finalizer = ( delegate instanceof FinalizerEnabled ) ? (FinalizerEnabled) delegate : null;
@@ -734,7 +734,7 @@ private void doAddFileSet( final FileSet fs )
}
else if ( assemblyWorkPath.startsWith( fsPath ) )
{
- final List newEx = new ArrayList();
+ final List newEx = new ArrayList<>();
if ( fs.getExcludes() != null )
{
newEx.addAll( Arrays.asList( fs.getExcludes() ) );
@@ -748,7 +748,7 @@ else if ( assemblyWorkPath.startsWith( fsPath ) )
newEx.add( workDirExclude );
- final List newIn = new ArrayList();
+ final List newIn = new ArrayList<>();
if ( fs.getIncludes() != null )
{
for ( final String include : fs.getIncludes() )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
index 92e7b8138..ed778b3ca 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
@@ -149,7 +149,7 @@ public static Set getModuleProjects( final ModuleSet moduleSet,
{
if ( !moduleSet.isIncludeSubModules() )
{
- moduleProjects = new LinkedHashSet( configSource.getReactorProjects() );
+ moduleProjects = new LinkedHashSet<>( configSource.getReactorProjects() );
}
project = configSource.getReactorProjects().get( 0 );
@@ -254,13 +254,13 @@ void addModuleBinaries( final Assembly assembly, ModuleSet moduleSet, final Modu
return;
}
- final Set moduleProjects = new LinkedHashSet();
+ final Set moduleProjects = new LinkedHashSet<>();
MavenProjects.select( projects, "pom", log( getLogger() ), addTo( moduleProjects ) );
final String classifier = binaries.getAttachmentClassifier();
- final Map chosenModuleArtifacts = new HashMap();
+ final Map chosenModuleArtifacts = new HashMap<>();
for ( final MavenProject project : moduleProjects )
{
@@ -347,7 +347,7 @@ void addModuleBinaries( final Assembly assembly, ModuleSet moduleSet, final Modu
private List validateModuleVersions( Set moduleProjects )
{
- List result = new ArrayList();
+ List result = new ArrayList<>();
if ( moduleProjects != null && !moduleProjects.isEmpty() )
{
@@ -416,7 +416,7 @@ void addModuleSourceFileSets( final ModuleSources sources, final Set fileSets = new ArrayList();
+ final List fileSets = new ArrayList<>();
if ( isDeprecatedModuleSourcesConfigPresent( sources ) )
{
@@ -445,7 +445,7 @@ void addModuleSourceFileSets( final ModuleSources sources, final Set moduleFileSets = new ArrayList();
+ final List moduleFileSets = new ArrayList<>();
for ( final FileSet fileSet : fileSets )
{
@@ -514,7 +514,7 @@ FileSet createFileSet( @Nonnull final FileSet fileSet, @Nonnull final ModuleSour
fs.setDirectory( sourcePath );
fs.setDirectoryMode( fileSet.getDirectoryMode() );
- final List excludes = new ArrayList();
+ final List excludes = new ArrayList<>();
final List originalExcludes = fileSet.getExcludes();
if ( ( originalExcludes != null ) && !originalExcludes.isEmpty() )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/wrappers/RepoInfoWrapper.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/wrappers/RepoInfoWrapper.java
index 9a0fa8e4a..f606f7bda 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/wrappers/RepoInfoWrapper.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/wrappers/RepoInfoWrapper.java
@@ -65,7 +65,7 @@ public List getGroupVersionAlignments()
if ( convertedAlignments == null || alignments.size() != convertedAlignments.size() )
{
- final List l = new ArrayList( alignments.size() );
+ final List l = new ArrayList<>( alignments.size() );
for ( final org.apache.maven.plugins.assembly.model.GroupVersionAlignment alignment : alignments )
{
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
index 959c1e1d4..3f180357f 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
@@ -64,7 +64,7 @@ public class AddDependencySetsTask
static
{
- final List nonArch = new ArrayList();
+ final List nonArch = new ArrayList<>();
nonArch.add( "pom" );
@@ -283,7 +283,7 @@ private MavenProject buildProjectStub( final Artifact depArtifact )
Set resolveDependencyArtifacts( final DependencySet dependencySet )
throws InvalidAssemblerConfigurationException
{
- final Set dependencyArtifacts = new LinkedHashSet();
+ final Set dependencyArtifacts = new LinkedHashSet<>();
if ( resolvedArtifacts != null )
{
dependencyArtifacts.addAll( resolvedArtifacts );
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDirectoryTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDirectoryTask.java
index 2664ae166..749fd424c 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDirectoryTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDirectoryTask.java
@@ -103,11 +103,11 @@ else if ( "..".equals( outputDirectory ) )
List directoryExcludes;
if ( excludes != null && !excludes.isEmpty() )
{
- directoryExcludes = new ArrayList( excludes );
+ directoryExcludes = new ArrayList<>( excludes );
}
else
{
- directoryExcludes = new ArrayList();
+ directoryExcludes = new ArrayList<>();
}
try
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
index 1b855fa52..7ea776ead 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
@@ -58,7 +58,7 @@ public AddFileSetsTask( final List fileSets )
public AddFileSetsTask( final FileSet... fileSets )
{
- this.fileSets = new ArrayList( Arrays.asList( fileSets ) );
+ this.fileSets = new ArrayList<>( Arrays.asList( fileSets ) );
}
public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java b/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
index 81a98cbd5..7d224dc9c 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
@@ -57,7 +57,7 @@ public Map> resolveDependencySets( final Assembly a
List dependencySets )
throws DependencyResolutionException
{
- Map> result = new LinkedHashMap>();
+ Map> result = new LinkedHashMap<>();
for ( DependencySet dependencySet : dependencySets )
{
@@ -80,7 +80,7 @@ public Map> resolveDependencySets( final Assembly a
List dependencySets )
throws DependencyResolutionException
{
- Map> result = new LinkedHashMap>();
+ Map> result = new LinkedHashMap<>();
for ( DependencySet dependencySet : dependencySets )
{
diff --git a/src/main/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfo.java b/src/main/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfo.java
index 59904a49c..a66c4ac82 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfo.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfo.java
@@ -32,7 +32,7 @@
*/
class ResolutionManagementInfo
{
- private final LinkedHashSet artifacts = new LinkedHashSet();
+ private final LinkedHashSet artifacts = new LinkedHashSet<>();
Set getArtifacts()
{
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/AbstractLineAggregatingHandler.java b/src/main/java/org/apache/maven/plugins/assembly/filter/AbstractLineAggregatingHandler.java
index 20663ed4e..49a16b9ee 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/AbstractLineAggregatingHandler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/AbstractLineAggregatingHandler.java
@@ -44,7 +44,7 @@ abstract class AbstractLineAggregatingHandler
implements ContainerDescriptorHandler
{
- private Map> catalog = new HashMap>();
+ private Map> catalog = new HashMap<>();
private boolean excludeOverride = false;
@@ -121,7 +121,7 @@ public void finalizeArchiveExtraction( final UnArchiver unArchiver )
@Override
public List getVirtualFiles()
{
- return new ArrayList( catalog.keySet() );
+ return new ArrayList<>( catalog.keySet() );
}
@Override
@@ -142,7 +142,7 @@ public boolean isSelected( @Nonnull final FileInfo fileInfo )
List lines = catalog.get( name );
if ( lines == null )
{
- lines = new ArrayList();
+ lines = new ArrayList<>();
catalog.put( name, lines );
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilter.java b/src/main/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilter.java
index cc627c5b7..75031ba3a 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilter.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilter.java
@@ -83,7 +83,7 @@ void addComponentsXml( final Reader componentsReader )
{
if ( components == null )
{
- components = new LinkedHashMap();
+ components = new LinkedHashMap<>();
}
final String role = component.getChild( "role" ).getValue();
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/SimpleAggregatingDescriptorHandler.java b/src/main/java/org/apache/maven/plugins/assembly/filter/SimpleAggregatingDescriptorHandler.java
index cf34995f3..0c6c9a3d3 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/SimpleAggregatingDescriptorHandler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/SimpleAggregatingDescriptorHandler.java
@@ -59,7 +59,7 @@ public class SimpleAggregatingDescriptorHandler
private final StringWriter aggregateWriter = new StringWriter();
- private final List filenames = new ArrayList();
+ private final List filenames = new ArrayList<>();
// calculated, temporary values.
diff --git a/src/main/java/org/apache/maven/plugins/assembly/format/ReaderFormatter.java b/src/main/java/org/apache/maven/plugins/assembly/format/ReaderFormatter.java
index 960cd6994..4120b8bb7 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/format/ReaderFormatter.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/format/ReaderFormatter.java
@@ -59,7 +59,7 @@ private static Reader createReaderFilter( @Nonnull Reader source, String escapeS
// if these are NOT set, just use the defaults, which are '${*}' and '@'.
if ( delimiters != null && !delimiters.isEmpty() )
{
- LinkedHashSet delims = new LinkedHashSet();
+ LinkedHashSet delims = new LinkedHashSet<>();
for ( String delim : delimiters )
{
if ( delim == null )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolator.java b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolator.java
index fe55eaa2f..536cafb3b 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolator.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolator.java
@@ -47,7 +47,7 @@ public class AssemblyInterpolator
static
{
- final Set blacklist = new HashSet();
+ final Set blacklist = new HashSet<>();
blacklist.add( "outputFileNameMapping" );
blacklist.add( "outputDirectoryMapping" );
@@ -65,7 +65,7 @@ public static AssemblyXpp3Reader.ContentTransformer assemblyInterpolator(
final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger )
{
final Set blacklistFields =
- new HashSet( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
+ new HashSet<>( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
blacklistFields.addAll( INTERPOLATION_BLACKLIST );
return new AssemblyXpp3Reader.ContentTransformer()
@@ -93,7 +93,7 @@ public static ComponentXpp3Reader.ContentTransformer componentInterpolator(
final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger )
{
final Set blacklistFields =
- new HashSet( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
+ new HashSet<>( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
blacklistFields.addAll( INTERPOLATION_BLACKLIST );
return new ComponentXpp3Reader.ContentTransformer()
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
index 7ef826e10..ab2047756 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReader.java
@@ -94,14 +94,14 @@ public List readAssemblies( final AssemblerConfigurationSource configS
{
final Locator locator = new Locator();
- final List strategies = new ArrayList();
+ final List strategies = new ArrayList<>();
strategies.add( new RelativeFileLocatorStrategy( configSource.getBasedir() ) );
strategies.add( new FileLocatorStrategy() );
- final List refStrategies = new ArrayList();
+ final List refStrategies = new ArrayList<>();
refStrategies.add( new PrefixedClasspathLocatorStrategy( "/assemblies/" ) );
- final List assemblies = new ArrayList();
+ final List assemblies = new ArrayList<>();
final String[] descriptors = configSource.getDescriptors();
final String[] descriptorRefs = configSource.getDescriptorReferences();
@@ -161,7 +161,7 @@ public List readAssemblies( final AssemblerConfigurationSource configS
}
// check unique IDs
- final Set ids = new HashSet();
+ final Set ids = new HashSet<>();
for ( final Assembly assembly : assemblies )
{
if ( !ids.add( assembly.getId() ) )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/repository/DefaultRepositoryAssembler.java b/src/main/java/org/apache/maven/plugins/assembly/repository/DefaultRepositoryAssembler.java
index 30f05c517..31318b0f3 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/repository/DefaultRepositoryAssembler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/repository/DefaultRepositoryAssembler.java
@@ -1,272 +1,272 @@
-package org.apache.maven.plugins.assembly.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.plugins.assembly.repository.model.GroupVersionAlignment;
-import org.apache.maven.plugins.assembly.repository.model.RepositoryInfo;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.artifact.TransferUtils;
-import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
-import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
-import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
-import org.apache.maven.shared.artifact.resolve.ArtifactResolver;
-import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
-import org.apache.maven.shared.artifact.resolve.ArtifactResult;
-import org.apache.maven.shared.dependencies.resolve.DependencyResolver;
-import org.apache.maven.shared.dependencies.resolve.DependencyResolverException;
-import org.apache.maven.shared.repository.RepositoryManager;
-import org.apache.maven.shared.utils.io.FileUtils;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
-
-/**
- * @author Jason van Zyl
- */
-
-// todo will need to pop the processed project cache using reflection
-@Component( role = RepositoryAssembler.class )
-public class DefaultRepositoryAssembler
- extends AbstractLogEnabled
- implements RepositoryAssembler
-{
- @Requirement
- protected ArtifactResolver artifactResolver;
-
- @Requirement
- private DependencyResolver dependencyResolver;
-
- @Requirement
- private RepositoryManager repositoryManager;
-
- public void buildRemoteRepository( File repositoryDirectory, RepositoryInfo repository,
- RepositoryBuilderConfigSource configSource )
- throws RepositoryAssemblyException
- {
- MavenProject project = configSource.getProject();
- ProjectBuildingRequest buildingRequest = configSource.getProjectBuildingRequest();
-
- Iterable result = null;
-
- Collection dependencies = project.getDependencies();
-
- if ( dependencies == null )
- {
- Logger logger = getLogger();
-
- if ( logger.isDebugEnabled() )
- {
- logger.debug( "dependency-artifact set for project: " + project.getId()
- + " is null. Skipping repository processing." );
- }
-
- return;
- }
-
- Collection managedDependencies = null;
- if ( project.getDependencyManagement() != null )
- {
- managedDependencies = project.getDependencyManagement().getDependencies();
- }
-
- // Older Aether versions use an cache which can't be cleared. So can't delete repoDir and use it again.
- // Instead create a temporary repository, delete it at end (should be in a finally-block)
-
- File tempRepo = new File( repositoryDirectory.getParentFile(), repositoryDirectory.getName() + "_tmp" );
-
- buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, tempRepo );
-
- try
- {
- result = dependencyResolver.resolveDependencies( buildingRequest, dependencies, managedDependencies, null );
- }
- catch ( DependencyResolverException e )
- {
- throw new RepositoryAssemblyException( "Error resolving artifacts: " + e.getMessage(), e );
- }
-
- ArtifactFilter filter = buildRepositoryFilter( repository, project );
-
- buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, repositoryDirectory );
-
- Map groupVersionAlignments =
- createGroupVersionAlignments( repository.getGroupVersionAlignments() );
-
- assembleRepositoryArtifacts( buildingRequest, result, filter, groupVersionAlignments );
-
- if ( repository.isIncludeMetadata() )
- {
-// assembleRepositoryMetadata( result, filter, centralRepository, targetRepository );
- }
-
- try
- {
- FileUtils.deleteDirectory( tempRepo );
- }
- catch ( IOException e )
- {
- // noop
- }
- }
-
- private ArtifactFilter buildRepositoryFilter( RepositoryInfo repository, MavenProject project )
- {
- AndArtifactFilter filter = new AndArtifactFilter();
-
- ArtifactFilter scopeFilter = new ScopeArtifactFilter( repository.getScope() );
- filter.add( scopeFilter );
-
- // ----------------------------------------------------------------------------
- // Includes
- //
- // We'll take everything if no includes are specified to try and make
- // this
- // process more maintainable. Don't want to have to update the assembly
- // descriptor everytime the POM is updated.
- // ----------------------------------------------------------------------------
-
- List includes = repository.getIncludes();
-
- if ( ( includes == null ) || includes.isEmpty() )
- {
- List patterns = new ArrayList();
-
- Set projectArtifacts = project.getDependencyArtifacts();
-
- if ( projectArtifacts != null )
- {
- for ( Artifact artifact : projectArtifacts )
- {
- patterns.add( artifact.getDependencyConflictId() );
- }
- }
-
- PatternIncludesArtifactFilter includeFilter = new PatternIncludesArtifactFilter( patterns, true );
-
- filter.add( includeFilter );
- }
- else
- {
- filter.add( new PatternIncludesArtifactFilter( repository.getIncludes(), true ) );
- }
-
- // ----------------------------------------------------------------------------
- // Excludes
- //
- // We still want to make it easy to exclude a few things even if we
- // slurp
- // up everything.
- // ----------------------------------------------------------------------------
-
- List excludes = repository.getExcludes();
-
- if ( ( excludes != null ) && !excludes.isEmpty() )
- {
- filter.add( new PatternExcludesArtifactFilter( repository.getExcludes(), true ) );
- }
-
- return filter;
- }
-
- private void assembleRepositoryArtifacts( ProjectBuildingRequest buildingRequest, Iterable result,
- ArtifactFilter filter,
- Map groupVersionAlignments )
- throws RepositoryAssemblyException
- {
- try
- {
- for ( ArtifactResult ar : result )
- {
- Artifact a = ar.getArtifact();
-
- if ( filter.include( a ) )
- {
- getLogger().debug( "Re-resolving: " + a + " for repository assembly." );
-
- setAlignment( a, groupVersionAlignments );
-
- artifactResolver.resolveArtifact( buildingRequest, TransferUtils.toArtifactCoordinate( a ) );
-
- a.setVersion( a.getBaseVersion() );
-
- File targetFile = new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ),
- repositoryManager.getPathForLocalArtifact( buildingRequest, a ) );
-
- FileUtils.copyFile( a.getFile(), targetFile );
-
-// writeChecksums( targetFile );
- }
- }
- }
- catch ( ArtifactResolverException e )
- {
- throw new RepositoryAssemblyException( "Error resolving artifacts: " + e.getMessage(), e );
- }
- catch ( IOException e )
- {
- throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
- }
- }
-
- // CHECKSTYLE_OFF: LineLength
- protected Map createGroupVersionAlignments( List versionAlignments )
- // CHECKSTYLE_ON: LineLength
- {
- Map groupVersionAlignments = new HashMap();
-
- if ( versionAlignments != null )
- {
- for ( GroupVersionAlignment alignment : versionAlignments )
- {
- groupVersionAlignments.put( alignment.getId(), alignment );
- }
- }
-
- return groupVersionAlignments;
- }
-
- private void setAlignment( Artifact artifact, Map groupVersionAlignments )
- {
- GroupVersionAlignment alignment = groupVersionAlignments.get( artifact.getGroupId() );
-
- if ( alignment != null )
- {
- if ( !alignment.getExcludes().contains( artifact.getArtifactId() ) )
- {
- artifact.setVersion( alignment.getVersion() );
- }
- }
- }
-}
+package org.apache.maven.plugins.assembly.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugins.assembly.repository.model.GroupVersionAlignment;
+import org.apache.maven.plugins.assembly.repository.model.RepositoryInfo;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.TransferUtils;
+import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
+import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
+import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.dependencies.resolve.DependencyResolver;
+import org.apache.maven.shared.dependencies.resolve.DependencyResolverException;
+import org.apache.maven.shared.repository.RepositoryManager;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ * @author Jason van Zyl
+ */
+
+// todo will need to pop the processed project cache using reflection
+@Component( role = RepositoryAssembler.class )
+public class DefaultRepositoryAssembler
+ extends AbstractLogEnabled
+ implements RepositoryAssembler
+{
+ @Requirement
+ protected ArtifactResolver artifactResolver;
+
+ @Requirement
+ private DependencyResolver dependencyResolver;
+
+ @Requirement
+ private RepositoryManager repositoryManager;
+
+ public void buildRemoteRepository( File repositoryDirectory, RepositoryInfo repository,
+ RepositoryBuilderConfigSource configSource )
+ throws RepositoryAssemblyException
+ {
+ MavenProject project = configSource.getProject();
+ ProjectBuildingRequest buildingRequest = configSource.getProjectBuildingRequest();
+
+ Iterable result = null;
+
+ Collection dependencies = project.getDependencies();
+
+ if ( dependencies == null )
+ {
+ Logger logger = getLogger();
+
+ if ( logger.isDebugEnabled() )
+ {
+ logger.debug( "dependency-artifact set for project: " + project.getId()
+ + " is null. Skipping repository processing." );
+ }
+
+ return;
+ }
+
+ Collection managedDependencies = null;
+ if ( project.getDependencyManagement() != null )
+ {
+ managedDependencies = project.getDependencyManagement().getDependencies();
+ }
+
+ // Older Aether versions use an cache which can't be cleared. So can't delete repoDir and use it again.
+ // Instead create a temporary repository, delete it at end (should be in a finally-block)
+
+ File tempRepo = new File( repositoryDirectory.getParentFile(), repositoryDirectory.getName() + "_tmp" );
+
+ buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, tempRepo );
+
+ try
+ {
+ result = dependencyResolver.resolveDependencies( buildingRequest, dependencies, managedDependencies, null );
+ }
+ catch ( DependencyResolverException e )
+ {
+ throw new RepositoryAssemblyException( "Error resolving artifacts: " + e.getMessage(), e );
+ }
+
+ ArtifactFilter filter = buildRepositoryFilter( repository, project );
+
+ buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, repositoryDirectory );
+
+ Map groupVersionAlignments =
+ createGroupVersionAlignments( repository.getGroupVersionAlignments() );
+
+ assembleRepositoryArtifacts( buildingRequest, result, filter, groupVersionAlignments );
+
+ if ( repository.isIncludeMetadata() )
+ {
+// assembleRepositoryMetadata( result, filter, centralRepository, targetRepository );
+ }
+
+ try
+ {
+ FileUtils.deleteDirectory( tempRepo );
+ }
+ catch ( IOException e )
+ {
+ // noop
+ }
+ }
+
+ private ArtifactFilter buildRepositoryFilter( RepositoryInfo repository, MavenProject project )
+ {
+ AndArtifactFilter filter = new AndArtifactFilter();
+
+ ArtifactFilter scopeFilter = new ScopeArtifactFilter( repository.getScope() );
+ filter.add( scopeFilter );
+
+ // ----------------------------------------------------------------------------
+ // Includes
+ //
+ // We'll take everything if no includes are specified to try and make
+ // this
+ // process more maintainable. Don't want to have to update the assembly
+ // descriptor everytime the POM is updated.
+ // ----------------------------------------------------------------------------
+
+ List includes = repository.getIncludes();
+
+ if ( ( includes == null ) || includes.isEmpty() )
+ {
+ List patterns = new ArrayList<>();
+
+ Set projectArtifacts = project.getDependencyArtifacts();
+
+ if ( projectArtifacts != null )
+ {
+ for ( Artifact artifact : projectArtifacts )
+ {
+ patterns.add( artifact.getDependencyConflictId() );
+ }
+ }
+
+ PatternIncludesArtifactFilter includeFilter = new PatternIncludesArtifactFilter( patterns, true );
+
+ filter.add( includeFilter );
+ }
+ else
+ {
+ filter.add( new PatternIncludesArtifactFilter( repository.getIncludes(), true ) );
+ }
+
+ // ----------------------------------------------------------------------------
+ // Excludes
+ //
+ // We still want to make it easy to exclude a few things even if we
+ // slurp
+ // up everything.
+ // ----------------------------------------------------------------------------
+
+ List excludes = repository.getExcludes();
+
+ if ( ( excludes != null ) && !excludes.isEmpty() )
+ {
+ filter.add( new PatternExcludesArtifactFilter( repository.getExcludes(), true ) );
+ }
+
+ return filter;
+ }
+
+ private void assembleRepositoryArtifacts( ProjectBuildingRequest buildingRequest, Iterable result,
+ ArtifactFilter filter,
+ Map groupVersionAlignments )
+ throws RepositoryAssemblyException
+ {
+ try
+ {
+ for ( ArtifactResult ar : result )
+ {
+ Artifact a = ar.getArtifact();
+
+ if ( filter.include( a ) )
+ {
+ getLogger().debug( "Re-resolving: " + a + " for repository assembly." );
+
+ setAlignment( a, groupVersionAlignments );
+
+ artifactResolver.resolveArtifact( buildingRequest, TransferUtils.toArtifactCoordinate( a ) );
+
+ a.setVersion( a.getBaseVersion() );
+
+ File targetFile = new File( repositoryManager.getLocalRepositoryBasedir( buildingRequest ),
+ repositoryManager.getPathForLocalArtifact( buildingRequest, a ) );
+
+ FileUtils.copyFile( a.getFile(), targetFile );
+
+// writeChecksums( targetFile );
+ }
+ }
+ }
+ catch ( ArtifactResolverException e )
+ {
+ throw new RepositoryAssemblyException( "Error resolving artifacts: " + e.getMessage(), e );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
+ }
+ }
+
+ // CHECKSTYLE_OFF: LineLength
+ protected Map createGroupVersionAlignments( List versionAlignments )
+ // CHECKSTYLE_ON: LineLength
+ {
+ Map groupVersionAlignments = new HashMap<>();
+
+ if ( versionAlignments != null )
+ {
+ for ( GroupVersionAlignment alignment : versionAlignments )
+ {
+ groupVersionAlignments.put( alignment.getId(), alignment );
+ }
+ }
+
+ return groupVersionAlignments;
+ }
+
+ private void setAlignment( Artifact artifact, Map groupVersionAlignments )
+ {
+ GroupVersionAlignment alignment = groupVersionAlignments.get( artifact.getGroupId() );
+
+ if ( alignment != null )
+ {
+ if ( !alignment.getExcludes().contains( artifact.getArtifactId() ) )
+ {
+ artifact.setVersion( alignment.getVersion() );
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtils.java b/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtils.java
index 4697ae9ca..3777d78f5 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtils.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtils.java
@@ -313,7 +313,7 @@ public static String fixRelativeRefs( @Nonnull String src )
if ( value.contains( "." + sep ) )
{
- List parts = new ArrayList();
+ List parts = new ArrayList<>();
parts.addAll( Arrays.asList( value.split( sep.replace( "\\", "\\\\" ) ) ) );
for ( ListIterator it = parts.listIterator(); it.hasNext(); )
diff --git a/src/main/java/org/apache/maven/plugins/assembly/utils/FilterUtils.java b/src/main/java/org/apache/maven/plugins/assembly/utils/FilterUtils.java
index f3edf94ef..a99c4d267 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/utils/FilterUtils.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/utils/FilterUtils.java
@@ -54,7 +54,7 @@ public static Set filterProjects( final Set projects
final List excludes, final boolean actTransitively,
final Logger logger )
{
- final List allFilters = new ArrayList();
+ final List allFilters = new ArrayList<>();
final AndArtifactFilter filter = new AndArtifactFilter();
@@ -75,7 +75,7 @@ public static Set filterProjects( final Set projects
allFilters.add( excludeFilter );
}
- Set result = new LinkedHashSet( projects.size() );
+ Set result = new LinkedHashSet<>( projects.size() );
for ( MavenProject project : projects )
{
final Artifact artifact = project.getArtifact();
@@ -102,7 +102,7 @@ public static void filterArtifacts( final Set artifacts, final List allFilters = new ArrayList();
+ final List allFilters = new ArrayList<>();
final AndArtifactFilter filter = new AndArtifactFilter();
@@ -211,7 +211,7 @@ public static ScopeFilter newScopeFilter( final String rootScope )
*/
public static ScopeFilter newScopeFilter( final Collection rootScopes )
{
- Set scopes = new HashSet();
+ Set scopes = new HashSet<>();
for ( String rootScope : rootScopes )
{
diff --git a/src/main/java/org/apache/maven/plugins/assembly/utils/InterpolationConstants.java b/src/main/java/org/apache/maven/plugins/assembly/utils/InterpolationConstants.java
index e0fdf99eb..c990a9f5e 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/utils/InterpolationConstants.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/utils/InterpolationConstants.java
@@ -37,13 +37,13 @@ public final class InterpolationConstants
static
{
- final List projectPrefixes = new ArrayList();
+ final List projectPrefixes = new ArrayList<>();
projectPrefixes.add( "pom." );
projectPrefixes.add( "project." );
PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
- final List projectPropertiesPrefixes = new ArrayList();
+ final List projectPropertiesPrefixes = new ArrayList<>();
projectPropertiesPrefixes.add( "pom.properties." );
projectPropertiesPrefixes.add( "project.properties." );
diff --git a/src/main/java/org/apache/maven/plugins/assembly/utils/ProjectUtils.java b/src/main/java/org/apache/maven/plugins/assembly/utils/ProjectUtils.java
index 269b7793c..c9a682148 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/utils/ProjectUtils.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/utils/ProjectUtils.java
@@ -62,9 +62,9 @@ public static Set getProjectModules( @Nonnull final MavenProject p
{
final Set singleParentSet = Collections.singleton( project );
- final Set moduleCandidates = new LinkedHashSet( reactorProjects );
+ final Set moduleCandidates = new LinkedHashSet<>( reactorProjects );
- final Set modules = new LinkedHashSet();
+ final Set modules = new LinkedHashSet<>();
// we temporarily add the master project to the modules set, since this
// set is pulling double duty as a set of
@@ -96,7 +96,7 @@ public static Set getProjectModules( @Nonnull final MavenProject p
Set currentPotentialParents;
if ( includeSubModules )
{
- currentPotentialParents = new LinkedHashSet( modules );
+ currentPotentialParents = new LinkedHashSet<>( modules );
}
else
{
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiverTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiverTest.java
index 7b1ac8f17..b86499763 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/archiver/AssemblyProxyArchiverTest.java
@@ -126,7 +126,7 @@ public void addFile_NoPerms_CallAcceptFilesOnlyOnce()
EasyMock.expectLastCall().anyTimes();
final CounterSelector counter = new CounterSelector( true );
- final List selectors = new ArrayList();
+ final List selectors = new ArrayList<>();
selectors.add( counter );
mm.replayAll();
@@ -157,7 +157,7 @@ public void addDirectory_NoPerms_CallAcceptFilesOnlyOnce()
delegate.setDestFile( output );
final CounterSelector counter = new CounterSelector( true );
- final List selectors = new ArrayList();
+ final List selectors = new ArrayList<>();
selectors.add( counter );
final AssemblyProxyArchiver archiver =
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparatorTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparatorTest.java
index abef5a2b8..d6815ac83 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparatorTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparatorTest.java
@@ -41,7 +41,7 @@ public class AssemblyArchiverPhaseComparatorTest
public void comparatorSortsCorrectly()
throws Exception
{
- List items = new ArrayList();
+ List items = new ArrayList<>();
Unordered2 u2 = new Unordered2();
items.add( u2 );
Ordered2 o2 = new Ordered2();
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
index 86b9de0fb..20decc159 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
@@ -277,7 +277,7 @@ public void testExecute_ShouldAddOneModuleSetWithOneModuleInIt()
final File moduleArtifactFile = moduleArtifactMock.setNewFile();
module.setArtifact( moduleArtifactMock.getArtifact() );
- final List projects = new ArrayList();
+ final List projects = new ArrayList<>();
projects.add( module );
@@ -648,7 +648,7 @@ public void testGetModuleProjects_ShouldReturnNothingWhenReactorContainsTwoSibli
final MavenProject project2 = createProject( "group", "artifact2", "version", null );
- final List projects = new ArrayList();
+ final List projects = new ArrayList<>();
projects.add( project );
projects.add( project2 );
@@ -679,7 +679,7 @@ public void testGetModuleProjects_ShouldReturnModuleOfCurrentProject()
final MavenProject project2 = createProject( "group", "artifact2", "version", project );
- final List projects = new ArrayList();
+ final List projects = new ArrayList<>();
projects.add( project );
projects.add( project2 );
@@ -715,7 +715,7 @@ public void testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject(
final MavenProject project2 = createProject( "group", "artifact2", "version", project );
final MavenProject project3 = createProject( "group", "artifact3", "version", project2 );
- final List projects = new ArrayList();
+ final List projects = new ArrayList<>();
projects.add( project );
projects.add( project2 );
projects.add( project3 );
@@ -732,7 +732,7 @@ public void testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject(
assertEquals( 2, moduleProjects.size() );
- final List check = new ArrayList();
+ final List check = new ArrayList<>();
check.add( project2 );
check.add( project3 );
@@ -758,7 +758,7 @@ public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively(
final MavenProject project3 = createProject( "group", "artifact3", "version", project2 );
addArtifact( project3, mm, true );
- final List projects = new ArrayList();
+ final List projects = new ArrayList<>();
projects.add( project );
projects.add( project2 );
projects.add( project3 );
@@ -789,7 +789,7 @@ private ArtifactMock addArtifact( final MavenProject project, final EasyMockSupp
if ( expectDepTrailCheck )
{
- final LinkedList depTrail = new LinkedList();
+ final LinkedList depTrail = new LinkedList<>();
MavenProject parent = project.getParent();
while ( parent != null )
@@ -811,7 +811,7 @@ private void verifyResultIs( final List check, final Set checkTooMany = new HashSet( moduleProjects );
+ final Set checkTooMany = new HashSet<>( moduleProjects );
checkTooMany.removeAll( check );
if ( !checkTooMany.isEmpty() )
@@ -826,7 +826,7 @@ private void verifyResultIs( final List check, final Set checkTooFew = new HashSet( check );
+ final Set checkTooFew = new HashSet<>( check );
checkTooFew.removeAll( moduleProjects );
if ( !checkTooFew.isEmpty() )
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
index 8ab9625a6..b322df9b1 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
@@ -299,7 +299,7 @@ public void testGetDependencyArtifacts_ShouldFilterOneDependencyArtifactViaInclu
{
final MavenProject project = new MavenProject( new Model() );
- final Set artifacts = new HashSet();
+ final Set artifacts = new HashSet<>();
final ArtifactMock am = new ArtifactMock( mockManager, "group", "artifact", "1.0", "jar", false );
am.setDependencyTrail( Collections.singletonList( project.getId() ) );
@@ -335,7 +335,7 @@ public void testGetDependencyArtifacts_ShouldIgnoreTransitivePathFilteringWhenIn
{
final MavenProject project = new MavenProject( new Model() );
- final Set artifacts = new HashSet();
+ final Set artifacts = new HashSet<>();
final ArtifactMock am = new ArtifactMock( mockManager, "group", "artifact", "1.0", "jar", false );
artifacts.add( am.getArtifact() );
diff --git a/src/test/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfoTest.java b/src/test/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfoTest.java
index 86c2b717f..9f682113b 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfoTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/artifact/ResolutionManagementInfoTest.java
@@ -68,14 +68,14 @@ public void testAddMultiArtifactWithReplacemen()
Artifact a3 =
new DefaultArtifact( "groupid", "a3", VersionRange.createFromVersion( "1.0" ), "test", "jar", null,
new DefaultArtifactHandler() );
- rmi.addArtifacts( new HashSet( Arrays.asList( a1, a2, a3 ) ) );
+ rmi.addArtifacts( new HashSet<>( Arrays.asList( a1, a2, a3 ) ) );
Artifact b2 =
new DefaultArtifact( "groupid", "a2", VersionRange.createFromVersion( "1.0" ), "compile", "jar", null,
new DefaultArtifactHandler() );
Artifact b3 =
new DefaultArtifact( "groupid", "a3", VersionRange.createFromVersion( "1.0" ), "compile", "jar", null,
new DefaultArtifactHandler() );
- rmi.addArtifacts( new HashSet( Arrays.asList( b2, b3 ) ) );
+ rmi.addArtifacts( new HashSet<>( Arrays.asList( b2, b3 ) ) );
assertEquals( 3, rmi.getArtifacts().size() );
int compile = 0;
int test = 0;
diff --git a/src/test/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilterTest.java b/src/test/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilterTest.java
index f09163181..df2718ac1 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilterTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/filter/ComponentsXmlArchiverFileFilterTest.java
@@ -117,7 +117,7 @@ public void testAddComponentsXml_ShouldAddComponentWithRoleHint()
public void testAddComponentsXml_ShouldAddTwoComponentsWithRoleHints()
throws IOException, XmlPullParserException
{
- final List defs = new ArrayList();
+ final List defs = new ArrayList<>();
defs.add( new ComponentDef( "role", "hint", "org.apache.maven.Impl" ) );
defs.add( new ComponentDef( "role", "hint2", "org.apache.maven.Impl2" ) );
@@ -146,7 +146,7 @@ public void testAddToArchive_ShouldWriteComponentWithoutHintToFile()
{
final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", null, "impl" ) );
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<>();
filter.components.put( "role", dom );
final FileCatchingArchiver fca = new FileCatchingArchiver();
@@ -173,7 +173,7 @@ public void testAddToArchive_ShouldWriteComponentWithHintToFile()
{
final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<>();
filter.components.put( "rolehint", dom );
final FileCatchingArchiver fca = new FileCatchingArchiver();
@@ -198,7 +198,7 @@ public void testAddToArchive_ShouldWriteComponentWithHintToFile()
public void testAddToArchive_ShouldWriteTwoComponentToFile()
throws IOException, ArchiverException, JDOMException
{
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<>();
final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
@@ -239,7 +239,7 @@ public void testAddToArchive_ShouldWriteTwoComponentToFile()
public void testAddToArchive_ShouldWriteTwoComponentToArchivedFile()
throws IOException, ArchiverException, JDOMException
{
- filter.components = new LinkedHashMap();
+ filter.components = new LinkedHashMap<>();
final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );
diff --git a/src/test/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReaderTest.java b/src/test/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReaderTest.java
index 8acff0083..9e4dda2c8 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReaderTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/io/DefaultAssemblyReaderTest.java
@@ -883,7 +883,7 @@ public void testReadAssemblies_ShouldGetAssemblyDescriptorFromFileArray()
final Assembly assembly2 = new Assembly();
assembly2.setId( "test2" );
- final List assemblies = new ArrayList();
+ final List assemblies = new ArrayList<>();
assemblies.add( assembly1 );
assemblies.add( assembly2 );
@@ -935,7 +935,7 @@ public void testReadAssemblies_ShouldGetAssemblyDescriptorFromDirectory()
final Assembly assembly2 = new Assembly();
assembly2.setId( "test2" );
- final List assemblies = new ArrayList();
+ final List assemblies = new ArrayList<>();
assemblies.add( assembly1 );
assemblies.add( assembly2 );
@@ -966,7 +966,7 @@ public void testReadAssemblies_ShouldGetTwoAssemblyDescriptorsFromDirectoryWithT
final Assembly assembly2 = new Assembly();
assembly2.setId( "test2" );
- final List assemblies = new ArrayList();
+ final List assemblies = new ArrayList<>();
assemblies.add( assembly1 );
assemblies.add( assembly2 );
@@ -993,7 +993,7 @@ public void testReadAssemblies_ShouldGetTwoAssemblyDescriptorsFromDirectoryWithT
private List