You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2023/04/02 21:18:02 UTC
[maven-assembly-plugin] 02/02: [MASSEMBLY-972] Apply formatting
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MASSEMBLY-972
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git
commit 9ca9ab02c05138e6d254df48c0fcb16ba48f7d1a
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun Apr 2 23:13:01 2023 +0200
[MASSEMBLY-972] Apply formatting
---
pom.xml | 56 +-
.../assembly/AssemblerConfigurationSource.java | 8 +-
.../InvalidAssemblerConfigurationException.java | 18 +-
.../assembly/archive/ArchiveCreationException.java | 18 +-
.../archive/ArchiveExpansionException.java | 18 +-
.../plugins/assembly/archive/AssemblyArchiver.java | 24 +-
.../assembly/archive/DefaultAssemblyArchiver.java | 547 ++++++------
.../archive/ManifestCreationFinalizer.java | 101 +--
.../archive/archiver/AssemblyProxyArchiver.java | 954 ++++++++-------------
.../archive/archiver/PrefixedArchivedFileSet.java | 69 +-
.../assembly/archive/archiver/PrefixedFileSet.java | 88 +-
.../archive/phase/AssemblyArchiverPhase.java | 12 +-
.../phase/AssemblyArchiverPhaseComparator.java | 23 +-
.../archive/phase/DependencySetAssemblyPhase.java | 53 +-
.../archive/phase/FileItemAssemblyPhase.java | 152 ++--
.../archive/phase/FileSetAssemblyPhase.java | 37 +-
.../archive/phase/ModuleSetAssemblyPhase.java | 538 ++++++------
.../plugins/assembly/archive/phase/PhaseOrder.java | 6 +-
.../assembly/archive/task/AddArtifactTask.java | 288 +++----
.../archive/task/AddDependencySetsTask.java | 403 ++++-----
.../assembly/archive/task/AddDirectoryTask.java | 145 ++--
.../assembly/archive/task/AddFileSetsTask.java | 171 ++--
.../assembly/archive/task/ArchiverTask.java | 11 +-
.../artifact/DefaultDependencyResolver.java | 142 ++-
.../artifact/DependencyResolutionException.java | 13 +-
.../assembly/artifact/DependencyResolver.java | 32 +-
.../artifact/ResolutionManagementInfo.java | 67 +-
.../filter/AbstractLineAggregatingHandler.java | 125 ++-
.../filter/ComponentsXmlArchiverFileFilter.java | 159 ++--
.../filter/ContainerDescriptorHandler.java | 9 +-
.../assembly/filter/MetaInfServicesHandler.java | 29 +-
.../assembly/filter/MetaInfSpringHandler.java | 27 +-
.../filter/SimpleAggregatingDescriptorHandler.java | 153 ++--
.../format/AssemblyFormattingException.java | 18 +-
.../plugins/assembly/format/ReaderFormatter.java | 185 ++--
.../assembly/functions/MavenProjectConsumer.java | 8 +-
.../plugins/assembly/functions/MavenProjects.java | 94 +-
.../assembly/functions/ModuleSetConsumer.java | 12 +-
.../internal/DebugConfigurationListener.java | 59 +-
.../internal/SarPlexusIoResourceCollection.java | 11 +-
.../assembly/internal/SarUnArchiverProvider.java | 11 +-
.../interpolation/AssemblyExpressionEvaluator.java | 41 +-
.../AssemblyInterpolationException.java | 13 +-
.../interpolation/AssemblyInterpolator.java | 144 ++--
.../plugins/assembly/io/AssemblyReadException.java | 18 +-
.../maven/plugins/assembly/io/AssemblyReader.java | 29 +-
.../io/ClasspathResourceLocatorStrategy.java | 32 +-
.../plugins/assembly/io/DefaultAssemblyReader.java | 440 ++++------
.../plugins/assembly/io/DefaultMessageHolder.java | 386 ++++-----
.../maven/plugins/assembly/io/FileLocation.java | 92 +-
.../plugins/assembly/io/FileLocatorStrategy.java | 24 +-
.../apache/maven/plugins/assembly/io/Location.java | 13 +-
.../apache/maven/plugins/assembly/io/Locator.java | 44 +-
.../maven/plugins/assembly/io/LocatorStrategy.java | 9 +-
.../maven/plugins/assembly/io/MessageHolder.java | 59 +-
.../maven/plugins/assembly/io/MessageLevels.java | 55 +-
.../maven/plugins/assembly/io/MessageSink.java | 18 +-
.../io/PrefixedClasspathLocatorStrategy.java | 39 +-
.../assembly/io/RelativeFileLocatorStrategy.java | 29 +-
.../maven/plugins/assembly/io/URLLocation.java | 31 +-
.../maven/plugins/assembly/model/Assemblies.java | 18 +-
.../assembly/mojos/AbstractAssemblyMojo.java | 456 ++++------
.../plugins/assembly/mojos/SingleAssemblyMojo.java | 42 +-
.../plugins/assembly/resolved/AssemblyId.java | 22 +-
.../plugins/assembly/utils/AssemblyFileUtils.java | 80 +-
.../assembly/utils/AssemblyFormatUtils.java | 370 ++++----
.../maven/plugins/assembly/utils/FilterUtils.java | 195 ++---
.../assembly/utils/InterpolationConstants.java | 26 +-
.../maven/plugins/assembly/utils/LineEndings.java | 32 +-
.../plugins/assembly/utils/LineEndingsUtils.java | 130 +--
.../assembly/utils/LinuxLineFeedInputStream.java | 63 +-
.../maven/plugins/assembly/utils/ProjectUtils.java | 115 +--
.../assembly/utils/TypeConversionUtils.java | 99 +--
.../assembly/utils/WindowsLineFeedInputStream.java | 66 +-
.../archive/DefaultAssemblyArchiverTest.java | 614 ++++++-------
.../archive/ManifestCreationFinalizerTest.java | 74 +-
.../archiver/AssemblyProxyArchiverTest.java | 196 ++---
.../phase/AssemblyArchiverPhaseComparatorTest.java | 77 +-
.../phase/DependencySetAssemblyPhaseTest.java | 113 ++-
.../archive/phase/FileItemAssemblyPhaseTest.java | 460 +++++-----
.../archive/phase/FileSetAssemblyPhaseTest.java | 93 +-
.../archive/phase/ModuleSetAssemblyPhaseTest.java | 937 ++++++++++----------
.../assembly/archive/task/AddArtifactTaskTest.java | 290 +++----
.../archive/task/AddDependencySetsTaskTest.java | 600 ++++++-------
.../archive/task/AddDirectoryTaskTest.java | 126 ++-
.../assembly/archive/task/AddFileSetsTaskTest.java | 243 +++---
.../artifact/DefaultDependencyResolverTest.java | 194 ++---
.../artifact/ResolutionManagementInfoTest.java | 128 +--
.../ComponentsXmlArchiverFileFilterTest.java | 578 ++++++-------
.../assembly/format/ReaderFormatterTest.java | 167 ++--
.../AssemblyExpressionEvaluatorTest.java | 141 ++-
.../interpolation/AssemblyInterpolatorTest.java | 237 +++--
.../assembly/io/DefaultAssemblyReaderTest.java | 655 +++++++-------
.../io/PrefixedClasspathLocatorStrategyTest.java | 53 +-
.../assembly/testutils/PojoConfigSource.java | 259 ++----
.../assembly/utils/AssemblyFormatUtilsTest.java | 899 +++++++++----------
.../plugins/assembly/utils/FilterUtilsTest.java | 396 +++++----
.../assembly/utils/LineEndingsUtilsTest.java | 213 ++---
.../utils/LinuxLineFeedInputStreamTest.java | 87 +-
.../plugins/assembly/utils/ProjectUtilsTest.java | 209 ++---
.../assembly/utils/TypeConversionUtilsTest.java | 98 +--
.../utils/WindowsLineFeedInputStreamTest.java | 86 +-
102 files changed, 6998 insertions(+), 9349 deletions(-)
diff --git a/pom.xml b/pom.xml
index d6b53351..8fe0d474 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,13 +17,12 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>maven-plugins</artifactId>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugins</artifactId>
<version>39</version>
<relativePath />
</parent>
@@ -36,6 +34,15 @@ under the License.
<name>Apache Maven Assembly Plugin</name>
<description>A Maven plugin to create archives of your project's sources, classes, dependencies etc. from flexible assembly descriptors.</description>
+ <contributors>
+ <contributor>
+ <name>Stephen Colebourne</name>
+ </contributor>
+ <contributor>
+ <name>Tony Jewell</name>
+ </contributor>
+ </contributors>
+
<prerequisites>
<maven>${mavenVersion}</maven>
</prerequisites>
@@ -43,8 +50,8 @@ under the License.
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-assembly-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-assembly-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
@@ -74,15 +81,6 @@ under the License.
<project.build.outputTimestamp>2023-02-19T15:09:17Z</project.build.outputTimestamp>
</properties>
- <contributors>
- <contributor>
- <name>Stephen Colebourne</name>
- </contributor>
- <contributor>
- <name>Tony Jewell</name>
- </contributor>
- </contributors>
-
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -240,8 +238,8 @@ under the License.
<build>
<resources>
<resource>
- <directory>src/main/resources</directory>
<filtering>true</filtering>
+ <directory>src/main/resources</directory>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources/plexus</directory>
@@ -314,21 +312,21 @@ under the License.
<executions>
<execution>
<id>mdo</id>
- <phase>generate-sources</phase>
<goals>
<goal>xpp3-reader</goal>
<goal>xpp3-writer</goal>
<goal>java</goal>
<goal>xsd</goal>
</goals>
+ <phase>generate-sources</phase>
</execution>
<execution>
<id>mdo-site</id>
- <phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
<goal>xsd</goal>
</goals>
+ <phase>pre-site</phase>
</execution>
</executions>
</plugin>
@@ -354,6 +352,18 @@ under the License.
</properties>
<showVersion>true</showVersion>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.23.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.github.luben</groupId>
+ <artifactId>zstd-jni</artifactId>
+ <version>1.5.4-2</version>
+ </dependency>
+ </dependencies>
<executions>
<execution>
<id>integration-test</id>
@@ -374,18 +384,6 @@ under the License.
</configuration>
</execution>
</executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
- <version>1.23.0</version>
- </dependency>
- <dependency>
- <groupId>com.github.luben</groupId>
- <artifactId>zstd-jni</artifactId>
- <version>1.5.4-2</version>
- </dependency>
- </dependencies>
</plugin>
</plugins>
</build>
diff --git a/src/main/java/org/apache/maven/plugins/assembly/AssemblerConfigurationSource.java b/src/main/java/org/apache/maven/plugins/assembly/AssemblerConfigurationSource.java
index af669a8f..49a14279 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/AssemblerConfigurationSource.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/AssemblerConfigurationSource.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly;
import java.io.File;
import java.util.List;
@@ -33,8 +32,7 @@ import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
/**
*
*/
-public interface AssemblerConfigurationSource
-{
+public interface AssemblerConfigurationSource {
/**
* @return The descriptors.
*/
@@ -109,7 +107,7 @@ public interface AssemblerConfigurationSource
* @return The filters.
*/
List<String> getFilters();
-
+
/**
* @return the additional properties
*/
diff --git a/src/main/java/org/apache/maven/plugins/assembly/InvalidAssemblerConfigurationException.java b/src/main/java/org/apache/maven/plugins/assembly/InvalidAssemblerConfigurationException.java
index 3fe2b14c..22824169 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/InvalidAssemblerConfigurationException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/InvalidAssemblerConfigurationException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,12 @@ package org.apache.maven.plugins.assembly;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly;
/**
*
*/
-public class InvalidAssemblerConfigurationException
- extends Exception
-{
+public class InvalidAssemblerConfigurationException extends Exception {
private static final long serialVersionUID = 1L;
@@ -32,17 +29,14 @@ public class InvalidAssemblerConfigurationException
* @param message The message.
* @param error The error
*/
- public InvalidAssemblerConfigurationException( final String message, final Throwable error )
- {
- super( message, error );
+ public InvalidAssemblerConfigurationException(final String message, final Throwable error) {
+ super(message, error);
}
/**
* @param message The message.
*/
- public InvalidAssemblerConfigurationException( final String message )
- {
- super( message );
+ public InvalidAssemblerConfigurationException(final String message) {
+ super(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveCreationException.java b/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveCreationException.java
index 70079839..658483fc 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveCreationException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveCreationException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,12 @@ package org.apache.maven.plugins.assembly.archive;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive;
/**
*
*/
-public class ArchiveCreationException
- extends Exception
-{
+public class ArchiveCreationException extends Exception {
private static final long serialVersionUID = 1L;
@@ -34,17 +31,14 @@ public class ArchiveCreationException
* @param message The message to use.
* @param error The error.
*/
- public ArchiveCreationException( final String message, final Throwable error )
- {
- super( message, error );
+ public ArchiveCreationException(final String message, final Throwable error) {
+ super(message, error);
}
/**
* @param message The message.
*/
- public ArchiveCreationException( final String message )
- {
- super( message );
+ public ArchiveCreationException(final String message) {
+ super(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveExpansionException.java b/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveExpansionException.java
index f3c56ef0..b1d3ec1d 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveExpansionException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/ArchiveExpansionException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,12 @@ package org.apache.maven.plugins.assembly.archive;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive;
/**
*
*/
-public class ArchiveExpansionException
- extends Exception
-{
+public class ArchiveExpansionException extends Exception {
private static final long serialVersionUID = 1L;
@@ -32,17 +29,14 @@ public class ArchiveExpansionException
* @param message The message to use for this instance.
* @param error The error which has been thrown.
*/
- public ArchiveExpansionException( final String message, final Throwable error )
- {
- super( message, error );
+ public ArchiveExpansionException(final String message, final Throwable error) {
+ super(message, error);
}
/**
* @param message The message.
*/
- public ArchiveExpansionException( final String message )
- {
- super( message );
+ public ArchiveExpansionException(final String message) {
+ super(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/AssemblyArchiver.java b/src/main/java/org/apache/maven/plugins/assembly/archive/AssemblyArchiver.java
index d3a70ed6..efadb58f 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/AssemblyArchiver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/AssemblyArchiver.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,22 +16,22 @@ package org.apache.maven.plugins.assembly.archive;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive;
+
+import java.io.File;
+import java.util.Date;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
import org.apache.maven.plugins.assembly.model.Assembly;
-import java.io.File;
-import java.util.Date;
-
/**
* Creates an archive
*
*
*/
-public interface AssemblyArchiver
-{
+public interface AssemblyArchiver {
/**
* Create the assembly archive. Generally:
* <ol>
@@ -60,7 +58,13 @@ public interface AssemblyArchiver
* @throws org.apache.maven.plugins.assembly.format.AssemblyFormattingException when formatting fails
* @throws org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException when the configuration is bad
*/
- File createArchive( Assembly assembly, String fullName, String format, AssemblerConfigurationSource configSource,
- boolean recompressZippedFiles, String mergeManifestMode, Date sourceDateEpoch )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException;
+ File createArchive(
+ Assembly assembly,
+ String fullName,
+ String format,
+ AssemblerConfigurationSource configSource,
+ boolean recompressZippedFiles,
+ String mergeManifestMode,
+ Date sourceDateEpoch)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException;
}
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 f829330a..6ec010c8 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +16,22 @@ package org.apache.maven.plugins.assembly.archive;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive;
import javax.inject.Inject;
import javax.inject.Named;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugins.assembly.archive.archiver.AssemblyProxyArchiver;
@@ -65,17 +75,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
import static java.util.Objects.requireNonNull;
/**
@@ -88,35 +87,33 @@ import static java.util.Objects.requireNonNull;
*
*/
@Named
-public class DefaultAssemblyArchiver implements AssemblyArchiver
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultAssemblyArchiver.class );
+public class DefaultAssemblyArchiver implements AssemblyArchiver {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAssemblyArchiver.class);
private final ArchiverManager archiverManager;
private final List<AssemblyArchiverPhase> assemblyPhases;
- @SuppressWarnings( "MismatchedQueryAndUpdateOfCollection" )
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final Map<String, ContainerDescriptorHandler> containerDescriptorHandlers;
private final PlexusContainer container;
-
@Inject
- public DefaultAssemblyArchiver( ArchiverManager archiverManager, List<AssemblyArchiverPhase> assemblyPhases,
- Map<String, ContainerDescriptorHandler> containerDescriptorHandlers,
- PlexusContainer container )
- {
- this.archiverManager = requireNonNull( archiverManager );
- this.assemblyPhases = requireNonNull( assemblyPhases );
- this.containerDescriptorHandlers = requireNonNull( containerDescriptorHandlers );
- this.container = requireNonNull( container );
+ public DefaultAssemblyArchiver(
+ ArchiverManager archiverManager,
+ List<AssemblyArchiverPhase> assemblyPhases,
+ Map<String, ContainerDescriptorHandler> containerDescriptorHandlers,
+ PlexusContainer container) {
+ this.archiverManager = requireNonNull(archiverManager);
+ this.assemblyPhases = requireNonNull(assemblyPhases);
+ this.containerDescriptorHandlers = requireNonNull(containerDescriptorHandlers);
+ this.container = requireNonNull(container);
}
- private List<AssemblyArchiverPhase> sortedPhases()
- {
- List<AssemblyArchiverPhase> sorted = new ArrayList<>( assemblyPhases );
- Collections.sort( sorted, new AssemblyArchiverPhaseComparator() );
+ private List<AssemblyArchiverPhase> sortedPhases() {
+ List<AssemblyArchiverPhase> sorted = new ArrayList<>(assemblyPhases);
+ Collections.sort(sorted, new AssemblyArchiverPhaseComparator());
return sorted;
}
@@ -124,136 +121,129 @@ public class DefaultAssemblyArchiver implements AssemblyArchiver
* {@inheritDoc}
*/
@Override
- public File createArchive( final Assembly assembly, final String fullName, final String format,
- final AssemblerConfigurationSource configSource, boolean recompressZippedFiles,
- String mergeManifestMode, Date outputTimestamp )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
- {
- validate( assembly );
+ public File createArchive(
+ final Assembly assembly,
+ final String fullName,
+ final String format,
+ final AssemblerConfigurationSource configSource,
+ boolean recompressZippedFiles,
+ String mergeManifestMode,
+ Date outputTimestamp)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
+ validate(assembly);
String filename = fullName;
- if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) )
- {
+ if (!configSource.isIgnoreDirFormatExtensions() || !format.startsWith("dir")) {
filename += "." + format;
}
- AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() );
+ AssemblyFileUtils.verifyTempDirectoryAvailability(configSource.getTemporaryRootDirectory());
final File outputDirectory = configSource.getOutputDirectory();
- final File destFile = new File( outputDirectory, filename );
+ final File destFile = new File(outputDirectory, filename);
- try
- {
+ try {
final String finalName = configSource.getFinalName();
final String specifiedBasedir = assembly.getBaseDirectory();
String basedir = finalName;
- if ( specifiedBasedir != null )
- {
- basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource,
- AssemblyFormatUtils.moduleProjectInterpolator(
- configSource.getProject() ),
- AssemblyFormatUtils.artifactProjectInterpolator(
- null ) );
+ if (specifiedBasedir != null) {
+ basedir = AssemblyFormatUtils.getOutputDirectory(
+ specifiedBasedir,
+ finalName,
+ configSource,
+ AssemblyFormatUtils.moduleProjectInterpolator(configSource.getProject()),
+ AssemblyFormatUtils.artifactProjectInterpolator(null));
}
final List<ContainerDescriptorHandler> containerHandlers =
- selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource );
-
- final Archiver archiver =
- createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers,
- recompressZippedFiles, mergeManifestMode, outputTimestamp );
-
- archiver.setDestFile( destFile );
-
- for ( AssemblyArchiverPhase phase : sortedPhases() )
- {
- phase.execute( assembly, archiver, configSource );
+ selectContainerDescriptorHandlers(assembly.getContainerDescriptorHandlers(), configSource);
+
+ final Archiver archiver = createArchiver(
+ format,
+ assembly.isIncludeBaseDirectory(),
+ basedir,
+ configSource,
+ containerHandlers,
+ recompressZippedFiles,
+ mergeManifestMode,
+ outputTimestamp);
+
+ archiver.setDestFile(destFile);
+
+ for (AssemblyArchiverPhase phase : sortedPhases()) {
+ phase.execute(assembly, archiver, configSource);
}
archiver.createArchive();
- }
- catch ( final ArchiverException | IOException e )
- {
+ } catch (final ArchiverException | IOException e) {
throw new ArchiveCreationException(
- "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e );
- }
- catch ( final NoSuchArchiverException e )
- {
+ "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e);
+ } catch (final NoSuchArchiverException e) {
throw new ArchiveCreationException(
- "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'",
- e );
- }
- catch ( final DependencyResolutionException e )
- {
+ "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId()
+ + "'",
+ e);
+ } catch (final DependencyResolutionException e) {
throw new ArchiveCreationException(
- "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e );
+ "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e);
}
return destFile;
}
- private void validate( final Assembly assembly )
- throws InvalidAssemblerConfigurationException
- {
- if ( assembly.getId() == null || assembly.getId().trim().length() < 1 )
- {
- throw new InvalidAssemblerConfigurationException( "Assembly ID must be present and non-empty." );
+ private void validate(final Assembly assembly) throws InvalidAssemblerConfigurationException {
+ if (assembly.getId() == null || assembly.getId().trim().length() < 1) {
+ throw new InvalidAssemblerConfigurationException("Assembly ID must be present and non-empty.");
}
}
// CHECKSTYLE_OFF: LineLength
private List<ContainerDescriptorHandler> selectContainerDescriptorHandlers(
- List<ContainerDescriptorHandlerConfig> requestedContainerDescriptorHandlers,
- final AssemblerConfigurationSource configSource )
- throws InvalidAssemblerConfigurationException
- // CHECKSTYLE_ON: LineLength
- {
- LOGGER.debug( "All known ContainerDescriptorHandler components: " + ( containerDescriptorHandlers == null
- ? "none; map is null."
- : "" + containerDescriptorHandlers.keySet() ) );
-
- if ( requestedContainerDescriptorHandlers == null )
- {
+ List<ContainerDescriptorHandlerConfig> requestedContainerDescriptorHandlers,
+ final AssemblerConfigurationSource configSource)
+ throws InvalidAssemblerConfigurationException
+ // CHECKSTYLE_ON: LineLength
+ {
+ LOGGER.debug("All known ContainerDescriptorHandler components: "
+ + (containerDescriptorHandlers == null
+ ? "none; map is null."
+ : "" + containerDescriptorHandlers.keySet()));
+
+ if (requestedContainerDescriptorHandlers == null) {
requestedContainerDescriptorHandlers = new ArrayList<>();
}
final List<ContainerDescriptorHandler> handlers = new ArrayList<>();
final List<String> hints = new ArrayList<>();
- if ( !requestedContainerDescriptorHandlers.isEmpty() )
- {
- for ( final ContainerDescriptorHandlerConfig config : requestedContainerDescriptorHandlers )
- {
+ if (!requestedContainerDescriptorHandlers.isEmpty()) {
+ for (final ContainerDescriptorHandlerConfig config : requestedContainerDescriptorHandlers) {
final String hint = config.getHandlerName();
- final ContainerDescriptorHandler handler = containerDescriptorHandlers.get( hint );
+ final ContainerDescriptorHandler handler = containerDescriptorHandlers.get(hint);
- if ( handler == null )
- {
+ if (handler == null) {
throw new InvalidAssemblerConfigurationException(
- "Cannot find ContainerDescriptorHandler with hint: " + hint );
+ "Cannot find ContainerDescriptorHandler with hint: " + hint);
}
- LOGGER.debug(
- "Found container descriptor handler with hint: " + hint + " (component: " + handler + ")" );
+ LOGGER.debug("Found container descriptor handler with hint: " + hint + " (component: " + handler + ")");
- if ( config.getConfiguration() != null )
- {
- LOGGER.debug( "Configuring handler with:\n\n" + config.getConfiguration() + "\n\n" );
+ if (config.getConfiguration() != null) {
+ LOGGER.debug("Configuring handler with:\n\n" + config.getConfiguration() + "\n\n");
- configureContainerDescriptorHandler( handler, (Xpp3Dom) config.getConfiguration(), configSource );
+ configureContainerDescriptorHandler(handler, (Xpp3Dom) config.getConfiguration(), configSource);
}
- handlers.add( handler );
- hints.add( hint );
+ handlers.add(handler);
+ hints.add(hint);
}
}
- if ( !hints.contains( "plexus" ) )
- {
- handlers.add( new ComponentsXmlArchiverFileFilter() );
+ if (!hints.contains("plexus")) {
+ handlers.add(new ComponentsXmlArchiverFileFilter());
}
return handlers;
@@ -273,165 +263,154 @@ public class DefaultAssemblyArchiver implements AssemblyArchiver
* @throws org.codehaus.plexus.archiver.ArchiverException
* @throws org.codehaus.plexus.archiver.manager.NoSuchArchiverException
*/
- protected Archiver createArchiver( final String format, final boolean includeBaseDir, final String finalName,
- final AssemblerConfigurationSource configSource,
- final List<ContainerDescriptorHandler> containerHandlers,
- boolean recompressZippedFiles, String mergeManifestMode, Date outputTimestamp )
- throws NoSuchArchiverException
- {
+ protected Archiver createArchiver(
+ final String format,
+ final boolean includeBaseDir,
+ final String finalName,
+ final AssemblerConfigurationSource configSource,
+ final List<ContainerDescriptorHandler> containerHandlers,
+ boolean recompressZippedFiles,
+ String mergeManifestMode,
+ Date outputTimestamp)
+ throws NoSuchArchiverException {
Archiver archiver;
- if ( "txz".equals( format ) || "tgz".equals( format ) || "tbz2".equals( format ) || "tzst".equals( format )
- || format.startsWith( "tar" ) )
- {
- archiver = createTarArchiver( format, TarLongFileMode.valueOf( configSource.getTarLongFileMode() ) );
- }
- else if ( "war".equals( format ) )
- {
+ if ("txz".equals(format)
+ || "tgz".equals(format)
+ || "tbz2".equals(format)
+ || "tzst".equals(format)
+ || format.startsWith("tar")) {
+ archiver = createTarArchiver(format, TarLongFileMode.valueOf(configSource.getTarLongFileMode()));
+ } else if ("war".equals(format)) {
archiver = createWarArchiver();
- }
- else
- {
- archiver = archiverManager.getArchiver( format );
+ } else {
+ archiver = archiverManager.getArchiver(format);
}
- if ( archiver instanceof AbstractZipArchiver )
- {
- ( (AbstractZipArchiver) archiver ).setRecompressAddedZips( recompressZippedFiles );
+ if (archiver instanceof AbstractZipArchiver) {
+ ((AbstractZipArchiver) archiver).setRecompressAddedZips(recompressZippedFiles);
}
final List<FileSelector> extraSelectors = new ArrayList<>();
final List<ArchiveFinalizer> extraFinalizers = new ArrayList<>();
- if ( archiver instanceof JarArchiver )
- {
- if ( mergeManifestMode != null )
- {
- ( (JarArchiver) archiver ).setFilesetmanifest(
- JarArchiver.FilesetManifestConfig.valueOf( mergeManifestMode ) );
+ if (archiver instanceof JarArchiver) {
+ if (mergeManifestMode != null) {
+ ((JarArchiver) archiver)
+ .setFilesetmanifest(JarArchiver.FilesetManifestConfig.valueOf(mergeManifestMode));
}
- extraSelectors.add( new JarSecurityFileSelector() );
-
- extraFinalizers.add(
- new ManifestCreationFinalizer( configSource.getMavenSession(), configSource.getProject(),
- configSource.getJarArchiveConfiguration() ) );
+ extraSelectors.add(new JarSecurityFileSelector());
+ extraFinalizers.add(new ManifestCreationFinalizer(
+ configSource.getMavenSession(),
+ configSource.getProject(),
+ configSource.getJarArchiveConfiguration()));
}
- if ( configSource.getArchiverConfig() != null )
- {
- configureArchiver( archiver, configSource );
+ if (configSource.getArchiverConfig() != null) {
+ configureArchiver(archiver, configSource);
}
String prefix = "";
- if ( includeBaseDir )
- {
+ if (includeBaseDir) {
prefix = finalName;
}
- archiver = new AssemblyProxyArchiver( prefix, archiver, containerHandlers, extraSelectors, extraFinalizers,
- configSource.getWorkingDirectory() );
- if ( configSource.isDryRun() )
- {
- archiver = new DryRunArchiver( archiver, LOGGER );
+ archiver = new AssemblyProxyArchiver(
+ prefix,
+ archiver,
+ containerHandlers,
+ extraSelectors,
+ extraFinalizers,
+ configSource.getWorkingDirectory());
+ if (configSource.isDryRun()) {
+ archiver = new DryRunArchiver(archiver, LOGGER);
}
- archiver.setUseJvmChmod( configSource.isUpdateOnly() );
- archiver.setIgnorePermissions( configSource.isIgnorePermissions() );
- archiver.setForced( !configSource.isUpdateOnly() );
+ archiver.setUseJvmChmod(configSource.isUpdateOnly());
+ archiver.setIgnorePermissions(configSource.isIgnorePermissions());
+ archiver.setForced(!configSource.isUpdateOnly());
// configure for Reproducible Builds based on outputTimestamp value
- if ( outputTimestamp != null )
- {
- archiver.configureReproducible( outputTimestamp );
+ if (outputTimestamp != null) {
+ archiver.configureReproducible(outputTimestamp);
}
- if ( configSource.getOverrideUid() != null )
- {
- archiver.setOverrideUid( configSource.getOverrideUid() );
+ if (configSource.getOverrideUid() != null) {
+ archiver.setOverrideUid(configSource.getOverrideUid());
}
- if ( StringUtils.isNotBlank( configSource.getOverrideUserName() ) )
- {
- archiver.setOverrideUserName( StringUtils.trim( configSource.getOverrideUserName() ) );
+ if (StringUtils.isNotBlank(configSource.getOverrideUserName())) {
+ archiver.setOverrideUserName(StringUtils.trim(configSource.getOverrideUserName()));
}
- if ( configSource.getOverrideGid() != null )
- {
- archiver.setOverrideGid( configSource.getOverrideGid() );
+ if (configSource.getOverrideGid() != null) {
+ archiver.setOverrideGid(configSource.getOverrideGid());
}
- if ( StringUtils.isNotBlank( configSource.getOverrideGroupName() ) )
- {
- archiver.setOverrideGroupName( StringUtils.trim( configSource.getOverrideGroupName() ) );
+ if (StringUtils.isNotBlank(configSource.getOverrideGroupName())) {
+ archiver.setOverrideGroupName(StringUtils.trim(configSource.getOverrideGroupName()));
}
return archiver;
}
- private void configureContainerDescriptorHandler( final ContainerDescriptorHandler handler, final Xpp3Dom config,
- final AssemblerConfigurationSource configSource )
- throws InvalidAssemblerConfigurationException
- {
- LOGGER.debug( "Configuring handler: '" + handler.getClass().getName() + "' -->" );
+ private void configureContainerDescriptorHandler(
+ final ContainerDescriptorHandler handler,
+ final Xpp3Dom config,
+ final AssemblerConfigurationSource configSource)
+ throws InvalidAssemblerConfigurationException {
+ LOGGER.debug("Configuring handler: '" + handler.getClass().getName() + "' -->");
- try
- {
- configureComponent( handler, config, configSource );
- }
- catch ( final ComponentConfigurationException e )
- {
+ try {
+ configureComponent(handler, config, configSource);
+ } catch (final ComponentConfigurationException e) {
throw new InvalidAssemblerConfigurationException(
- "Failed to configure handler: " + handler.getClass().getName(), e );
- }
- catch ( final ComponentLookupException e )
- {
+ "Failed to configure handler: " + handler.getClass().getName(), e);
+ } catch (final ComponentLookupException e) {
throw new InvalidAssemblerConfigurationException(
- "Failed to lookup configurator for setup of handler: " + handler.getClass().getName(), e );
+ "Failed to lookup configurator for setup of handler: "
+ + handler.getClass().getName(),
+ e);
}
- LOGGER.debug( "-- end configuration --" );
+ LOGGER.debug("-- end configuration --");
}
- private void configureArchiver( final Archiver archiver, final AssemblerConfigurationSource configSource )
- {
+ private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
Xpp3Dom config;
- try
- {
- config = Xpp3DomBuilder.build( new StringReader( configSource.getArchiverConfig() ) );
- }
- catch ( final XmlPullParserException | IOException e )
- {
- throw new ArchiverException( "Failed to parse archiver configuration for: " + archiver.getClass().getName(),
- e );
+ try {
+ config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
+ } catch (final XmlPullParserException | IOException e) {
+ throw new ArchiverException(
+ "Failed to parse archiver configuration for: "
+ + archiver.getClass().getName(),
+ e);
}
- LOGGER.debug( "Configuring archiver: '" + archiver.getClass().getName() + "' -->" );
+ LOGGER.debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
- try
- {
- configureComponent( archiver, config, configSource );
- }
- catch ( final ComponentConfigurationException e )
- {
- throw new ArchiverException( "Failed to configure archiver: " + archiver.getClass().getName(), e );
- }
- catch ( final ComponentLookupException e )
- {
+ try {
+ configureComponent(archiver, config, configSource);
+ } catch (final ComponentConfigurationException e) {
throw new ArchiverException(
- "Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e );
+ "Failed to configure archiver: " + archiver.getClass().getName(), e);
+ } catch (final ComponentLookupException e) {
+ throw new ArchiverException(
+ "Failed to lookup configurator for setup of archiver: "
+ + archiver.getClass().getName(),
+ e);
}
- LOGGER.debug( "-- end configuration --" );
+ LOGGER.debug("-- end configuration --");
}
- private void configureComponent( final Object component, final Xpp3Dom config,
- final AssemblerConfigurationSource configSource )
- throws ComponentLookupException, ComponentConfigurationException
- {
- final ComponentConfigurator configurator = container.lookup( ComponentConfigurator.class, "basic" );
+ private void configureComponent(
+ final Object component, final Xpp3Dom config, final AssemblerConfigurationSource configSource)
+ throws ComponentLookupException, ComponentConfigurationException {
+ final ComponentConfigurator configurator = container.lookup(ComponentConfigurator.class, "basic");
- final ConfigurationListener listener = new DebugConfigurationListener( LOGGER );
+ final ConfigurationListener listener = new DebugConfigurationListener(LOGGER);
- final ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator( configSource );
+ final ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator(configSource);
- final XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( config );
+ final XmlPlexusConfiguration configuration = new XmlPlexusConfiguration(config);
final Object[] containerRealm = getContainerRealm();
@@ -439,116 +418,84 @@ public class DefaultAssemblyArchiver implements AssemblyArchiver
* NOTE: The signature of configureComponent() has changed in Maven 3.x, the reflection prevents a linkage error
* and makes the code work with both Maven 2 and 3.
*/
- try
- {
- final Method configureComponent =
- ComponentConfigurator.class.getMethod( "configureComponent", Object.class, PlexusConfiguration.class,
- ExpressionEvaluator.class, (Class<?>) containerRealm[1],
- ConfigurationListener.class );
-
- configureComponent.invoke( configurator, component, configuration, expressionEvaluator, containerRealm[0],
- listener );
- }
- catch ( final NoSuchMethodException | IllegalAccessException e )
- {
- throw new RuntimeException( e );
- }
- catch ( final InvocationTargetException e )
- {
- if ( e.getCause() instanceof ComponentConfigurationException )
- {
+ try {
+ final Method configureComponent = ComponentConfigurator.class.getMethod(
+ "configureComponent",
+ Object.class,
+ PlexusConfiguration.class,
+ ExpressionEvaluator.class,
+ (Class<?>) containerRealm[1],
+ ConfigurationListener.class);
+
+ configureComponent.invoke(
+ configurator, component, configuration, expressionEvaluator, containerRealm[0], listener);
+ } catch (final NoSuchMethodException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (final InvocationTargetException e) {
+ if (e.getCause() instanceof ComponentConfigurationException) {
throw (ComponentConfigurationException) e.getCause();
}
- throw new RuntimeException( e.getCause() );
+ throw new RuntimeException(e.getCause());
}
}
- private Object[] getContainerRealm()
- {
+ private Object[] getContainerRealm() {
/*
* NOTE: The return type of getContainerRealm() has changed in Maven 3.x, the reflection prevents a linkage
* error and makes the code work with both Maven 2 and 3.
*/
- try
- {
- final Method getContainerRealm = container.getClass().getMethod( "getContainerRealm" );
- return new Object[]{ getContainerRealm.invoke( container ), getContainerRealm.getReturnType() };
- }
- catch ( final NoSuchMethodException | IllegalAccessException e )
- {
- throw new RuntimeException( e );
- }
- catch ( final InvocationTargetException e )
- {
- throw new RuntimeException( e.getCause() );
+ try {
+ final Method getContainerRealm = container.getClass().getMethod("getContainerRealm");
+ return new Object[] {getContainerRealm.invoke(container), getContainerRealm.getReturnType()};
+ } catch (final NoSuchMethodException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (final InvocationTargetException e) {
+ throw new RuntimeException(e.getCause());
}
}
- protected Archiver createWarArchiver()
- throws NoSuchArchiverException
- {
- final WarArchiver warArchiver = (WarArchiver) archiverManager.getArchiver( "war" );
- warArchiver.setIgnoreWebxml( false ); // See MNG-1274
+ protected Archiver createWarArchiver() throws NoSuchArchiverException {
+ final WarArchiver warArchiver = (WarArchiver) archiverManager.getArchiver("war");
+ warArchiver.setIgnoreWebxml(false); // See MNG-1274
return warArchiver;
}
- protected Archiver createTarArchiver( final String format, final TarLongFileMode tarLongFileMode )
- throws NoSuchArchiverException
- {
- final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" );
- final int index = format.indexOf( '.' );
- if ( index >= 0 )
- {
+ protected Archiver createTarArchiver(final String format, final TarLongFileMode tarLongFileMode)
+ throws NoSuchArchiverException {
+ final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver("tar");
+ final int index = format.indexOf('.');
+ if (index >= 0) {
TarArchiver.TarCompressionMethod tarCompressionMethod;
// TODO: this should accept gz and bz2 as well so we can skip
// TODO: over the switch
- final String compression = format.substring( index + 1 );
- if ( "gz".equals( compression ) )
- {
+ final String compression = format.substring(index + 1);
+ if ("gz".equals(compression)) {
tarCompressionMethod = TarArchiver.TarCompressionMethod.gzip;
- }
- else if ( "bz2".equals( compression ) )
- {
+ } else if ("bz2".equals(compression)) {
tarCompressionMethod = TarArchiver.TarCompressionMethod.bzip2;
- }
- else if ( "xz".equals( compression ) )
- {
+ } else if ("xz".equals(compression)) {
tarCompressionMethod = TarArchiver.TarCompressionMethod.xz;
- }
- else if ( "snappy".equals( compression ) )
- {
+ } else if ("snappy".equals(compression)) {
tarCompressionMethod = TarArchiver.TarCompressionMethod.snappy;
- }
- else if ( "zst".equals( compression ) )
- {
+ } else if ("zst".equals(compression)) {
tarCompressionMethod = TarArchiver.TarCompressionMethod.zstd;
- }
- else
- {
+ } else {
// TODO: better handling
- throw new IllegalArgumentException( "Unknown compression format: " + compression );
+ throw new IllegalArgumentException("Unknown compression format: " + compression);
}
- tarArchiver.setCompression( tarCompressionMethod );
- }
- else if ( "tgz".equals( format ) )
- {
- tarArchiver.setCompression( TarArchiver.TarCompressionMethod.gzip );
- }
- else if ( "tbz2".equals( format ) )
- {
- tarArchiver.setCompression( TarArchiver.TarCompressionMethod.bzip2 );
- }
- else if ( "txz".equals( format ) )
- {
- tarArchiver.setCompression( TarArchiver.TarCompressionMethod.xz );
- }
- else if ( "tzst".equals( format ) )
- {
- tarArchiver.setCompression( TarArchiver.TarCompressionMethod.zstd );
- }
-
- tarArchiver.setLongfile( tarLongFileMode );
+ tarArchiver.setCompression(tarCompressionMethod);
+ } else if ("tgz".equals(format)) {
+ tarArchiver.setCompression(TarArchiver.TarCompressionMethod.gzip);
+ } else if ("tbz2".equals(format)) {
+ tarArchiver.setCompression(TarArchiver.TarCompressionMethod.bzip2);
+ } else if ("txz".equals(format)) {
+ tarArchiver.setCompression(TarArchiver.TarCompressionMethod.xz);
+ } else if ("tzst".equals(format)) {
+ tarArchiver.setCompression(TarArchiver.TarCompressionMethod.zstd);
+ }
+
+ tarArchiver.setLongfile(tarLongFileMode);
return tarArchiver;
}
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 334ea66a..98383bbc 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,15 @@ package org.apache.maven.plugins.assembly.archive;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
@@ -31,20 +38,10 @@ import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.archiver.jar.ManifestException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-
/**
*
*/
-public class ManifestCreationFinalizer
- extends AbstractArchiveFinalizer
-{
+public class ManifestCreationFinalizer extends AbstractArchiveFinalizer {
private final MavenProject project;
@@ -59,80 +56,58 @@ public class ManifestCreationFinalizer
// (the first is preferable).
private final MavenArchiver mavenArchiver = new MavenArchiver();
- public ManifestCreationFinalizer( final MavenSession session, final MavenProject project,
- final MavenArchiveConfiguration archiveConfiguration )
- {
+ public ManifestCreationFinalizer(
+ final MavenSession session,
+ final MavenProject project,
+ final MavenArchiveConfiguration archiveConfiguration) {
this.session = session;
this.project = project;
this.archiveConfiguration = archiveConfiguration;
}
@Override
- public void finalizeArchiveCreation( final Archiver archiver )
- {
- if ( archiveConfiguration != null )
- {
- try
- {
+ public void finalizeArchiveCreation(final Archiver archiver) {
+ if (archiveConfiguration != null) {
+ try {
Manifest manifest;
final File manifestFile = archiveConfiguration.getManifestFile();
- if ( manifestFile != null )
- {
- try ( InputStream in = new FileInputStream( manifestFile ) )
- {
- manifest = new Manifest( in );
- }
- catch ( final FileNotFoundException e )
- {
- throw new ArchiverException( "Manifest not found: " + e.getMessage(), e );
+ if (manifestFile != null) {
+ try (InputStream in = new FileInputStream(manifestFile)) {
+ manifest = new Manifest(in);
+ } catch (final FileNotFoundException e) {
+ throw new ArchiverException("Manifest not found: " + e.getMessage(), e);
+ } catch (final IOException e) {
+ throw new ArchiverException("Error processing manifest: " + e.getMessage(), e);
}
- catch ( final IOException e )
- {
- throw new ArchiverException( "Error processing manifest: " + e.getMessage(), e );
- }
- }
- else
- {
- manifest = mavenArchiver.getManifest( session, project, archiveConfiguration );
+ } else {
+ manifest = mavenArchiver.getManifest(session, project, archiveConfiguration);
}
- if ( ( manifest != null ) && ( archiver instanceof JarArchiver ) )
- {
+ if ((manifest != null) && (archiver instanceof JarArchiver)) {
final JarArchiver jarArchiver = (JarArchiver) archiver;
- jarArchiver.addConfiguredManifest( manifest );
+ jarArchiver.addConfiguredManifest(manifest);
}
- }
- catch ( final ManifestException e )
- {
- throw new ArchiverException( "Error creating manifest: " + e.getMessage(), e );
- }
- catch ( final DependencyResolutionRequiredException e )
- {
- throw new ArchiverException( "Dependencies were not resolved: " + e.getMessage(), e );
+ } catch (final ManifestException e) {
+ throw new ArchiverException("Error creating manifest: " + e.getMessage(), e);
+ } catch (final DependencyResolutionRequiredException e) {
+ throw new ArchiverException("Dependencies were not resolved: " + e.getMessage(), e);
}
}
}
@Override
- public List<String> getVirtualFiles()
- {
- if ( archiveConfiguration != null )
- {
- try
- {
- if ( mavenArchiver.getManifest( project, archiveConfiguration.getManifest() ) != null )
- {
- return Collections.singletonList( "META-INF/MANIFEST.MF" );
+ public List<String> getVirtualFiles() {
+ if (archiveConfiguration != null) {
+ try {
+ if (mavenArchiver.getManifest(project, archiveConfiguration.getManifest()) != null) {
+ return Collections.singletonList("META-INF/MANIFEST.MF");
}
- }
- catch ( final ManifestException | DependencyResolutionRequiredException ignore )
- {
+ } catch (final ManifestException | DependencyResolutionRequiredException ignore) {
// noop
}
}
return 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 49382db4..a5c70d60 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.archiver;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,20 @@ package org.apache.maven.plugins.assembly.archive.archiver;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.archiver;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.attribute.FileTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
import org.apache.maven.plugins.assembly.filter.ContainerDescriptorHandler;
import org.codehaus.plexus.archiver.ArchiveEntry;
@@ -37,19 +49,6 @@ import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.nio.file.attribute.FileTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
/**
* Delegating archiver implementation that supports:
* <ul>
@@ -61,9 +60,8 @@ import java.util.Map;
* @author jdcasey
*
*/
-public class AssemblyProxyArchiver implements Archiver
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( AssemblyProxyArchiver.class );
+public class AssemblyProxyArchiver implements Archiver {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AssemblyProxyArchiver.class);
private final Archiver delegate;
@@ -82,54 +80,48 @@ public class AssemblyProxyArchiver implements Archiver
*/
private boolean useJvmChmod;
- public AssemblyProxyArchiver( final String rootPrefix, final Archiver delegate,
- final List<ContainerDescriptorHandler> containerDescriptorHandlers,
- final List<FileSelector> extraSelectors, final List<ArchiveFinalizer> extraFinalizers,
- final File assemblyWorkDir )
- {
+ public AssemblyProxyArchiver(
+ final String rootPrefix,
+ final Archiver delegate,
+ final List<ContainerDescriptorHandler> containerDescriptorHandlers,
+ final List<FileSelector> extraSelectors,
+ final List<ArchiveFinalizer> extraFinalizers,
+ final File assemblyWorkDir) {
this.rootPrefix = rootPrefix;
this.delegate = delegate;
- assemblyWorkPath = assemblyWorkDir.getAbsolutePath().replace( '\\', '/' );
+ assemblyWorkPath = assemblyWorkDir.getAbsolutePath().replace('\\', '/');
- if ( !"".equals( rootPrefix ) && !rootPrefix.endsWith( "/" ) )
- {
+ if (!"".equals(rootPrefix) && !rootPrefix.endsWith("/")) {
this.rootPrefix += "/";
}
final List<FileSelector> selectors = new ArrayList<>();
- FinalizerEnabled finalizer = ( delegate instanceof FinalizerEnabled ) ? (FinalizerEnabled) delegate : null;
+ FinalizerEnabled finalizer = (delegate instanceof FinalizerEnabled) ? (FinalizerEnabled) delegate : null;
- if ( containerDescriptorHandlers != null )
- {
- for ( final ContainerDescriptorHandler handler : containerDescriptorHandlers )
- {
- selectors.add( handler );
+ if (containerDescriptorHandlers != null) {
+ for (final ContainerDescriptorHandler handler : containerDescriptorHandlers) {
+ selectors.add(handler);
- if ( finalizer != null )
- {
- finalizer.addArchiveFinalizer( handler );
+ if (finalizer != null) {
+ finalizer.addArchiveFinalizer(handler);
}
}
}
- if ( extraSelectors != null )
- {
- selectors.addAll( extraSelectors );
+ if (extraSelectors != null) {
+ selectors.addAll(extraSelectors);
}
- if ( ( extraFinalizers != null ) && finalizer != null )
- {
- for ( ArchiveFinalizer extraFinalizer : extraFinalizers )
- {
- finalizer.addArchiveFinalizer( extraFinalizer );
+ if ((extraFinalizers != null) && finalizer != null) {
+ for (ArchiveFinalizer extraFinalizer : extraFinalizers) {
+ finalizer.addArchiveFinalizer(extraFinalizer);
}
}
- if ( !selectors.isEmpty() )
- {
- this.selectors = selectors.toArray( new FileSelector[0] );
+ if (!selectors.isEmpty()) {
+ this.selectors = selectors.toArray(new FileSelector[0]);
}
}
@@ -137,34 +129,28 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addArchivedFileSet( final File archiveFile, final String prefix, final String[] includes,
- final String[] excludes )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final DefaultArchivedFileSet fs = new DefaultArchivedFileSet( archiveFile );
-
- fs.setIncludes( includes );
- fs.setExcludes( excludes );
- fs.setPrefix( rootPrefix + prefix );
- fs.setFileSelectors( selectors );
-
- debug( "Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix() );
-
- delegate.addArchivedFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addArchivedFileSet(
+ final File archiveFile, final String prefix, final String[] includes, final String[] excludes) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final DefaultArchivedFileSet fs = new DefaultArchivedFileSet(archiveFile);
+
+ fs.setIncludes(includes);
+ fs.setExcludes(excludes);
+ fs.setPrefix(rootPrefix + prefix);
+ fs.setFileSelectors(selectors);
+
+ debug("Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix());
+
+ delegate.addArchivedFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
- private void debug( final String message )
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( message );
+ private void debug(final String message) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(message);
}
}
@@ -172,23 +158,19 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addArchivedFileSet( final File archiveFile, final String prefix )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final DefaultArchivedFileSet fs = new DefaultArchivedFileSet( archiveFile );
+ public void addArchivedFileSet(final File archiveFile, final String prefix) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final DefaultArchivedFileSet fs = new DefaultArchivedFileSet(archiveFile);
- fs.setPrefix( rootPrefix + prefix );
- fs.setFileSelectors( selectors );
+ fs.setPrefix(rootPrefix + prefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix() );
+ debug("Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix());
- delegate.addArchivedFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.addArchivedFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -196,25 +178,21 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addArchivedFileSet( final File archiveFile, final String[] includes, final String[] excludes )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final DefaultArchivedFileSet fs = new DefaultArchivedFileSet( archiveFile );
+ public void addArchivedFileSet(final File archiveFile, final String[] includes, final String[] excludes) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final DefaultArchivedFileSet fs = new DefaultArchivedFileSet(archiveFile);
- fs.setIncludes( includes );
- fs.setExcludes( excludes );
- fs.setPrefix( rootPrefix );
- fs.setFileSelectors( selectors );
+ fs.setIncludes(includes);
+ fs.setExcludes(excludes);
+ fs.setPrefix(rootPrefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix() );
+ debug("Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix());
- delegate.addArchivedFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.addArchivedFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -222,23 +200,19 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addArchivedFileSet( final File archiveFile )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final DefaultArchivedFileSet fs = new DefaultArchivedFileSet( archiveFile );
+ public void addArchivedFileSet(final File archiveFile) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final DefaultArchivedFileSet fs = new DefaultArchivedFileSet(archiveFile);
- fs.setPrefix( rootPrefix );
- fs.setFileSelectors( selectors );
+ fs.setPrefix(rootPrefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix() );
+ debug("Adding archived file-set in: " + archiveFile + " to archive location: " + fs.getPrefix());
- delegate.addArchivedFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.addArchivedFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -246,27 +220,23 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addDirectory( final File directory, final String prefix, final String[] includes,
- final String[] excludes )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public void addDirectory(
+ final File directory, final String prefix, final String[] includes, final String[] excludes) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
final DefaultFileSet fs = new DefaultFileSet();
- fs.setDirectory( directory );
- fs.setIncludes( includes );
- fs.setExcludes( excludes );
- fs.setPrefix( rootPrefix + prefix );
- fs.setFileSelectors( selectors );
+ fs.setDirectory(directory);
+ fs.setIncludes(includes);
+ fs.setExcludes(excludes);
+ fs.setPrefix(rootPrefix + prefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix() );
+ debug("Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix());
- doAddFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ doAddFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -274,60 +244,46 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addSymlink( String symlinkName, String symlinkDestination )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.addSymlink( symlinkName, symlinkDestination );
+ public void addSymlink(String symlinkName, String symlinkDestination) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.addSymlink(symlinkName, symlinkDestination);
+ } finally {
+ inPublicApi.set(null);
}
- finally
- {
- inPublicApi.set( null );
- }
-
}
/**
* {@inheritDoc}
*/
@Override
- public void addSymlink( String symlinkName, int permissions, String symlinkDestination )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.addSymlink( symlinkName, permissions, symlinkDestination );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addSymlink(String symlinkName, int permissions, String symlinkDestination) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.addSymlink(symlinkName, permissions, symlinkDestination);
+ } finally {
+ inPublicApi.set(null);
}
-
}
/**
* {@inheritDoc}
*/
@Override
- public void addDirectory( final File directory, final String prefix )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public void addDirectory(final File directory, final String prefix) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
final DefaultFileSet fs = new DefaultFileSet();
- fs.setDirectory( directory );
- fs.setPrefix( rootPrefix + prefix );
- fs.setFileSelectors( selectors );
+ fs.setDirectory(directory);
+ fs.setPrefix(rootPrefix + prefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix() );
+ debug("Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix());
- doAddFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ doAddFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -335,26 +291,22 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addDirectory( final File directory, final String[] includes, final String[] excludes )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public void addDirectory(final File directory, final String[] includes, final String[] excludes) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
final DefaultFileSet fs = new DefaultFileSet();
- fs.setDirectory( directory );
- fs.setIncludes( includes );
- fs.setExcludes( excludes );
- fs.setPrefix( rootPrefix );
- fs.setFileSelectors( selectors );
+ fs.setDirectory(directory);
+ fs.setIncludes(includes);
+ fs.setExcludes(excludes);
+ fs.setPrefix(rootPrefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix() );
+ debug("Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix());
- doAddFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ doAddFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -362,24 +314,20 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addDirectory( final File directory )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public void addDirectory(final File directory) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
final DefaultFileSet fs = new DefaultFileSet();
- fs.setDirectory( directory );
- fs.setPrefix( rootPrefix );
- fs.setFileSelectors( selectors );
+ fs.setDirectory(directory);
+ fs.setPrefix(rootPrefix);
+ fs.setFileSelectors(selectors);
- debug( "Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix() );
+ debug("Adding directory file-set in: " + directory + " to archive location: " + fs.getPrefix());
- doAddFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ doAddFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -387,20 +335,15 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addFile( final File inputFile, final String destFileName, final int permissions )
- {
- if ( acceptFile( inputFile ) )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- debug( "Adding file: " + inputFile + " to archive location: " + rootPrefix + destFileName );
-
- delegate.addFile( inputFile, rootPrefix + destFileName, permissions );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addFile(final File inputFile, final String destFileName, final int permissions) {
+ if (acceptFile(inputFile)) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ debug("Adding file: " + inputFile + " to archive location: " + rootPrefix + destFileName);
+
+ delegate.addFile(inputFile, rootPrefix + destFileName, permissions);
+ } finally {
+ inPublicApi.set(null);
}
}
}
@@ -409,20 +352,15 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addFile( final File inputFile, final String destFileName )
- {
- if ( acceptFile( inputFile ) )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- debug( "Adding file: " + inputFile + " to archive location: " + rootPrefix + destFileName );
-
- delegate.addFile( inputFile, rootPrefix + destFileName );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addFile(final File inputFile, final String destFileName) {
+ if (acceptFile(inputFile)) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ debug("Adding file: " + inputFile + " to archive location: " + rootPrefix + destFileName);
+
+ delegate.addFile(inputFile, rootPrefix + destFileName);
+ } finally {
+ inPublicApi.set(null);
}
}
}
@@ -431,18 +369,13 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void createArchive()
- throws IOException
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setForced( forced );
+ public void createArchive() throws IOException {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setForced(forced);
delegate.createArchive();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -450,16 +383,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getDefaultDirectoryMode()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public int getDefaultDirectoryMode() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.getDefaultDirectoryMode();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -467,16 +396,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDefaultDirectoryMode( final int mode )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setDefaultDirectoryMode( mode );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setDefaultDirectoryMode(final int mode) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setDefaultDirectoryMode(mode);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -484,16 +409,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getDefaultFileMode()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public int getDefaultFileMode() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.getDefaultFileMode();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -501,16 +422,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDefaultFileMode( final int mode )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setDefaultFileMode( mode );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setDefaultFileMode(final int mode) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setDefaultFileMode(mode);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -518,16 +435,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public File getDestFile()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public File getDestFile() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.getDestFile();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -535,31 +448,23 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDestFile( final File destFile )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setDestFile( destFile );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setDestFile(final File destFile) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setDestFile(destFile);
+ } finally {
+ inPublicApi.set(null);
}
}
@Override
- @SuppressWarnings( { "deprecation" } )
- public Map<String, ArchiveEntry> getFiles()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ @SuppressWarnings({"deprecation"})
+ public Map<String, ArchiveEntry> getFiles() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.getFiles();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -567,16 +472,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public boolean getIncludeEmptyDirs()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public boolean getIncludeEmptyDirs() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.getIncludeEmptyDirs();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -584,16 +485,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setIncludeEmptyDirs( final boolean includeEmptyDirs )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setIncludeEmptyDirs( includeEmptyDirs );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setIncludeEmptyDirs(final boolean includeEmptyDirs) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setIncludeEmptyDirs(includeEmptyDirs);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -601,16 +498,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public boolean isForced()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public boolean isForced() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.isForced();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -618,17 +511,13 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setForced( final boolean forced )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public void setForced(final boolean forced) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
this.forced = forced;
- delegate.setForced( forced );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.setForced(forced);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -636,16 +525,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public boolean isSupportingForced()
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
+ public boolean isSupportingForced() {
+ inPublicApi.set(Boolean.TRUE);
+ try {
return delegate.isSupportingForced();
- }
- finally
- {
- inPublicApi.set( null );
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -653,49 +538,39 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDotFileDirectory( final File dotFileDirectory )
- {
- throw new UnsupportedOperationException(
- "Undocumented feature of plexus-archiver; this is not yet supported." );
+ public void setDotFileDirectory(final File dotFileDirectory) {
+ throw new UnsupportedOperationException("Undocumented feature of plexus-archiver; this is not yet supported.");
}
/**
* {@inheritDoc}
*/
@Override
- public void addArchivedFileSet( final ArchivedFileSet fileSet )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final PrefixedArchivedFileSet fs = new PrefixedArchivedFileSet( fileSet, rootPrefix, selectors );
+ public void addArchivedFileSet(final ArchivedFileSet fileSet) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final PrefixedArchivedFileSet fs = new PrefixedArchivedFileSet(fileSet, rootPrefix, selectors);
- debug( "Adding archived file-set in: " + fileSet.getArchive() + " to archive location: " + fs.getPrefix() );
+ debug("Adding archived file-set in: " + fileSet.getArchive() + " to archive location: " + fs.getPrefix());
- delegate.addArchivedFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.addArchivedFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
@Override
- public void addArchivedFileSet( ArchivedFileSet archivedFileSet, Charset charset )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final PrefixedArchivedFileSet fs = new PrefixedArchivedFileSet( archivedFileSet, rootPrefix, selectors );
+ public void addArchivedFileSet(ArchivedFileSet archivedFileSet, Charset charset) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final PrefixedArchivedFileSet fs = new PrefixedArchivedFileSet(archivedFileSet, rootPrefix, selectors);
- debug( "Adding archived file-set in: " + archivedFileSet.getArchive() + " to archive location: "
- + fs.getPrefix() );
+ debug("Adding archived file-set in: " + archivedFileSet.getArchive() + " to archive location: "
+ + fs.getPrefix());
- delegate.addArchivedFileSet( fs, charset );
- }
- finally
- {
- inPublicApi.set( null );
+ delegate.addArchivedFileSet(fs, charset);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -703,100 +578,76 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addFileSet( final FileSet fileSet )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- final PrefixedFileSet fs = new PrefixedFileSet( fileSet, rootPrefix, selectors );
+ public void addFileSet(final FileSet fileSet) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ final PrefixedFileSet fs = new PrefixedFileSet(fileSet, rootPrefix, selectors);
- debug( "Adding file-set in: " + fileSet.getDirectory() + " to archive location: " + fs.getPrefix() );
+ debug("Adding file-set in: " + fileSet.getDirectory() + " to archive location: " + fs.getPrefix());
- doAddFileSet( fs );
- }
- finally
- {
- inPublicApi.set( null );
+ doAddFileSet(fs);
+ } finally {
+ inPublicApi.set(null);
}
}
- private void doAddFileSet( final FileSet fs )
- {
- final String fsPath = fs.getDirectory().getAbsolutePath().replace( '\\', '/' );
+ private void doAddFileSet(final FileSet fs) {
+ final String fsPath = fs.getDirectory().getAbsolutePath().replace('\\', '/');
- if ( fsPath.equals( assemblyWorkPath ) )
- {
- LOGGER.debug(
- "SKIPPING fileset with source directory matching assembly working-directory: " + fsPath );
- }
- else if ( assemblyWorkPath.startsWith( fsPath ) )
- {
+ if (fsPath.equals(assemblyWorkPath)) {
+ LOGGER.debug("SKIPPING fileset with source directory matching assembly working-directory: " + fsPath);
+ } else if (assemblyWorkPath.startsWith(fsPath)) {
final List<String> newEx = new ArrayList<>();
- if ( fs.getExcludes() != null )
- {
- newEx.addAll( Arrays.asList( fs.getExcludes() ) );
+ if (fs.getExcludes() != null) {
+ newEx.addAll(Arrays.asList(fs.getExcludes()));
}
- final String workDirExclude = assemblyWorkPath.substring( fsPath.length() + 1 );
+ final String workDirExclude = assemblyWorkPath.substring(fsPath.length() + 1);
- LOGGER.debug(
- "Adding exclude for assembly working-directory: " + workDirExclude + "\nFile-Set source directory: "
- + fsPath );
+ LOGGER.debug("Adding exclude for assembly working-directory: " + workDirExclude
+ + "\nFile-Set source directory: " + fsPath);
- newEx.add( workDirExclude );
+ newEx.add(workDirExclude);
final List<String> newIn = new ArrayList<>();
- if ( fs.getIncludes() != null )
- {
- for ( final String include : fs.getIncludes() )
- {
- if ( !include.startsWith( workDirExclude ) )
- {
- newIn.add( include );
+ if (fs.getIncludes() != null) {
+ for (final String include : fs.getIncludes()) {
+ if (!include.startsWith(workDirExclude)) {
+ newIn.add(include);
}
}
}
final DefaultFileSet dfs = new DefaultFileSet();
- dfs.setCaseSensitive( fs.isCaseSensitive() );
- dfs.setDirectory( fs.getDirectory() );
- dfs.setExcludes( newEx.toArray( new String[0] ) );
- dfs.setFileSelectors( fs.getFileSelectors() );
- dfs.setIncludes( newIn.toArray( new String[0] ) );
- dfs.setIncludingEmptyDirectories( fs.isIncludingEmptyDirectories() );
- dfs.setPrefix( fs.getPrefix() );
- dfs.setStreamTransformer( fs.getStreamTransformer() );
+ dfs.setCaseSensitive(fs.isCaseSensitive());
+ dfs.setDirectory(fs.getDirectory());
+ dfs.setExcludes(newEx.toArray(new String[0]));
+ dfs.setFileSelectors(fs.getFileSelectors());
+ dfs.setIncludes(newIn.toArray(new String[0]));
+ dfs.setIncludingEmptyDirectories(fs.isIncludingEmptyDirectories());
+ dfs.setPrefix(fs.getPrefix());
+ dfs.setStreamTransformer(fs.getStreamTransformer());
- delegate.addFileSet( dfs );
- }
- else
- {
- delegate.addFileSet( fs );
+ delegate.addFileSet(dfs);
+ } else {
+ delegate.addFileSet(fs);
}
}
- private boolean acceptFile( final File inputFile )
- {
- if ( !Boolean.TRUE.equals( inPublicApi.get() ) )
- {
- if ( selectors != null )
- {
- final FileInfo fileInfo = new DefaultFileInfo( inputFile );
-
- for ( final FileSelector selector : selectors )
- {
- try
- {
- if ( !selector.isSelected( fileInfo ) )
- {
+ private boolean acceptFile(final File inputFile) {
+ if (!Boolean.TRUE.equals(inPublicApi.get())) {
+ if (selectors != null) {
+ final FileInfo fileInfo = new DefaultFileInfo(inputFile);
+
+ for (final FileSelector selector : selectors) {
+ try {
+ if (!selector.isSelected(fileInfo)) {
return false;
}
- }
- catch ( final IOException e )
- {
+ } catch (final IOException e) {
throw new ArchiverException(
- "Error processing file: " + inputFile + " using selector: " + selector, e );
+ "Error processing file: " + inputFile + " using selector: " + selector, e);
}
}
}
@@ -809,20 +660,15 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addResource( final PlexusIoResource resource, final String destFileName, final int permissions )
- {
- File file = new File( resource.getName() ); // zOMG.
- if ( acceptFile( file ) )
- {
-
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.addResource( resource, rootPrefix + destFileName, permissions );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addResource(final PlexusIoResource resource, final String destFileName, final int permissions) {
+ File file = new File(resource.getName()); // zOMG.
+ if (acceptFile(file)) {
+
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.addResource(resource, rootPrefix + destFileName, permissions);
+ } finally {
+ inPublicApi.set(null);
}
}
}
@@ -831,16 +677,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void addResources( final PlexusIoResourceCollection resources )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.addResources( resources );
- }
- finally
- {
- inPublicApi.set( null );
+ public void addResources(final PlexusIoResourceCollection resources) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.addResources(resources);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -848,8 +690,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public ResourceIterator getResources()
- {
+ public ResourceIterator getResources() {
return delegate.getResources();
}
@@ -857,8 +698,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public String getDuplicateBehavior()
- {
+ public String getDuplicateBehavior() {
return delegate.getDuplicateBehavior();
}
@@ -866,16 +706,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDuplicateBehavior( final String duplicate )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setDuplicateBehavior( duplicate );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setDuplicateBehavior(final String duplicate) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setDuplicateBehavior(duplicate);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -883,8 +719,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getDirectoryMode()
- {
+ public int getDirectoryMode() {
return delegate.getDirectoryMode();
}
@@ -892,16 +727,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setDirectoryMode( final int mode )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setDirectoryMode( mode );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setDirectoryMode(final int mode) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setDirectoryMode(mode);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -909,8 +740,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getFileMode()
- {
+ public int getFileMode() {
return delegate.getFileMode();
}
@@ -918,16 +748,12 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setFileMode( final int mode )
- {
- inPublicApi.set( Boolean.TRUE );
- try
- {
- delegate.setFileMode( mode );
- }
- finally
- {
- inPublicApi.set( null );
+ public void setFileMode(final int mode) {
+ inPublicApi.set(Boolean.TRUE);
+ try {
+ delegate.setFileMode(mode);
+ } finally {
+ inPublicApi.set(null);
}
}
@@ -935,8 +761,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getOverrideDirectoryMode()
- {
+ public int getOverrideDirectoryMode() {
return delegate.getOverrideDirectoryMode();
}
@@ -944,8 +769,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public int getOverrideFileMode()
- {
+ public int getOverrideFileMode() {
return delegate.getOverrideFileMode();
}
@@ -953,8 +777,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public boolean isUseJvmChmod()
- {
+ public boolean isUseJvmChmod() {
return useJvmChmod;
}
@@ -962,8 +785,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setUseJvmChmod( final boolean useJvmChmod )
- {
+ public void setUseJvmChmod(final boolean useJvmChmod) {
this.useJvmChmod = useJvmChmod;
}
@@ -971,8 +793,7 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public boolean isIgnorePermissions()
- {
+ public boolean isIgnorePermissions() {
return delegate.isIgnorePermissions();
}
@@ -980,141 +801,116 @@ public class AssemblyProxyArchiver implements Archiver
* {@inheritDoc}
*/
@Override
- public void setIgnorePermissions( final boolean ignorePermissions )
- {
- delegate.setIgnorePermissions( ignorePermissions );
+ public void setIgnorePermissions(final boolean ignorePermissions) {
+ delegate.setIgnorePermissions(ignorePermissions);
}
- private static final class DefaultFileInfo
- implements FileInfo
- {
+ private static final class DefaultFileInfo implements FileInfo {
private final File inputFile;
- DefaultFileInfo( final File inputFile )
- {
+ DefaultFileInfo(final File inputFile) {
this.inputFile = inputFile;
}
@Override
- public InputStream getContents()
- throws IOException
- {
- return new FileInputStream( inputFile );
+ public InputStream getContents() throws IOException {
+ return new FileInputStream(inputFile);
}
@Override
- public String getName()
- {
+ public String getName() {
return inputFile.getName();
}
@Override
- public boolean isDirectory()
- {
+ public boolean isDirectory() {
return inputFile.isDirectory();
}
@Override
- public boolean isFile()
- {
+ public boolean isFile() {
return inputFile.isFile();
}
@Override
- public boolean isSymbolicLink()
- {
+ public boolean isSymbolicLink() {
return false;
}
}
@Override
- public void setLastModifiedDate( Date lastModifiedDate )
- {
- delegate.setLastModifiedDate( lastModifiedDate );
+ public void setLastModifiedDate(Date lastModifiedDate) {
+ delegate.setLastModifiedDate(lastModifiedDate);
}
@Override
- public Date getLastModifiedDate()
- {
+ public Date getLastModifiedDate() {
return delegate.getLastModifiedDate();
}
@Override
- public void setFilenameComparator( Comparator<String> filenameComparator )
- {
- delegate.setFilenameComparator( filenameComparator );
+ public void setFilenameComparator(Comparator<String> filenameComparator) {
+ delegate.setFilenameComparator(filenameComparator);
}
@Override
- public void configureReproducible( Date outputTimestamp )
- {
- delegate.configureReproducible( outputTimestamp );
+ public void configureReproducible(Date outputTimestamp) {
+ delegate.configureReproducible(outputTimestamp);
}
@Override
- public void setOverrideUid( int uid )
- {
- delegate.setOverrideUid( uid );
+ public void setOverrideUid(int uid) {
+ delegate.setOverrideUid(uid);
}
@Override
- public void setOverrideUserName( String userName )
- {
- delegate.setOverrideUserName( userName );
+ public void setOverrideUserName(String userName) {
+ delegate.setOverrideUserName(userName);
}
@Override
- public int getOverrideUid()
- {
+ public int getOverrideUid() {
return delegate.getOverrideUid();
}
@Override
- public String getOverrideUserName()
- {
+ public String getOverrideUserName() {
return delegate.getOverrideUserName();
}
@Override
- public void setOverrideGid( int gid )
- {
- delegate.setOverrideGid( gid );
+ public void setOverrideGid(int gid) {
+ delegate.setOverrideGid(gid);
}
@Override
- public void setOverrideGroupName( String groupName )
- {
- delegate.setOverrideGroupName( groupName );
+ public void setOverrideGroupName(String groupName) {
+ delegate.setOverrideGroupName(groupName);
}
@Override
- public int getOverrideGid()
- {
+ public int getOverrideGid() {
return delegate.getOverrideGid();
}
@Override
- public String getOverrideGroupName()
- {
+ public String getOverrideGroupName() {
return delegate.getOverrideGroupName();
}
@Override
- public void setLastModifiedTime( FileTime fileTime )
- {
- delegate.setLastModifiedTime( fileTime );
+ public void setLastModifiedTime(FileTime fileTime) {
+ delegate.setLastModifiedTime(fileTime);
}
@Override
- public FileTime getLastModifiedTime()
- {
+ public FileTime getLastModifiedTime() {
return delegate.getLastModifiedTime();
}
@Override
- public void configureReproducibleBuild( FileTime fileTime )
- {
- delegate.configureReproducibleBuild( fileTime );
+ public void configureReproducibleBuild(FileTime fileTime) {
+ delegate.configureReproducibleBuild(fileTime);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedArchivedFileSet.java b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedArchivedFileSet.java
index 2f1d12e7..16cea586 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedArchivedFileSet.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedArchivedFileSet.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.archiver;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,21 +16,20 @@ package org.apache.maven.plugins.assembly.archive.archiver;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.archiver;
+
+import java.io.File;
import org.codehaus.plexus.archiver.ArchivedFileSet;
+import org.codehaus.plexus.components.io.filemappers.FileMapper;
import org.codehaus.plexus.components.io.fileselectors.FileSelector;
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
-import java.io.File;
-import org.codehaus.plexus.components.io.filemappers.FileMapper;
-
/**
*
*/
-class PrefixedArchivedFileSet
- implements ArchivedFileSet
-{
- private final static FileMapper[] EMPTY_FILE_MAPPERS_ARRAY = new FileMapper[0];
+class PrefixedArchivedFileSet implements ArchivedFileSet {
+ private static final FileMapper[] EMPTY_FILE_MAPPERS_ARRAY = new FileMapper[0];
private final String rootPrefix;
@@ -45,17 +42,13 @@ class PrefixedArchivedFileSet
* @param rootPrefix The root prefix.
* @param selectors The file selectors.
*/
- PrefixedArchivedFileSet( ArchivedFileSet fileSet, String rootPrefix, FileSelector[] selectors )
- {
+ PrefixedArchivedFileSet(ArchivedFileSet fileSet, String rootPrefix, FileSelector[] selectors) {
this.fileSet = fileSet;
this.selectors = selectors;
- if ( rootPrefix.length() > 0 && !rootPrefix.endsWith( "/" ) )
- {
+ if (rootPrefix.length() > 0 && !rootPrefix.endsWith("/")) {
this.rootPrefix = rootPrefix + "/";
- }
- else
- {
+ } else {
this.rootPrefix = rootPrefix;
}
}
@@ -64,8 +57,7 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public File getArchive()
- {
+ public File getArchive() {
return fileSet.getArchive();
}
@@ -73,8 +65,7 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public String[] getExcludes()
- {
+ public String[] getExcludes() {
return fileSet.getExcludes();
}
@@ -82,17 +73,15 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public FileSelector[] getFileSelectors()
- {
- return PrefixedFileSet.combineSelectors( fileSet.getFileSelectors(), selectors );
+ public FileSelector[] getFileSelectors() {
+ return PrefixedFileSet.combineSelectors(fileSet.getFileSelectors(), selectors);
}
/**
* {@inheritDoc}
*/
@Override
- public String[] getIncludes()
- {
+ public String[] getIncludes() {
return fileSet.getIncludes();
}
@@ -100,17 +89,12 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public String getPrefix()
- {
+ public String getPrefix() {
String prefix = fileSet.getPrefix();
- if ( prefix.startsWith( "/" ) )
- {
- if ( prefix.length() > 1 )
- {
- prefix = prefix.substring( 1 );
- }
- else
- {
+ if (prefix.startsWith("/")) {
+ if (prefix.length() > 1) {
+ prefix = prefix.substring(1);
+ } else {
prefix = "";
}
}
@@ -122,8 +106,7 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isCaseSensitive()
- {
+ public boolean isCaseSensitive() {
return fileSet.isCaseSensitive();
}
@@ -131,8 +114,7 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isIncludingEmptyDirectories()
- {
+ public boolean isIncludingEmptyDirectories() {
return fileSet.isIncludingEmptyDirectories();
}
@@ -140,20 +122,17 @@ class PrefixedArchivedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isUsingDefaultExcludes()
- {
+ public boolean isUsingDefaultExcludes() {
return fileSet.isUsingDefaultExcludes();
}
@Override
- public InputStreamTransformer getStreamTransformer()
- {
+ public InputStreamTransformer getStreamTransformer() {
return fileSet.getStreamTransformer();
}
@Override
- public FileMapper[] getFileMappers()
- {
+ public FileMapper[] getFileMappers() {
return EMPTY_FILE_MAPPERS_ARRAY;
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedFileSet.java b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedFileSet.java
index 86d8071d..98c0e9b5 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedFileSet.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/archiver/PrefixedFileSet.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.archiver;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,21 +16,20 @@ package org.apache.maven.plugins.assembly.archive.archiver;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.archiver;
+
+import java.io.File;
import org.codehaus.plexus.archiver.FileSet;
+import org.codehaus.plexus.components.io.filemappers.FileMapper;
import org.codehaus.plexus.components.io.fileselectors.FileSelector;
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
-import java.io.File;
-import org.codehaus.plexus.components.io.filemappers.FileMapper;
-
/**
*
*/
-class PrefixedFileSet
- implements FileSet
-{
- private final static FileMapper[] EMPTY_FILE_MAPPERS_ARRAY = new FileMapper[0];
+class PrefixedFileSet implements FileSet {
+ private static final FileMapper[] EMPTY_FILE_MAPPERS_ARRAY = new FileMapper[0];
private final String rootPrefix;
@@ -45,17 +42,13 @@ class PrefixedFileSet
* @param rootPrefix The root prefix
* @param selectors The file selectors.
*/
- PrefixedFileSet( final FileSet fileSet, final String rootPrefix, final FileSelector[] selectors )
- {
+ PrefixedFileSet(final FileSet fileSet, final String rootPrefix, final FileSelector[] selectors) {
this.fileSet = fileSet;
this.selectors = selectors;
- if ( rootPrefix.length() > 0 && !rootPrefix.endsWith( "/" ) )
- {
+ if (rootPrefix.length() > 0 && !rootPrefix.endsWith("/")) {
this.rootPrefix = rootPrefix + "/";
- }
- else
- {
+ } else {
this.rootPrefix = rootPrefix;
}
}
@@ -63,19 +56,15 @@ class PrefixedFileSet
/**
* {@inheritDoc}
*/
- static FileSelector[] combineSelectors( FileSelector[] first, FileSelector[] second )
- {
- if ( ( first != null ) && ( second != null ) )
- {
+ static FileSelector[] combineSelectors(FileSelector[] first, FileSelector[] second) {
+ if ((first != null) && (second != null)) {
final FileSelector[] temp = new FileSelector[first.length + second.length];
- System.arraycopy( first, 0, temp, 0, first.length );
- System.arraycopy( second, 0, temp, first.length, second.length );
+ System.arraycopy(first, 0, temp, 0, first.length);
+ System.arraycopy(second, 0, temp, first.length, second.length);
first = temp;
- }
- else if ( ( first == null ) && ( second != null ) )
- {
+ } else if ((first == null) && (second != null)) {
first = second;
}
@@ -86,8 +75,7 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public String[] getExcludes()
- {
+ public String[] getExcludes() {
return fileSet.getExcludes();
}
@@ -95,19 +83,17 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public FileSelector[] getFileSelectors()
- {
+ public FileSelector[] getFileSelectors() {
FileSelector[] sel = fileSet.getFileSelectors();
final FileSelector[] selectors1 = selectors;
- return combineSelectors( sel, selectors1 );
+ return combineSelectors(sel, selectors1);
}
/**
* {@inheritDoc}
*/
@Override
- public String[] getIncludes()
- {
+ public String[] getIncludes() {
return fileSet.getIncludes();
}
@@ -115,22 +101,16 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public String getPrefix()
- {
+ public String getPrefix() {
String prefix = fileSet.getPrefix();
- if ( prefix == null )
- {
+ if (prefix == null) {
return rootPrefix;
}
- if ( prefix.startsWith( "/" ) )
- {
- if ( prefix.length() > 1 )
- {
- prefix = prefix.substring( 1 );
- }
- else
- {
+ if (prefix.startsWith("/")) {
+ if (prefix.length() > 1) {
+ prefix = prefix.substring(1);
+ } else {
prefix = "";
}
}
@@ -142,8 +122,7 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isCaseSensitive()
- {
+ public boolean isCaseSensitive() {
return fileSet.isCaseSensitive();
}
@@ -151,8 +130,7 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isIncludingEmptyDirectories()
- {
+ public boolean isIncludingEmptyDirectories() {
return fileSet.isIncludingEmptyDirectories();
}
@@ -160,8 +138,7 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public boolean isUsingDefaultExcludes()
- {
+ public boolean isUsingDefaultExcludes() {
return fileSet.isUsingDefaultExcludes();
}
@@ -169,20 +146,17 @@ class PrefixedFileSet
* {@inheritDoc}
*/
@Override
- public File getDirectory()
- {
+ public File getDirectory() {
return fileSet.getDirectory();
}
@Override
- public InputStreamTransformer getStreamTransformer()
- {
+ public InputStreamTransformer getStreamTransformer() {
return fileSet.getStreamTransformer();
}
@Override
- public FileMapper[] getFileMappers()
- {
+ public FileMapper[] getFileMappers() {
return EMPTY_FILE_MAPPERS_ARRAY;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhase.java
index 83a15452..6d51d0f2 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhase.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
@@ -33,8 +32,7 @@ import org.codehaus.plexus.archiver.Archiver;
*
*
*/
-public interface AssemblyArchiverPhase
-{
+public interface AssemblyArchiverPhase {
/**
* Handle the associated section of the assembly descriptor.
*
@@ -50,7 +48,7 @@ public interface AssemblyArchiverPhase
* @throws org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException in case of an invalid
* assembler configuration.
*/
- void execute( Assembly assembly, Archiver archiver, AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException;
+ void execute(Assembly assembly, Archiver archiver, AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
+ DependencyResolutionException;
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparator.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparator.java
index f796ae40..c9f32749 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparator.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/AssemblyArchiverPhaseComparator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,32 +16,27 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
import java.util.Comparator;
/**
*
*/
-public class AssemblyArchiverPhaseComparator
- implements Comparator<AssemblyArchiverPhase>
-{
+public class AssemblyArchiverPhaseComparator implements Comparator<AssemblyArchiverPhase> {
@Override
- public int compare( AssemblyArchiverPhase o1, AssemblyArchiverPhase o2 )
- {
+ public int compare(AssemblyArchiverPhase o1, AssemblyArchiverPhase o2) {
boolean o1hasOrder = o1 instanceof PhaseOrder;
boolean o2hasOrder = o2 instanceof PhaseOrder;
- if ( !o1hasOrder && !o2hasOrder )
- {
- return o1.getClass().getName().compareTo( o2.getClass().getName() );
+ if (!o1hasOrder && !o2hasOrder) {
+ return o1.getClass().getName().compareTo(o2.getClass().getName());
}
- if ( !o1hasOrder )
- {
+ if (!o1hasOrder) {
return -1;
}
- if ( !o2hasOrder )
- {
+ if (!o2hasOrder) {
return +1;
}
- return Integer.compare( ( (PhaseOrder) o1 ).order(), ( (PhaseOrder) o2 ).order() );
+ return Integer.compare(((PhaseOrder) o1).order(), ((PhaseOrder) o2).order());
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhase.java
index 64077cd8..97fe7c71 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhase.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,11 +16,16 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
@@ -36,10 +39,6 @@ import org.apache.maven.plugins.assembly.model.DependencySet;
import org.apache.maven.project.ProjectBuilder;
import org.codehaus.plexus.archiver.Archiver;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
import static java.util.Objects.requireNonNull;
/**
@@ -48,9 +47,8 @@ import static java.util.Objects.requireNonNull;
*
*/
@Singleton
-@Named( "dependency-sets" )
-public class DependencySetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder
-{
+@Named("dependency-sets")
+public class DependencySetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder {
private final ProjectBuilder projectBuilder;
private final DependencyResolver dependencyResolver;
@@ -59,39 +57,36 @@ public class DependencySetAssemblyPhase implements AssemblyArchiverPhase, PhaseO
* Injected ctor.
*/
@Inject
- public DependencySetAssemblyPhase( final ProjectBuilder projectBuilder,
- final DependencyResolver dependencyResolver )
- {
- this.projectBuilder = requireNonNull( projectBuilder );
- this.dependencyResolver = requireNonNull( dependencyResolver );
+ public DependencySetAssemblyPhase(
+ final ProjectBuilder projectBuilder, final DependencyResolver dependencyResolver) {
+ this.projectBuilder = requireNonNull(projectBuilder);
+ this.dependencyResolver = requireNonNull(dependencyResolver);
}
/**
* {@inheritDoc}
*/
@Override
- public void execute( final Assembly assembly, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException
- {
+ public void execute(
+ final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
+ DependencyResolutionException {
Map<DependencySet, Set<Artifact>> resolved =
- dependencyResolver.resolveDependencySets( assembly, configSource, assembly.getDependencySets() );
- for ( Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : resolved.entrySet() )
- {
- final AddDependencySetsTask task =
- new AddDependencySetsTask( Collections.singletonList( dependencySetSetEntry.getKey() ),
- dependencySetSetEntry.getValue(), configSource.getProject(),
- projectBuilder );
+ dependencyResolver.resolveDependencySets(assembly, configSource, assembly.getDependencySets());
+ for (Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : resolved.entrySet()) {
+ final AddDependencySetsTask task = new AddDependencySetsTask(
+ Collections.singletonList(dependencySetSetEntry.getKey()),
+ dependencySetSetEntry.getValue(),
+ configSource.getProject(),
+ projectBuilder);
- task.execute( archiver, configSource );
+ task.execute(archiver, configSource);
}
}
@Override
- public int order()
- {
+ public int order() {
// CHECKSTYLE_OFF: MagicNumber
return 40;
// CHECKSTYLE_ON: MagicNumber
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 0a93086f..8a9797ac 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,12 +16,11 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
import javax.inject.Named;
import javax.inject.Singleton;
-import static org.codehaus.plexus.components.io.resources.ResourceFactory.createResource;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -53,148 +50,121 @@ import org.codehaus.plexus.components.io.resources.PlexusIoResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.codehaus.plexus.components.io.resources.ResourceFactory.createResource;
+
/**
* Handles the top-level <files/> section of the assembly descriptor.
*
*
*/
@Singleton
-@Named( "file-items" )
-public class FileItemAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( FileItemAssemblyPhase.class );
+@Named("file-items")
+public class FileItemAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileItemAssemblyPhase.class);
/**
* {@inheritDoc}
*/
@Override
- public void execute( final Assembly assembly, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
- {
+ public void execute(
+ final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
final List<FileItem> fileList = assembly.getFiles();
final File basedir = configSource.getBasedir();
- for ( final FileItem fileItem : fileList )
- {
- if ( fileItem.getSource() != null ^ fileItem.getSources().isEmpty() )
- {
- throw new InvalidAssemblerConfigurationException(
- "Misconfigured file: one of source or sources must be set" );
+ for (final FileItem fileItem : fileList) {
+ if (fileItem.getSource() != null ^ fileItem.getSources().isEmpty()) {
+ throw new InvalidAssemblerConfigurationException(
+ "Misconfigured file: one of source or sources must be set");
}
-
+
String destName = fileItem.getDestName();
-
+
final String sourcePath;
- if ( fileItem.getSource() != null )
- {
+ if (fileItem.getSource() != null) {
sourcePath = fileItem.getSource();
- }
- else if ( destName != null )
- {
+ } else if (destName != null) {
// because createResource() requires a file
- sourcePath = fileItem.getSources().get( 0 );
+ sourcePath = fileItem.getSources().get(0);
+ } else {
+ throw new InvalidAssemblerConfigurationException(
+ "Misconfigured file: specify destName when using sources");
}
- else
- {
- throw new InvalidAssemblerConfigurationException(
- "Misconfigured file: specify destName when using sources" );
- }
// ensure source file is in absolute path for reactor build to work
- File source = new File( sourcePath );
+ File source = new File(sourcePath);
// save the original sourcefile's name, because filtration may
// create a temp file with a different name.
final String sourceName = source.getName();
- if ( !AssemblyFileUtils.isAbsolutePath( source ) )
- {
- source = new File( basedir, sourcePath );
+ if (!AssemblyFileUtils.isAbsolutePath(source)) {
+ source = new File(basedir, sourcePath);
}
- if ( destName == null )
- {
+ if (destName == null) {
destName = sourceName;
}
final String outputDirectory1 = fileItem.getOutputDirectory();
- final String outputDirectory =
- AssemblyFormatUtils.getOutputDirectory( outputDirectory1, configSource.getFinalName(), configSource,
- AssemblyFormatUtils.moduleProjectInterpolator(
- configSource.getProject() ),
- AssemblyFormatUtils.artifactProjectInterpolator( null ) );
+ final String outputDirectory = AssemblyFormatUtils.getOutputDirectory(
+ outputDirectory1,
+ configSource.getFinalName(),
+ configSource,
+ AssemblyFormatUtils.moduleProjectInterpolator(configSource.getProject()),
+ AssemblyFormatUtils.artifactProjectInterpolator(null));
String target;
// omit the last char if ends with / or \\
- if ( outputDirectory.endsWith( "/" ) || outputDirectory.endsWith( "\\" ) )
- {
+ if (outputDirectory.endsWith("/") || outputDirectory.endsWith("\\")) {
target = outputDirectory + destName;
- }
- else if ( outputDirectory.length() < 1 )
- {
+ } else if (outputDirectory.length() < 1) {
target = destName;
- }
- else
- {
+ } else {
target = outputDirectory + "/" + destName;
}
- try
- {
- final InputStreamTransformer fileSetTransformers =
- ReaderFormatter.getFileSetTransformers( configSource, fileItem.isFiltered(),
- Collections.<String>emptySet(),
- fileItem.getLineEnding() );
-
+ try {
+ final InputStreamTransformer fileSetTransformers = ReaderFormatter.getFileSetTransformers(
+ configSource, fileItem.isFiltered(), Collections.<String>emptySet(), fileItem.getLineEnding());
+
final PlexusIoResource restoUse;
- if ( !fileItem.getSources().isEmpty() )
- {
- List<InputStream> content = new ArrayList<>( fileItem.getSources().size() );
- for ( String contentSourcePath : fileItem.getSources() )
- {
- File contentSource = new File( contentSourcePath );
- if ( !AssemblyFileUtils.isAbsolutePath( contentSource ) )
- {
- contentSource = new File( basedir, contentSourcePath );
+ if (!fileItem.getSources().isEmpty()) {
+ List<InputStream> content =
+ new ArrayList<>(fileItem.getSources().size());
+ for (String contentSourcePath : fileItem.getSources()) {
+ File contentSource = new File(contentSourcePath);
+ if (!AssemblyFileUtils.isAbsolutePath(contentSource)) {
+ contentSource = new File(basedir, contentSourcePath);
}
- content.add( new FileInputStream( contentSource ) );
+ content.add(new FileInputStream(contentSource));
}
-
- String name = PlexusIoFileResource.getName( source );
- restoUse = createResource( source, name, getContentSupplier( content ), fileSetTransformers );
- }
- else
- {
- restoUse = createResource( source, fileSetTransformers );
+
+ String name = PlexusIoFileResource.getName(source);
+ restoUse = createResource(source, name, getContentSupplier(content), fileSetTransformers);
+ } else {
+ restoUse = createResource(source, fileSetTransformers);
}
- int mode = TypeConversionUtils.modeToInt( fileItem.getFileMode(), LOGGER );
- archiver.addResource( restoUse, target, mode );
- }
- catch ( final ArchiverException | IOException e )
- {
- throw new ArchiveCreationException( "Error adding file to archive: " + e.getMessage(), e );
+ int mode = TypeConversionUtils.modeToInt(fileItem.getFileMode(), LOGGER);
+ archiver.addResource(restoUse, target, mode);
+ } catch (final ArchiverException | IOException e) {
+ throw new ArchiveCreationException("Error adding file to archive: " + e.getMessage(), e);
}
}
}
@Override
- public int order()
- {
+ public int order() {
return 10;
}
-
- private ContentSupplier getContentSupplier( final Collection<InputStream> contentStreams )
- {
- return new ContentSupplier()
- {
+
+ private ContentSupplier getContentSupplier(final Collection<InputStream> contentStreams) {
+ return new ContentSupplier() {
@Override
- public InputStream getContents()
- throws IOException
- {
- return new SequenceInputStream( Collections.enumeration( contentStreams ) );
+ public InputStream getContents() throws IOException {
+ return new SequenceInputStream(Collections.enumeration(contentStreams));
}
};
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhase.java
index 3035b3bc..559ba353 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhase.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,12 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.util.List;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
@@ -27,43 +31,32 @@ import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.model.FileSet;
import org.codehaus.plexus.archiver.Archiver;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import java.util.List;
-
/**
* Handles the <fileSets/> top-level section of the assembly descriptor.
*
*
*/
@Singleton
-@Named( "file-sets" )
-public class FileSetAssemblyPhase
- implements AssemblyArchiverPhase, PhaseOrder
-{
+@Named("file-sets")
+public class FileSetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder {
/**
* {@inheritDoc}
*/
@Override
- public void execute( final Assembly assembly, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException
- {
+ public void execute(
+ final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException {
final List<FileSet> fileSets = assembly.getFileSets();
- if ( ( fileSets != null ) && !fileSets.isEmpty() )
- {
- final AddFileSetsTask task = new AddFileSetsTask( fileSets );
- task.execute( archiver, configSource );
+ if ((fileSets != null) && !fileSets.isEmpty()) {
+ final AddFileSetsTask task = new AddFileSetsTask(fileSets);
+ task.execute(archiver, configSource);
}
}
-
@Override
- public int order()
- {
+ public int order() {
// CHECKSTYLE_OFF: MagicNumber
return 20;
// CHECKSTYLE_ON: MagicNumber
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 43112870..8681fd6c 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,21 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+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.plugins.assembly.AssemblerConfigurationSource;
@@ -50,20 +63,6 @@ import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import static java.util.Objects.requireNonNull;
import static org.apache.maven.plugins.assembly.functions.MavenProjects.addTo;
import static org.apache.maven.plugins.assembly.functions.MavenProjects.log;
@@ -74,17 +73,16 @@ import static org.apache.maven.plugins.assembly.functions.MavenProjects.log;
*
*/
@Singleton
-@Named( "module-sets" )
-public class ModuleSetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( ModuleSetAssemblyPhase.class );
+@Named("module-sets")
+public class ModuleSetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModuleSetAssemblyPhase.class);
// TODO: Remove if using something like commons-lang instead.
/**
* The line separator.
*/
- private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
private final ProjectBuilder projectBuilder;
@@ -94,478 +92,428 @@ public class ModuleSetAssemblyPhase implements AssemblyArchiverPhase, PhaseOrder
* Injected ctor.
*/
@Inject
- public ModuleSetAssemblyPhase( final ProjectBuilder projectBuilder,
- final DependencyResolver dependencyResolver )
- {
- this.projectBuilder = requireNonNull( projectBuilder );
- this.dependencyResolver = requireNonNull( dependencyResolver );
+ public ModuleSetAssemblyPhase(final ProjectBuilder projectBuilder, final DependencyResolver dependencyResolver) {
+ this.projectBuilder = requireNonNull(projectBuilder);
+ this.dependencyResolver = requireNonNull(dependencyResolver);
}
- public static List<DependencySet> getDependencySets( final ModuleBinaries binaries )
- {
+ public static List<DependencySet> getDependencySets(final ModuleBinaries binaries) {
List<DependencySet> depSets = binaries.getDependencySets();
- if ( ( ( depSets == null ) || depSets.isEmpty() ) && binaries.isIncludeDependencies() )
- {
+ if (((depSets == null) || depSets.isEmpty()) && binaries.isIncludeDependencies()) {
final DependencySet impliedDependencySet = new DependencySet();
- impliedDependencySet.setOutputDirectory( binaries.getOutputDirectory() );
- //impliedDependencySet.setOutputFileNameMapping( binaries.getOutputFileNameMapping() );
- impliedDependencySet.setFileMode( binaries.getFileMode() );
- impliedDependencySet.setDirectoryMode( binaries.getDirectoryMode() );
- impliedDependencySet.setExcludes( binaries.getExcludes() );
- impliedDependencySet.setIncludes( binaries.getIncludes() );
- impliedDependencySet.setUnpack( binaries.isUnpack() );
+ impliedDependencySet.setOutputDirectory(binaries.getOutputDirectory());
+ // impliedDependencySet.setOutputFileNameMapping( binaries.getOutputFileNameMapping() );
+ impliedDependencySet.setFileMode(binaries.getFileMode());
+ impliedDependencySet.setDirectoryMode(binaries.getDirectoryMode());
+ impliedDependencySet.setExcludes(binaries.getExcludes());
+ impliedDependencySet.setIncludes(binaries.getIncludes());
+ impliedDependencySet.setUnpack(binaries.isUnpack());
// unpackOptions is handled in the first stage of dependency-set handling, below.
- depSets = Collections.singletonList( impliedDependencySet );
+ depSets = Collections.singletonList(impliedDependencySet);
}
return depSets;
}
- public static Set<MavenProject> getModuleProjects( final ModuleSet moduleSet,
- final AssemblerConfigurationSource configSource,
- final Logger logger )
- throws ArchiveCreationException
- {
+ public static Set<MavenProject> getModuleProjects(
+ final ModuleSet moduleSet, final AssemblerConfigurationSource configSource, final Logger logger)
+ throws ArchiveCreationException {
MavenProject project = configSource.getProject();
Set<MavenProject> moduleProjects = null;
- if ( moduleSet.isUseAllReactorProjects() )
- {
- if ( !moduleSet.isIncludeSubModules() )
- {
- moduleProjects = new LinkedHashSet<>( configSource.getReactorProjects() );
+ if (moduleSet.isUseAllReactorProjects()) {
+ if (!moduleSet.isIncludeSubModules()) {
+ moduleProjects = new LinkedHashSet<>(configSource.getReactorProjects());
}
- project = configSource.getReactorProjects().get( 0 );
+ project = configSource.getReactorProjects().get(0);
}
- if ( moduleProjects == null )
- {
- try
- {
- moduleProjects = ProjectUtils.getProjectModules( project, configSource.getReactorProjects(),
- moduleSet.isIncludeSubModules(), logger );
- }
- catch ( final IOException e )
- {
+ if (moduleProjects == null) {
+ try {
+ moduleProjects = ProjectUtils.getProjectModules(
+ project, configSource.getReactorProjects(), moduleSet.isIncludeSubModules(), logger);
+ } catch (final IOException e) {
throw new ArchiveCreationException(
- "Error retrieving module-set for project: " + project.getId() + ": " + e.getMessage(), e );
+ "Error retrieving module-set for project: " + project.getId() + ": " + e.getMessage(), e);
}
}
- return FilterUtils.filterProjects( moduleProjects, moduleSet.getIncludes(), moduleSet.getExcludes(), true,
- logger );
+ return FilterUtils.filterProjects(
+ moduleProjects, moduleSet.getIncludes(), moduleSet.getExcludes(), true, logger);
}
/**
* {@inheritDoc}
*/
@Override
- public void execute( final Assembly assembly, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException
- {
- Assemblies.forEachModuleSet( assembly, new ModuleSetConsumer()
- {
+ public void execute(
+ final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
+ DependencyResolutionException {
+ Assemblies.forEachModuleSet(assembly, new ModuleSetConsumer() {
@Override
- public void accept( ModuleSet resolvedModule )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException
- {
- validate( resolvedModule, configSource );
+ public void accept(ModuleSet resolvedModule)
+ throws ArchiveCreationException, AssemblyFormattingException,
+ InvalidAssemblerConfigurationException, DependencyResolutionException {
+ validate(resolvedModule, configSource);
- final Set<MavenProject> moduleProjects = getModuleProjects( resolvedModule, configSource, LOGGER );
+ final Set<MavenProject> moduleProjects = getModuleProjects(resolvedModule, configSource, LOGGER);
final ModuleSources sources = resolvedModule.getSources();
- addModuleSourceFileSets( sources, moduleProjects, archiver, configSource );
+ addModuleSourceFileSets(sources, moduleProjects, archiver, configSource);
final ModuleBinaries binaries = resolvedModule.getBinaries();
- addModuleBinaries( assembly, resolvedModule, binaries, moduleProjects, archiver, configSource );
+ addModuleBinaries(assembly, resolvedModule, binaries, moduleProjects, archiver, configSource);
}
- } );
+ });
}
- private void validate( final ModuleSet moduleSet, final AssemblerConfigurationSource configSource )
- {
- if ( ( moduleSet.getSources() == null ) && ( moduleSet.getBinaries() == null ) )
- {
- LOGGER.warn( "Encountered ModuleSet with no sources or binaries specified. Skipping." );
+ private void validate(final ModuleSet moduleSet, final AssemblerConfigurationSource configSource) {
+ if ((moduleSet.getSources() == null) && (moduleSet.getBinaries() == null)) {
+ LOGGER.warn("Encountered ModuleSet with no sources or binaries specified. Skipping.");
}
- if ( moduleSet.isUseAllReactorProjects() && !moduleSet.isIncludeSubModules() )
- {
- LOGGER.warn( "includeSubModules == false is incompatible with useAllReactorProjects. Ignoring."
- + "\n\nTo refactor, remove the <includeSubModules/> flag, and use the <includes/> "
- + "and <excludes/> sections to fine-tune the modules included." );
+ if (moduleSet.isUseAllReactorProjects() && !moduleSet.isIncludeSubModules()) {
+ LOGGER.warn("includeSubModules == false is incompatible with useAllReactorProjects. Ignoring."
+ + "\n\nTo refactor, remove the <includeSubModules/> flag, and use the <includes/> "
+ + "and <excludes/> sections to fine-tune the modules included.");
}
final List<MavenProject> projects = configSource.getReactorProjects();
- if ( projects != null && projects.size() > 1 && projects.indexOf( configSource.getProject() ) == 0
- && moduleSet.getBinaries() != null )
- {
- LOGGER.warn( "[DEPRECATION] moduleSet/binaries section detected in root-project assembly."
- + "\n\nMODULE BINARIES MAY NOT BE AVAILABLE FOR THIS ASSEMBLY!"
- + "\n\n To refactor, move this assembly into a child project and use the flag "
- + "<useAllReactorProjects>true</useAllReactorProjects> in each moduleSet." );
+ if (projects != null
+ && projects.size() > 1
+ && projects.indexOf(configSource.getProject()) == 0
+ && moduleSet.getBinaries() != null) {
+ LOGGER.warn("[DEPRECATION] moduleSet/binaries section detected in root-project assembly."
+ + "\n\nMODULE BINARIES MAY NOT BE AVAILABLE FOR THIS ASSEMBLY!"
+ + "\n\n To refactor, move this assembly into a child project and use the flag "
+ + "<useAllReactorProjects>true</useAllReactorProjects> in each moduleSet.");
}
- if ( moduleSet.getSources() != null )
- {
+ if (moduleSet.getSources() != null) {
final ModuleSources sources = moduleSet.getSources();
- if ( isDeprecatedModuleSourcesConfigPresent( sources ) )
- {
- LOGGER.warn( "[DEPRECATION] Use of <moduleSources/> as a file-set is deprecated. "
- + "Please use the <fileSets/> sub-element of <moduleSources/> instead." );
- }
- else if ( !sources.isUseDefaultExcludes() )
- {
- LOGGER.warn( "[DEPRECATION] Use of directoryMode, fileMode, or useDefaultExcludes "
- + "elements directly within <moduleSources/> are all deprecated. "
- + "Please use the <fileSets/> sub-element of <moduleSources/> instead." );
+ if (isDeprecatedModuleSourcesConfigPresent(sources)) {
+ LOGGER.warn("[DEPRECATION] Use of <moduleSources/> as a file-set is deprecated. "
+ + "Please use the <fileSets/> sub-element of <moduleSources/> instead.");
+ } else if (!sources.isUseDefaultExcludes()) {
+ LOGGER.warn("[DEPRECATION] Use of directoryMode, fileMode, or useDefaultExcludes "
+ + "elements directly within <moduleSources/> are all deprecated. "
+ + "Please use the <fileSets/> sub-element of <moduleSources/> instead.");
}
}
}
- void addModuleBinaries( final Assembly assembly, ModuleSet moduleSet, final ModuleBinaries binaries,
- final Set<MavenProject> projects, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException
- {
- if ( binaries == null )
- {
+ void addModuleBinaries(
+ final Assembly assembly,
+ ModuleSet moduleSet,
+ final ModuleBinaries binaries,
+ final Set<MavenProject> projects,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
+ DependencyResolutionException {
+ if (binaries == null) {
return;
}
final Set<MavenProject> moduleProjects = new LinkedHashSet<>();
- MavenProjects.select( projects, "pom", log( LOGGER ), addTo( moduleProjects ) );
+ MavenProjects.select(projects, "pom", log(LOGGER), addTo(moduleProjects));
final String classifier = binaries.getAttachmentClassifier();
final Map<MavenProject, Artifact> chosenModuleArtifacts = new HashMap<>();
- for ( final MavenProject project : moduleProjects )
- {
+ for (final MavenProject project : moduleProjects) {
Artifact artifact;
- if ( classifier == null )
- {
- LOGGER.debug( "Processing binary artifact for module project: " + project.getId() );
+ if (classifier == null) {
+ LOGGER.debug("Processing binary artifact for module project: " + project.getId());
artifact = project.getArtifact();
- }
- else
- {
- LOGGER.debug(
- "Processing binary attachment: " + classifier + " for module project: " + project.getId() );
+ } else {
+ LOGGER.debug("Processing binary attachment: " + classifier + " for module project: " + project.getId());
- artifact = MavenProjects.findArtifactByClassifier( project, classifier );
+ artifact = MavenProjects.findArtifactByClassifier(project, classifier);
- if ( artifact == null )
- {
+ if (artifact == null) {
throw new InvalidAssemblerConfigurationException(
- "Cannot find attachment with classifier: " + classifier + " in module project: "
- + project.getId() + ". Please exclude this module from the module-set." );
+ "Cannot find attachment with classifier: " + classifier + " in module project: "
+ + project.getId() + ". Please exclude this module from the module-set.");
}
}
- chosenModuleArtifacts.put( project, artifact );
- addModuleArtifact( artifact, project, archiver, configSource, binaries );
+ chosenModuleArtifacts.put(project, artifact);
+ addModuleArtifact(artifact, project, archiver, configSource, binaries);
}
- final List<DependencySet> depSets = getDependencySets( binaries );
+ final List<DependencySet> depSets = getDependencySets(binaries);
- if ( depSets != null )
- {
+ if (depSets != null) {
Map<DependencySet, Set<Artifact>> dependencySetSetMap =
- dependencyResolver.resolveDependencySets( assembly, moduleSet, configSource, depSets );
+ dependencyResolver.resolveDependencySets(assembly, moduleSet, configSource, depSets);
- for ( final DependencySet ds : depSets )
- {
+ for (final DependencySet ds : depSets) {
// NOTE: Disabling useProjectArtifact flag, since module artifact has already been handled!
- ds.setUseProjectArtifact( false );
+ ds.setUseProjectArtifact(false);
}
// TODO: The following should be moved into a shared component, cause this
// test is the same as in maven-enforce rules ReactorModuleConvergence.
- List<MavenProject> validateModuleVersions = validateModuleVersions( moduleProjects );
- if ( !validateModuleVersions.isEmpty() )
- {
+ List<MavenProject> validateModuleVersions = validateModuleVersions(moduleProjects);
+ if (!validateModuleVersions.isEmpty()) {
StringBuilder sb =
- new StringBuilder().append( "The current modules seemed to be having different versions." );
- sb.append( LINE_SEPARATOR );
- for ( MavenProject mavenProject : validateModuleVersions )
- {
- sb.append( " --> " );
- sb.append( mavenProject.getId() );
- sb.append( LINE_SEPARATOR );
+ new StringBuilder().append("The current modules seemed to be having different versions.");
+ sb.append(LINE_SEPARATOR);
+ for (MavenProject mavenProject : validateModuleVersions) {
+ sb.append(" --> ");
+ sb.append(mavenProject.getId());
+ sb.append(LINE_SEPARATOR);
}
- LOGGER.warn( sb.toString() );
+ LOGGER.warn(sb.toString());
}
- for ( final MavenProject moduleProject : moduleProjects )
- {
- LOGGER.debug( "Processing binary dependencies for module project: " + moduleProject.getId() );
-
- for ( Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : dependencySetSetMap.entrySet() )
- {
- final AddDependencySetsTask task =
- new AddDependencySetsTask( Collections.singletonList( dependencySetSetEntry.getKey() ),
- dependencySetSetEntry.getValue(), moduleProject, projectBuilder );
+ for (final MavenProject moduleProject : moduleProjects) {
+ LOGGER.debug("Processing binary dependencies for module project: " + moduleProject.getId());
- task.setModuleProject( moduleProject );
- task.setModuleArtifact( chosenModuleArtifacts.get( moduleProject ) );
- task.setDefaultOutputDirectory( binaries.getOutputDirectory() );
- task.setDefaultOutputFileNameMapping( binaries.getOutputFileNameMapping() );
+ for (Map.Entry<DependencySet, Set<Artifact>> dependencySetSetEntry : dependencySetSetMap.entrySet()) {
+ final AddDependencySetsTask task = new AddDependencySetsTask(
+ Collections.singletonList(dependencySetSetEntry.getKey()),
+ dependencySetSetEntry.getValue(),
+ moduleProject,
+ projectBuilder);
- task.execute( archiver, configSource );
+ task.setModuleProject(moduleProject);
+ task.setModuleArtifact(chosenModuleArtifacts.get(moduleProject));
+ task.setDefaultOutputDirectory(binaries.getOutputDirectory());
+ task.setDefaultOutputFileNameMapping(binaries.getOutputFileNameMapping());
+ task.execute(archiver, configSource);
}
}
}
}
- private List<MavenProject> validateModuleVersions( Set<MavenProject> moduleProjects )
- {
+ private List<MavenProject> validateModuleVersions(Set<MavenProject> moduleProjects) {
List<MavenProject> result = new ArrayList<>();
- if ( moduleProjects != null && !moduleProjects.isEmpty() )
- {
+ if (moduleProjects != null && !moduleProjects.isEmpty()) {
String version = moduleProjects.iterator().next().getVersion();
- LOGGER.debug( "First version:" + version );
- for ( MavenProject mavenProject : moduleProjects )
- {
- LOGGER.debug( " -> checking " + mavenProject.getId() );
- if ( !version.equals( mavenProject.getVersion() ) )
- {
- result.add( mavenProject );
+ LOGGER.debug("First version:" + version);
+ for (MavenProject mavenProject : moduleProjects) {
+ LOGGER.debug(" -> checking " + mavenProject.getId());
+ if (!version.equals(mavenProject.getVersion())) {
+ result.add(mavenProject);
}
}
}
return result;
}
- void addModuleArtifact( final Artifact artifact, final MavenProject project, final Archiver archiver,
- final AssemblerConfigurationSource configSource, final ModuleBinaries binaries )
- throws ArchiveCreationException, AssemblyFormattingException
- {
- if ( artifact.getFile() == null )
- {
+ void addModuleArtifact(
+ final Artifact artifact,
+ final MavenProject project,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource,
+ final ModuleBinaries binaries)
+ throws ArchiveCreationException, AssemblyFormattingException {
+ if (artifact.getFile() == null) {
throw new ArchiveCreationException(
- "Artifact: " + artifact.getId() + " (included by module) does not have an artifact with a file. "
- + "Please ensure the package phase is run before the assembly is generated." );
+ "Artifact: " + artifact.getId() + " (included by module) does not have an artifact with a file. "
+ + "Please ensure the package phase is run before the assembly is generated.");
}
- final AddArtifactTask task = new AddArtifactTask( artifact, null );
+ final AddArtifactTask task = new AddArtifactTask(artifact, null);
- task.setFileNameMapping( binaries.getOutputFileNameMapping() );
- task.setOutputDirectory( binaries.getOutputDirectory() );
- task.setProject( project );
- task.setModuleProject( project );
- task.setModuleArtifact( artifact );
+ task.setFileNameMapping(binaries.getOutputFileNameMapping());
+ task.setOutputDirectory(binaries.getOutputDirectory());
+ task.setProject(project);
+ task.setModuleProject(project);
+ task.setModuleArtifact(artifact);
- final int dirMode = TypeConversionUtils.modeToInt( binaries.getDirectoryMode(), LOGGER );
- if ( dirMode != -1 )
- {
- task.setDirectoryMode( dirMode );
+ final int dirMode = TypeConversionUtils.modeToInt(binaries.getDirectoryMode(), LOGGER);
+ if (dirMode != -1) {
+ task.setDirectoryMode(dirMode);
}
- final int fileMode = TypeConversionUtils.modeToInt( binaries.getFileMode(), LOGGER );
- if ( fileMode != -1 )
- {
- task.setFileMode( fileMode );
+ final int fileMode = TypeConversionUtils.modeToInt(binaries.getFileMode(), LOGGER);
+ if (fileMode != -1) {
+ task.setFileMode(fileMode);
}
- task.setUnpack( binaries.isUnpack() );
+ task.setUnpack(binaries.isUnpack());
- if ( binaries.isUnpack() && binaries.getUnpackOptions() != null )
- {
- task.setIncludes( binaries.getUnpackOptions().getIncludes() );
- task.setExcludes( binaries.getUnpackOptions().getExcludes() );
+ if (binaries.isUnpack() && binaries.getUnpackOptions() != null) {
+ task.setIncludes(binaries.getUnpackOptions().getIncludes());
+ task.setExcludes(binaries.getUnpackOptions().getExcludes());
}
- task.execute( archiver, configSource );
+ task.execute(archiver, configSource);
}
- void addModuleSourceFileSets( final ModuleSources sources, final Set<MavenProject> moduleProjects,
- final Archiver archiver, final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException
- {
- if ( sources == null )
- {
+ void addModuleSourceFileSets(
+ final ModuleSources sources,
+ final Set<MavenProject> moduleProjects,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException {
+ if (sources == null) {
return;
}
final List<FileSet> fileSets = new ArrayList<>();
- if ( isDeprecatedModuleSourcesConfigPresent( sources ) )
- {
+ if (isDeprecatedModuleSourcesConfigPresent(sources)) {
final FileSet fs = new FileSet();
- fs.setOutputDirectory( sources.getOutputDirectory() );
- fs.setIncludes( sources.getIncludes() );
- fs.setExcludes( sources.getExcludes() );
- fs.setUseDefaultExcludes( sources.isUseDefaultExcludes() );
+ fs.setOutputDirectory(sources.getOutputDirectory());
+ fs.setIncludes(sources.getIncludes());
+ fs.setExcludes(sources.getExcludes());
+ fs.setUseDefaultExcludes(sources.isUseDefaultExcludes());
- fileSets.add( fs );
+ fileSets.add(fs);
}
List<FileSet> subFileSets = sources.getFileSets();
- if ( ( subFileSets == null ) || subFileSets.isEmpty() )
- {
+ if ((subFileSets == null) || subFileSets.isEmpty()) {
final FileSet fs = new FileSet();
- fs.setDirectory( "src" );
+ fs.setDirectory("src");
- subFileSets = Collections.singletonList( fs );
+ subFileSets = Collections.singletonList(fs);
}
- fileSets.addAll( subFileSets );
+ fileSets.addAll(subFileSets);
- for ( final MavenProject moduleProject : moduleProjects )
- {
- LOGGER.info( "Processing sources for module project: " + moduleProject.getId() );
+ for (final MavenProject moduleProject : moduleProjects) {
+ LOGGER.info("Processing sources for module project: " + moduleProject.getId());
final List<FileSet> moduleFileSets = new ArrayList<>();
- for ( final FileSet fileSet : fileSets )
- {
- moduleFileSets.add( createFileSet( fileSet, sources, moduleProject, configSource ) );
+ for (final FileSet fileSet : fileSets) {
+ moduleFileSets.add(createFileSet(fileSet, sources, moduleProject, configSource));
}
- final AddFileSetsTask task = new AddFileSetsTask( moduleFileSets );
+ final AddFileSetsTask task = new AddFileSetsTask(moduleFileSets);
- task.setProject( moduleProject );
- task.setModuleProject( moduleProject );
+ task.setProject(moduleProject);
+ task.setModuleProject(moduleProject);
- task.execute( archiver, configSource );
+ task.execute(archiver, configSource);
}
}
/**
* Determine whether the deprecated file-set configuration directly within the ModuleSources object is present.
*/
- boolean isDeprecatedModuleSourcesConfigPresent( final ModuleSources sources )
- {
+ boolean isDeprecatedModuleSourcesConfigPresent(final ModuleSources sources) {
boolean result = false;
- if ( sources.getOutputDirectory() != null )
- {
+ if (sources.getOutputDirectory() != null) {
result = true;
- }
- else if ( ( sources.getIncludes() != null ) && !sources.getIncludes().isEmpty() )
- {
+ } else if ((sources.getIncludes() != null) && !sources.getIncludes().isEmpty()) {
result = true;
- }
- else if ( ( sources.getExcludes() != null ) && !sources.getExcludes().isEmpty() )
- {
+ } else if ((sources.getExcludes() != null) && !sources.getExcludes().isEmpty()) {
result = true;
}
return result;
}
- FileSet createFileSet( final FileSet fileSet, final ModuleSources sources,
- final MavenProject moduleProject,
- final AssemblerConfigurationSource configSource )
- throws AssemblyFormattingException
- {
+ FileSet createFileSet(
+ final FileSet fileSet,
+ final ModuleSources sources,
+ final MavenProject moduleProject,
+ final AssemblerConfigurationSource configSource)
+ throws AssemblyFormattingException {
final FileSet fs = new FileSet();
String sourcePath = fileSet.getDirectory();
final File moduleBasedir = moduleProject.getBasedir();
- if ( sourcePath != null )
- {
- final File sourceDir = new File( sourcePath );
+ if (sourcePath != null) {
+ final File sourceDir = new File(sourcePath);
- if ( !AssemblyFileUtils.isAbsolutePath( sourceDir ) )
- {
- sourcePath = new File( moduleBasedir, sourcePath ).getAbsolutePath();
+ if (!AssemblyFileUtils.isAbsolutePath(sourceDir)) {
+ sourcePath = new File(moduleBasedir, sourcePath).getAbsolutePath();
}
- }
- else
- {
+ } else {
sourcePath = moduleBasedir.getAbsolutePath();
}
- fs.setDirectory( sourcePath );
- fs.setDirectoryMode( fileSet.getDirectoryMode() );
+ fs.setDirectory(sourcePath);
+ fs.setDirectoryMode(fileSet.getDirectoryMode());
final List<String> excludes = new ArrayList<>();
final List<String> originalExcludes = fileSet.getExcludes();
- if ( ( originalExcludes != null ) && !originalExcludes.isEmpty() )
- {
- excludes.addAll( originalExcludes );
+ if ((originalExcludes != null) && !originalExcludes.isEmpty()) {
+ excludes.addAll(originalExcludes);
}
- if ( sources.isExcludeSubModuleDirectories() )
- {
+ if (sources.isExcludeSubModuleDirectories()) {
final List<String> modules = moduleProject.getModules();
- for ( final String moduleSubPath : modules )
- {
- excludes.add( moduleSubPath + "/**" );
+ for (final String moduleSubPath : modules) {
+ excludes.add(moduleSubPath + "/**");
}
}
- fs.setExcludes( excludes );
- fs.setFiltered( fileSet.isFiltered() );
- fs.setFileMode( fileSet.getFileMode() );
- fs.setIncludes( fileSet.getIncludes() );
- fs.setLineEnding( fileSet.getLineEnding() );
+ fs.setExcludes(excludes);
+ fs.setFiltered(fileSet.isFiltered());
+ fs.setFileMode(fileSet.getFileMode());
+ fs.setIncludes(fileSet.getIncludes());
+ fs.setLineEnding(fileSet.getLineEnding());
FixedStringSearchInterpolator moduleProjectInterpolator =
- AssemblyFormatUtils.moduleProjectInterpolator( moduleProject );
+ AssemblyFormatUtils.moduleProjectInterpolator(moduleProject);
FixedStringSearchInterpolator artifactProjectInterpolator =
- AssemblyFormatUtils.artifactProjectInterpolator( moduleProject );
+ AssemblyFormatUtils.artifactProjectInterpolator(moduleProject);
String destPathPrefix = "";
- if ( sources.isIncludeModuleDirectory() )
- {
- destPathPrefix = AssemblyFormatUtils.evaluateFileNameMapping( sources.getOutputDirectoryMapping(),
- moduleProject.getArtifact(),
- configSource.getProject(),
- moduleProject.getArtifact(), configSource,
- moduleProjectInterpolator,
- artifactProjectInterpolator );
-
- if ( !destPathPrefix.endsWith( "/" ) )
- {
+ if (sources.isIncludeModuleDirectory()) {
+ destPathPrefix = AssemblyFormatUtils.evaluateFileNameMapping(
+ sources.getOutputDirectoryMapping(),
+ moduleProject.getArtifact(),
+ configSource.getProject(),
+ moduleProject.getArtifact(),
+ configSource,
+ moduleProjectInterpolator,
+ artifactProjectInterpolator);
+
+ if (!destPathPrefix.endsWith("/")) {
destPathPrefix += "/";
}
}
String destPath = fileSet.getOutputDirectory();
- if ( destPath == null )
- {
+ if (destPath == null) {
destPath = destPathPrefix;
- }
- else
- {
+ } else {
destPath = destPathPrefix + destPath;
}
- destPath = AssemblyFormatUtils.getOutputDirectory( destPath, configSource.getFinalName(), configSource,
- moduleProjectInterpolator, artifactProjectInterpolator );
+ destPath = AssemblyFormatUtils.getOutputDirectory(
+ destPath,
+ configSource.getFinalName(),
+ configSource,
+ moduleProjectInterpolator,
+ artifactProjectInterpolator);
- fs.setOutputDirectory( destPath );
+ fs.setOutputDirectory(destPath);
- LOGGER.debug( "module source directory is: " + sourcePath );
- LOGGER.debug( "module dest directory is: " + destPath + " (assembly basedir may be prepended)" );
+ LOGGER.debug("module source directory is: " + sourcePath);
+ LOGGER.debug("module dest directory is: " + destPath + " (assembly basedir may be prepended)");
return fs;
}
@Override
- public int order()
- {
+ public int order() {
// CHECKSTYLE_OFF: MagicNumber
return 30;
// CHECKSTYLE_ON: MagicNumber
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/PhaseOrder.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/PhaseOrder.java
index 978732de..287b75ff 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/PhaseOrder.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/PhaseOrder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,12 +16,12 @@ package org.apache.maven.plugins.assembly.archive.phase;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.phase;
/**
* Indicates the order of a phase
* Elements without order will come before the ordered elements
*/
-public interface PhaseOrder
-{
+public interface PhaseOrder {
int order();
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTask.java
index 136e1398..23cd91b8 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTask.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.task;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,12 @@ package org.apache.maven.plugins.assembly.archive.task;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.task;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
@@ -36,19 +40,13 @@ import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.List;
-
/**
*
*/
-public class AddArtifactTask
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( AddArtifactTask.class );
+public class AddArtifactTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AddArtifactTask.class);
- public static final String[] DEFAULT_INCLUDES_ARRAY = { "**/*" };
+ public static final String[] DEFAULT_INCLUDES_ARRAY = {"**/*"};
private final Artifact artifact;
@@ -78,31 +76,28 @@ public class AddArtifactTask
private String outputFileNameMapping;
- public AddArtifactTask( final Artifact artifact, InputStreamTransformer transformer,
- Charset encoding )
- {
+ public AddArtifactTask(final Artifact artifact, InputStreamTransformer transformer, Charset encoding) {
this.artifact = artifact;
this.transformer = transformer;
this.encoding = encoding;
}
- public AddArtifactTask( final Artifact artifact, Charset encoding )
- {
- this( artifact, null, encoding );
+ public AddArtifactTask(final Artifact artifact, Charset encoding) {
+ this(artifact, null, encoding);
}
- public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException
- {
- if ( artifactIsArchiverDestination( archiver ) )
- {
- artifact.setFile( moveArtifactSomewhereElse( configSource ) );
+ public void execute(final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException {
+ if (artifactIsArchiverDestination(archiver)) {
+ artifact.setFile(moveArtifactSomewhereElse(configSource));
}
- String destDirectory =
- AssemblyFormatUtils.getOutputDirectory( outputDirectory, configSource.getFinalName(), configSource,
- AssemblyFormatUtils.moduleProjectInterpolator( moduleProject ),
- AssemblyFormatUtils.artifactProjectInterpolator( project ) );
+ String destDirectory = AssemblyFormatUtils.getOutputDirectory(
+ outputDirectory,
+ configSource.getFinalName(),
+ configSource,
+ AssemblyFormatUtils.moduleProjectInterpolator(moduleProject),
+ AssemblyFormatUtils.artifactProjectInterpolator(project));
boolean fileModeSet = false;
boolean dirModeSet = false;
@@ -110,231 +105,182 @@ public class AddArtifactTask
final int oldDirMode = archiver.getOverrideDirectoryMode();
final int oldFileMode = archiver.getOverrideFileMode();
- if ( fileMode != -1 )
- {
- archiver.setFileMode( fileMode );
+ if (fileMode != -1) {
+ archiver.setFileMode(fileMode);
fileModeSet = true;
}
- if ( directoryMode != -1 )
- {
- archiver.setDirectoryMode( directoryMode );
+ if (directoryMode != -1) {
+ archiver.setDirectoryMode(directoryMode);
dirModeSet = true;
}
- try
- {
+ try {
- if ( unpack )
- {
- unpacked( archiver, destDirectory );
- }
- else
- {
- asFile( archiver, configSource, destDirectory );
+ if (unpack) {
+ unpacked(archiver, destDirectory);
+ } else {
+ asFile(archiver, configSource, destDirectory);
}
- }
- finally
- {
- if ( dirModeSet )
- {
- archiver.setDirectoryMode( oldDirMode );
+ } finally {
+ if (dirModeSet) {
+ archiver.setDirectoryMode(oldDirMode);
}
- if ( fileModeSet )
- {
- archiver.setFileMode( oldFileMode );
+ if (fileModeSet) {
+ archiver.setFileMode(oldFileMode);
}
}
-
}
- private void asFile( Archiver archiver, AssemblerConfigurationSource configSource, String destDirectory )
- throws AssemblyFormattingException, ArchiveCreationException
- {
- final String tempMapping =
- AssemblyFormatUtils.evaluateFileNameMapping( outputFileNameMapping, artifact, configSource.getProject(),
- moduleArtifact, configSource,
- AssemblyFormatUtils.moduleProjectInterpolator( moduleProject ),
- AssemblyFormatUtils.artifactProjectInterpolator( project ) );
+ private void asFile(Archiver archiver, AssemblerConfigurationSource configSource, String destDirectory)
+ throws AssemblyFormattingException, ArchiveCreationException {
+ final String tempMapping = AssemblyFormatUtils.evaluateFileNameMapping(
+ outputFileNameMapping,
+ artifact,
+ configSource.getProject(),
+ moduleArtifact,
+ configSource,
+ AssemblyFormatUtils.moduleProjectInterpolator(moduleProject),
+ AssemblyFormatUtils.artifactProjectInterpolator(project));
final String outputLocation = destDirectory + tempMapping;
- try
- {
+ try {
final File artifactFile = artifact.getFile();
- LOGGER.debug(
- "Adding artifact: " + artifact.getId() + " with file: " + artifactFile + " to assembly location: "
- + outputLocation + "." );
+ LOGGER.debug("Adding artifact: " + artifact.getId() + " with file: " + artifactFile
+ + " to assembly location: " + outputLocation + ".");
- if ( fileMode != -1 )
- {
- archiver.addFile( artifactFile, outputLocation, fileMode );
- }
- else
- {
- archiver.addFile( artifactFile, outputLocation );
+ if (fileMode != -1) {
+ archiver.addFile(artifactFile, outputLocation, fileMode);
+ } else {
+ archiver.addFile(artifactFile, outputLocation);
}
- }
- catch ( final ArchiverException e )
- {
+ } catch (final ArchiverException e) {
throw new ArchiveCreationException(
- "Error adding file '" + artifact.getId() + "' to archive: " + e.getMessage(), e );
+ "Error adding file '" + artifact.getId() + "' to archive: " + e.getMessage(), e);
}
}
- private void unpacked( Archiver archiver, String destDirectory )
- throws ArchiveCreationException
- {
+ private void unpacked(Archiver archiver, String destDirectory) throws ArchiveCreationException {
String outputLocation = destDirectory;
- if ( ( outputLocation.length() > 0 ) && !outputLocation.endsWith( "/" ) )
- {
+ if ((outputLocation.length() > 0) && !outputLocation.endsWith("/")) {
outputLocation += "/";
}
- String[] includesArray = TypeConversionUtils.toStringArray( includes );
- if ( includesArray == null )
- {
+ String[] includesArray = TypeConversionUtils.toStringArray(includes);
+ if (includesArray == null) {
includesArray = DEFAULT_INCLUDES_ARRAY;
}
- final String[] excludesArray = TypeConversionUtils.toStringArray( excludes );
+ final String[] excludesArray = TypeConversionUtils.toStringArray(excludes);
- try
- {
+ try {
final File artifactFile = artifact.getFile();
- if ( artifactFile == null )
- {
- LOGGER.warn(
- "Skipping artifact: " + artifact.getId() + "; it does not have an associated file or directory." );
+ if (artifactFile == null) {
+ LOGGER.warn("Skipping artifact: " + artifact.getId()
+ + "; it does not have an associated file or directory.");
+ } else if (artifactFile.isDirectory()) {
+ LOGGER.debug("Adding artifact directory contents for: " + artifact + " to: " + outputLocation);
+
+ DefaultFileSet fs = DefaultFileSet.fileSet(artifactFile);
+ fs.setIncludes(includesArray);
+ fs.setExcludes(excludesArray);
+ fs.setPrefix(outputLocation);
+ fs.setStreamTransformer(transformer);
+ fs.setUsingDefaultExcludes(usingDefaultExcludes);
+ archiver.addFileSet(fs);
+ } else {
+ LOGGER.debug("Unpacking artifact contents for: " + artifact + " to: " + outputLocation);
+ LOGGER.debug("includes:\n" + StringUtils.join(includesArray, "\n") + "\n");
+ LOGGER.debug("excludes:\n" + (excludesArray == null ? "none" : StringUtils.join(excludesArray, "\n"))
+ + "\n");
+ DefaultArchivedFileSet afs = DefaultArchivedFileSet.archivedFileSet(artifactFile);
+ afs.setIncludes(includesArray);
+ afs.setExcludes(excludesArray);
+ afs.setPrefix(outputLocation);
+ afs.setStreamTransformer(transformer);
+ afs.setUsingDefaultExcludes(usingDefaultExcludes);
+ archiver.addArchivedFileSet(afs, encoding);
}
- else if ( artifactFile.isDirectory() )
- {
- LOGGER.debug( "Adding artifact directory contents for: " + artifact + " to: " + outputLocation );
-
- DefaultFileSet fs = DefaultFileSet.fileSet( artifactFile );
- fs.setIncludes( includesArray );
- fs.setExcludes( excludesArray );
- fs.setPrefix( outputLocation );
- fs.setStreamTransformer( transformer );
- fs.setUsingDefaultExcludes( usingDefaultExcludes );
- archiver.addFileSet( fs );
- }
- else
- {
- LOGGER.debug( "Unpacking artifact contents for: " + artifact + " to: " + outputLocation );
- LOGGER.debug( "includes:\n" + StringUtils.join( includesArray, "\n" ) + "\n" );
- LOGGER.debug(
- "excludes:\n" + ( excludesArray == null ? "none" : StringUtils.join( excludesArray, "\n" ) )
- + "\n" );
- DefaultArchivedFileSet afs = DefaultArchivedFileSet.archivedFileSet( artifactFile );
- afs.setIncludes( includesArray );
- afs.setExcludes( excludesArray );
- afs.setPrefix( outputLocation );
- afs.setStreamTransformer( transformer );
- afs.setUsingDefaultExcludes( usingDefaultExcludes );
- archiver.addArchivedFileSet( afs, encoding );
- }
- }
- catch ( final ArchiverException e )
- {
+ } catch (final ArchiverException e) {
throw new ArchiveCreationException(
- "Error adding file-set for '" + artifact.getId() + "' to archive: " + e.getMessage(), e );
+ "Error adding file-set for '" + artifact.getId() + "' to archive: " + e.getMessage(), e);
}
}
- private File moveArtifactSomewhereElse( AssemblerConfigurationSource configSource )
- throws ArchiveCreationException
- {
+ private File moveArtifactSomewhereElse(AssemblerConfigurationSource configSource) throws ArchiveCreationException {
final File tempRoot = configSource.getTemporaryRootDirectory();
- final File tempArtifactFile = new File( tempRoot, artifact.getFile().getName() );
-
- LOGGER.warn(
- "Artifact: " + artifact.getId() + " references the same file as the assembly destination file. "
- + "Moving it to a temporary location for inclusion." );
- try
- {
- FileUtils.copyFile( artifact.getFile(), tempArtifactFile );
- }
- catch ( final IOException e )
- {
+ final File tempArtifactFile = new File(tempRoot, artifact.getFile().getName());
+
+ LOGGER.warn("Artifact: " + artifact.getId() + " references the same file as the assembly destination file. "
+ + "Moving it to a temporary location for inclusion.");
+ try {
+ FileUtils.copyFile(artifact.getFile(), tempArtifactFile);
+ } catch (final IOException e) {
throw new ArchiveCreationException(
- "Error moving artifact file: '" + artifact.getFile() + "' to temporary location: " + tempArtifactFile
- + ". Reason: " + e.getMessage(), e );
+ "Error moving artifact file: '" + artifact.getFile() + "' to temporary location: "
+ + tempArtifactFile + ". Reason: " + e.getMessage(),
+ e);
}
return tempArtifactFile;
}
- private boolean artifactIsArchiverDestination( Archiver archiver )
- {
- return ( ( artifact.getFile() != null ) && ( archiver.getDestFile() != null ) ) && artifact.getFile().equals(
- archiver.getDestFile() );
+ private boolean artifactIsArchiverDestination(Archiver archiver) {
+ return ((artifact.getFile() != null) && (archiver.getDestFile() != null))
+ && artifact.getFile().equals(archiver.getDestFile());
}
- public void setDirectoryMode( final int directoryMode )
- {
+ public void setDirectoryMode(final int directoryMode) {
this.directoryMode = directoryMode;
}
- public void setFileMode( final int fileMode )
- {
+ public void setFileMode(final int fileMode) {
this.fileMode = fileMode;
}
- public void setExcludes( final List<String> excludes )
- {
+ public void setExcludes(final List<String> excludes) {
this.excludes = excludes;
}
- public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
- {
+ public void setUsingDefaultExcludes(boolean usingDefaultExcludes) {
this.usingDefaultExcludes = usingDefaultExcludes;
}
- public void setIncludes( final List<String> includes )
- {
+ public void setIncludes(final List<String> includes) {
this.includes = includes;
}
- public void setUnpack( final boolean unpack )
- {
+ public void setUnpack(final boolean unpack) {
this.unpack = unpack;
}
- public void setProject( final MavenProject project )
- {
+ public void setProject(final MavenProject project) {
this.project = project;
}
- public void setOutputDirectory( final String outputDirectory )
- {
+ public void setOutputDirectory(final String outputDirectory) {
this.outputDirectory = outputDirectory;
}
- public void setFileNameMapping( final String outputFileNameMapping )
- {
+ public void setFileNameMapping(final String outputFileNameMapping) {
this.outputFileNameMapping = outputFileNameMapping;
}
- public void setOutputDirectory( final String outputDirectory, final String defaultOutputDirectory )
- {
- setOutputDirectory( outputDirectory == null ? defaultOutputDirectory : outputDirectory );
+ public void setOutputDirectory(final String outputDirectory, final String defaultOutputDirectory) {
+ setOutputDirectory(outputDirectory == null ? defaultOutputDirectory : outputDirectory);
}
- public void setFileNameMapping( final String outputFileNameMapping, final String defaultOutputFileNameMapping )
- {
- setFileNameMapping( outputFileNameMapping == null ? defaultOutputFileNameMapping : outputFileNameMapping );
+ public void setFileNameMapping(final String outputFileNameMapping, final String defaultOutputFileNameMapping) {
+ setFileNameMapping(outputFileNameMapping == null ? defaultOutputFileNameMapping : outputFileNameMapping);
}
- public void setModuleProject( final MavenProject moduleProject )
- {
+ public void setModuleProject(final MavenProject moduleProject) {
this.moduleProject = moduleProject;
}
- public void setModuleArtifact( final Artifact moduleArtifact )
- {
+ public void setModuleArtifact(final Artifact moduleArtifact) {
this.moduleArtifact = moduleArtifact;
}
-
}
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 4c1fff71..bd9e5fd8 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.task;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.archive.task;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.task;
import java.io.File;
import java.nio.charset.Charset;
@@ -60,19 +59,17 @@ import org.slf4j.LoggerFactory;
/**
*
*/
-public class AddDependencySetsTask
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( AddDependencySetsTask.class );
+public class AddDependencySetsTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AddDependencySetsTask.class);
private static final List<String> NON_ARCHIVE_DEPENDENCY_TYPES;
- static
- {
+ static {
final List<String> nonArch = new ArrayList<>();
- nonArch.add( "pom" );
+ nonArch.add("pom");
- NON_ARCHIVE_DEPENDENCY_TYPES = Collections.unmodifiableList( nonArch );
+ NON_ARCHIVE_DEPENDENCY_TYPES = Collections.unmodifiableList(nonArch);
}
private final List<DependencySet> dependencySets;
@@ -91,339 +88,299 @@ public class AddDependencySetsTask
private Artifact moduleArtifact;
-
- public AddDependencySetsTask( final List<DependencySet> dependencySets, final Set<Artifact> resolvedArtifacts,
- final MavenProject project, ProjectBuilder projectBuilder )
- {
+ public AddDependencySetsTask(
+ final List<DependencySet> dependencySets,
+ final Set<Artifact> resolvedArtifacts,
+ final MavenProject project,
+ ProjectBuilder projectBuilder) {
this.dependencySets = dependencySets;
this.resolvedArtifacts = resolvedArtifacts;
this.project = project;
this.projectBuilder1 = projectBuilder;
}
- public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
- {
- if ( ( dependencySets == null ) || dependencySets.isEmpty() )
- {
- LOGGER.debug( "No dependency sets specified." );
+ public void execute(final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
+ if ((dependencySets == null) || dependencySets.isEmpty()) {
+ LOGGER.debug("No dependency sets specified.");
return;
}
final List<Dependency> deps = project.getDependencies();
- if ( ( deps == null ) || deps.isEmpty() )
- {
- LOGGER.debug(
- "Project " + project.getId() + " has no dependencies. Skipping dependency set addition." );
+ if ((deps == null) || deps.isEmpty()) {
+ LOGGER.debug("Project " + project.getId() + " has no dependencies. Skipping dependency set addition.");
}
- for ( final DependencySet dependencySet : dependencySets )
- {
- addDependencySet( dependencySet, archiver, configSource );
+ for (final DependencySet dependencySet : dependencySets) {
+ addDependencySet(dependencySet, archiver, configSource);
}
}
- void addDependencySet( final DependencySet dependencySet, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException
- {
- LOGGER.debug( "Processing DependencySet (output=" + dependencySet.getOutputDirectory() + ")" );
+ void addDependencySet(
+ final DependencySet dependencySet, final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException {
+ LOGGER.debug("Processing DependencySet (output=" + dependencySet.getOutputDirectory() + ")");
- if ( !dependencySet.isUseTransitiveDependencies() && dependencySet.isUseTransitiveFiltering() )
- {
- LOGGER.warn( "DependencySet has nonsensical configuration: useTransitiveDependencies == false "
- + "AND useTransitiveFiltering == true. Transitive filtering flag will be ignored." );
+ if (!dependencySet.isUseTransitiveDependencies() && dependencySet.isUseTransitiveFiltering()) {
+ LOGGER.warn("DependencySet has nonsensical configuration: useTransitiveDependencies == false "
+ + "AND useTransitiveFiltering == true. Transitive filtering flag will be ignored.");
}
- final Set<Artifact> dependencyArtifacts = resolveDependencyArtifacts( dependencySet );
+ final Set<Artifact> dependencyArtifacts = resolveDependencyArtifacts(dependencySet);
- if ( !unpackTransformsContent( dependencySet ) && dependencyArtifacts.size() > 1 )
- {
- checkMultiArtifactOutputConfig( dependencySet );
+ if (!unpackTransformsContent(dependencySet) && dependencyArtifacts.size() > 1) {
+ checkMultiArtifactOutputConfig(dependencySet);
}
- LOGGER.debug( "Adding " + dependencyArtifacts.size() + " dependency artifacts." );
+ LOGGER.debug("Adding " + dependencyArtifacts.size() + " dependency artifacts.");
UnpackOptions unpackOptions = dependencySet.getUnpackOptions();
- InputStreamTransformer fileSetTransformers = isUnpackWithOptions( dependencySet )
- ? ReaderFormatter.getFileSetTransformers( configSource,
- unpackOptions.isFiltered(),
- new HashSet<>( unpackOptions.getNonFilteredFileExtensions() ),
- unpackOptions.getLineEnding() )
- : null;
-
- for ( final Artifact depArtifact : dependencyArtifacts )
- {
- ProjectBuildingRequest pbr = getProjectBuildingRequest( configSource );
+ InputStreamTransformer fileSetTransformers = isUnpackWithOptions(dependencySet)
+ ? ReaderFormatter.getFileSetTransformers(
+ configSource,
+ unpackOptions.isFiltered(),
+ new HashSet<>(unpackOptions.getNonFilteredFileExtensions()),
+ unpackOptions.getLineEnding())
+ : null;
+
+ for (final Artifact depArtifact : dependencyArtifacts) {
+ ProjectBuildingRequest pbr = getProjectBuildingRequest(configSource);
MavenProject depProject;
- try
- {
- ProjectBuildingResult build = projectBuilder1.build( depArtifact, pbr );
+ try {
+ ProjectBuildingResult build = projectBuilder1.build(depArtifact, pbr);
depProject = build.getProject();
- }
- catch ( final ProjectBuildingException e )
- {
- LOGGER.debug(
- "Error retrieving POM of module-dependency: " + depArtifact.getId() + "; Reason: " + e.getMessage()
- + "\n\nBuilding stub project instance." );
+ } catch (final ProjectBuildingException e) {
+ LOGGER.debug("Error retrieving POM of module-dependency: " + depArtifact.getId() + "; Reason: "
+ + e.getMessage() + "\n\nBuilding stub project instance.");
- depProject = buildProjectStub( depArtifact );
+ depProject = buildProjectStub(depArtifact);
}
- if ( NON_ARCHIVE_DEPENDENCY_TYPES.contains( depArtifact.getType() ) )
- {
- addNonArchiveDependency( depArtifact, depProject, dependencySet, archiver, configSource );
- }
- else
- {
- addNormalArtifact( dependencySet, depArtifact, depProject, archiver, configSource,
- fileSetTransformers );
+ if (NON_ARCHIVE_DEPENDENCY_TYPES.contains(depArtifact.getType())) {
+ addNonArchiveDependency(depArtifact, depProject, dependencySet, archiver, configSource);
+ } else {
+ addNormalArtifact(dependencySet, depArtifact, depProject, archiver, configSource, fileSetTransformers);
}
}
}
- private ProjectBuildingRequest getProjectBuildingRequest( AssemblerConfigurationSource configSource )
- {
- return new DefaultProjectBuildingRequest( configSource.getMavenSession().getProjectBuildingRequest() )
- .setProcessPlugins( false );
+ private ProjectBuildingRequest getProjectBuildingRequest(AssemblerConfigurationSource configSource) {
+ return new DefaultProjectBuildingRequest(configSource.getMavenSession().getProjectBuildingRequest())
+ .setProcessPlugins(false);
}
- private boolean isUnpackWithOptions( DependencySet dependencySet )
- {
+ private boolean isUnpackWithOptions(DependencySet dependencySet) {
return dependencySet.isUnpack() && dependencySet.getUnpackOptions() != null;
}
- private boolean unpackTransformsContent( DependencySet dependencySet )
- {
- return isUnpackWithOptions( dependencySet ) && isContentModifyingOption( dependencySet.getUnpackOptions() );
+ private boolean unpackTransformsContent(DependencySet dependencySet) {
+ return isUnpackWithOptions(dependencySet) && isContentModifyingOption(dependencySet.getUnpackOptions());
}
- private boolean isContentModifyingOption( UnpackOptions opts )
- {
- return ( opts.isFiltered() || opts.getLineEnding() != null );
+ private boolean isContentModifyingOption(UnpackOptions opts) {
+ return (opts.isFiltered() || opts.getLineEnding() != null);
}
- private void checkMultiArtifactOutputConfig( final DependencySet dependencySet )
- {
+ private void checkMultiArtifactOutputConfig(final DependencySet dependencySet) {
String dir = dependencySet.getOutputDirectory();
- if ( dir == null )
- {
+ if (dir == null) {
dir = defaultOutputDirectory;
}
String mapping = dependencySet.getOutputFileNameMapping();
- if ( mapping == null )
- {
+ if (mapping == null) {
mapping = defaultOutputFileNameMapping;
}
- if ( ( dir == null || !dir.contains( "${" ) ) && ( mapping == null || !mapping.contains( "${" ) ) )
- {
- LOGGER.warn( "NOTE: Your assembly specifies a dependencySet that matches multiple artifacts, but "
- + "specifies a concrete output format. THIS MAY RESULT IN ONE OR MORE ARTIFACTS BEING "
- + "OBSCURED!\n\n" + "Output directory: '" + dir + "'\nOutput filename mapping: '" + mapping
- + "'" );
+ if ((dir == null || !dir.contains("${")) && (mapping == null || !mapping.contains("${"))) {
+ LOGGER.warn("NOTE: Your assembly specifies a dependencySet that matches multiple artifacts, but "
+ + "specifies a concrete output format. THIS MAY RESULT IN ONE OR MORE ARTIFACTS BEING "
+ + "OBSCURED!\n\n" + "Output directory: '" + dir + "'\nOutput filename mapping: '" + mapping
+ + "'");
}
}
- private void addNormalArtifact( final DependencySet dependencySet, final Artifact depArtifact,
- final MavenProject depProject, final Archiver archiver,
- final AssemblerConfigurationSource configSource,
- InputStreamTransformer fileSetTransformers )
- throws AssemblyFormattingException, ArchiveCreationException
- {
- LOGGER.debug( "Adding dependency artifact " + depArtifact.getId() + "." );
-
- String encoding = isUnpackWithOptions( dependencySet ) ? dependencySet.getUnpackOptions().getEncoding() : null;
- Charset charset = encoding != null ? Charset.forName( encoding ) : null;
- final AddArtifactTask task = new AddArtifactTask( depArtifact, fileSetTransformers, charset );
-
- task.setProject( depProject );
- task.setModuleProject( moduleProject );
- task.setModuleArtifact( moduleArtifact );
- task.setOutputDirectory( dependencySet.getOutputDirectory(), defaultOutputDirectory );
- task.setFileNameMapping( dependencySet.getOutputFileNameMapping(), defaultOutputFileNameMapping );
-
- final int dirMode = TypeConversionUtils.modeToInt( dependencySet.getDirectoryMode(), LOGGER );
- if ( dirMode != -1 )
- {
- task.setDirectoryMode( dirMode );
+ private void addNormalArtifact(
+ final DependencySet dependencySet,
+ final Artifact depArtifact,
+ final MavenProject depProject,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource,
+ InputStreamTransformer fileSetTransformers)
+ throws AssemblyFormattingException, ArchiveCreationException {
+ LOGGER.debug("Adding dependency artifact " + depArtifact.getId() + ".");
+
+ String encoding = isUnpackWithOptions(dependencySet)
+ ? dependencySet.getUnpackOptions().getEncoding()
+ : null;
+ Charset charset = encoding != null ? Charset.forName(encoding) : null;
+ final AddArtifactTask task = new AddArtifactTask(depArtifact, fileSetTransformers, charset);
+
+ task.setProject(depProject);
+ task.setModuleProject(moduleProject);
+ task.setModuleArtifact(moduleArtifact);
+ task.setOutputDirectory(dependencySet.getOutputDirectory(), defaultOutputDirectory);
+ task.setFileNameMapping(dependencySet.getOutputFileNameMapping(), defaultOutputFileNameMapping);
+
+ final int dirMode = TypeConversionUtils.modeToInt(dependencySet.getDirectoryMode(), LOGGER);
+ if (dirMode != -1) {
+ task.setDirectoryMode(dirMode);
}
- final int fileMode = TypeConversionUtils.modeToInt( dependencySet.getFileMode(), LOGGER );
- if ( fileMode != -1 )
- {
- task.setFileMode( fileMode );
+ final int fileMode = TypeConversionUtils.modeToInt(dependencySet.getFileMode(), LOGGER);
+ if (fileMode != -1) {
+ task.setFileMode(fileMode);
}
- task.setUnpack( dependencySet.isUnpack() );
+ task.setUnpack(dependencySet.isUnpack());
final UnpackOptions opts = dependencySet.getUnpackOptions();
- if ( isUnpackWithOptions( dependencySet ) )
- {
- task.setIncludes( opts.getIncludes() );
- task.setExcludes( opts.getExcludes() );
- task.setUsingDefaultExcludes( opts.isUseDefaultExcludes() );
+ if (isUnpackWithOptions(dependencySet)) {
+ task.setIncludes(opts.getIncludes());
+ task.setExcludes(opts.getExcludes());
+ task.setUsingDefaultExcludes(opts.isUseDefaultExcludes());
}
- task.execute( archiver, configSource );
-
+ task.execute(archiver, configSource);
}
- private MavenProject buildProjectStub( final Artifact depArtifact )
- {
+ private MavenProject buildProjectStub(final Artifact depArtifact) {
final Model model = new Model();
- model.setGroupId( depArtifact.getGroupId() );
- model.setArtifactId( depArtifact.getArtifactId() );
- model.setVersion( depArtifact.getBaseVersion() );
- model.setPackaging( depArtifact.getType() );
+ model.setGroupId(depArtifact.getGroupId());
+ model.setArtifactId(depArtifact.getArtifactId());
+ model.setVersion(depArtifact.getBaseVersion());
+ model.setPackaging(depArtifact.getType());
- model.setDescription( "Stub for " + depArtifact.getId() );
+ model.setDescription("Stub for " + depArtifact.getId());
- final MavenProject project = new MavenProject( model );
- project.setArtifact( depArtifact );
+ final MavenProject project = new MavenProject(model);
+ project.setArtifact(depArtifact);
return project;
}
- Set<Artifact> resolveDependencyArtifacts( final DependencySet dependencySet )
- throws InvalidAssemblerConfigurationException
- {
+ Set<Artifact> resolveDependencyArtifacts(final DependencySet dependencySet)
+ throws InvalidAssemblerConfigurationException {
final Set<Artifact> dependencyArtifacts = new LinkedHashSet<>();
- if ( resolvedArtifacts != null )
- {
- dependencyArtifacts.addAll( resolvedArtifacts );
+ if (resolvedArtifacts != null) {
+ dependencyArtifacts.addAll(resolvedArtifacts);
}
- if ( dependencySet.isUseProjectArtifact() )
- {
+ if (dependencySet.isUseProjectArtifact()) {
final Artifact projectArtifact = project.getArtifact();
- if ( ( projectArtifact != null ) && ( projectArtifact.getFile() != null ) )
- {
- dependencyArtifacts.add( projectArtifact );
- }
- else
- {
- LOGGER.warn( "Cannot include project artifact: " + projectArtifact
- + "; it doesn't have an associated file or directory." );
+ if ((projectArtifact != null) && (projectArtifact.getFile() != null)) {
+ dependencyArtifacts.add(projectArtifact);
+ } else {
+ LOGGER.warn("Cannot include project artifact: " + projectArtifact
+ + "; it doesn't have an associated file or directory.");
}
}
- if ( dependencySet.isUseProjectAttachments() )
- {
+ if (dependencySet.isUseProjectAttachments()) {
final List<Artifact> attachments = project.getAttachedArtifacts();
- if ( attachments != null )
- {
- for ( final Artifact attachment : attachments )
- {
- if ( attachment.getFile() != null )
- {
- dependencyArtifacts.add( attachment );
- }
- else
- {
- LOGGER.warn(
- "Cannot include attached artifact: " + project.getId() + " for project: " + project.getId()
- + "; it doesn't have an associated file or directory." );
+ if (attachments != null) {
+ for (final Artifact attachment : attachments) {
+ if (attachment.getFile() != null) {
+ dependencyArtifacts.add(attachment);
+ } else {
+ LOGGER.warn("Cannot include attached artifact: " + project.getId() + " for project: "
+ + project.getId() + "; it doesn't have an associated file or directory.");
}
}
}
}
- if ( dependencySet.isUseTransitiveFiltering() )
- {
- LOGGER.debug( "Filtering dependency artifacts USING transitive dependency path information." );
- }
- else
- {
- LOGGER.debug( "Filtering dependency artifacts WITHOUT transitive dependency path information." );
+ if (dependencySet.isUseTransitiveFiltering()) {
+ LOGGER.debug("Filtering dependency artifacts USING transitive dependency path information.");
+ } else {
+ LOGGER.debug("Filtering dependency artifacts WITHOUT transitive dependency path information.");
}
- final ScopeFilter scopeFilter = FilterUtils.newScopeFilter( dependencySet.getScope() );
+ final ScopeFilter scopeFilter = FilterUtils.newScopeFilter(dependencySet.getScope());
- final ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform( scopeFilter );
-
- FilterUtils.filterArtifacts( dependencyArtifacts, dependencySet.getIncludes(), dependencySet.getExcludes(),
- dependencySet.isUseStrictFiltering(), dependencySet.isUseTransitiveFiltering(),
- LOGGER, filter );
+ final ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform(scopeFilter);
+
+ FilterUtils.filterArtifacts(
+ dependencyArtifacts,
+ dependencySet.getIncludes(),
+ dependencySet.getExcludes(),
+ dependencySet.isUseStrictFiltering(),
+ dependencySet.isUseTransitiveFiltering(),
+ LOGGER,
+ filter);
return dependencyArtifacts;
}
- private void addNonArchiveDependency( final Artifact depArtifact, final MavenProject depProject,
- final DependencySet dependencySet, final Archiver archiver,
- final AssemblerConfigurationSource configSource )
- throws AssemblyFormattingException, ArchiveCreationException
- {
+ private void addNonArchiveDependency(
+ final Artifact depArtifact,
+ final MavenProject depProject,
+ final DependencySet dependencySet,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource)
+ throws AssemblyFormattingException, ArchiveCreationException {
final File source = depArtifact.getFile();
String outputDirectory = dependencySet.getOutputDirectory();
FixedStringSearchInterpolator moduleProjectInterpolator =
- AssemblyFormatUtils.moduleProjectInterpolator( moduleProject );
+ AssemblyFormatUtils.moduleProjectInterpolator(moduleProject);
FixedStringSearchInterpolator artifactProjectInterpolator =
- AssemblyFormatUtils.artifactProjectInterpolator( depProject );
- outputDirectory =
- AssemblyFormatUtils.getOutputDirectory( outputDirectory, depProject.getBuild().getFinalName(), configSource,
- moduleProjectInterpolator, artifactProjectInterpolator );
-
- final String destName =
- AssemblyFormatUtils.evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), depArtifact,
- configSource.getProject(), moduleArtifact, configSource,
- moduleProjectInterpolator, artifactProjectInterpolator );
+ AssemblyFormatUtils.artifactProjectInterpolator(depProject);
+ outputDirectory = AssemblyFormatUtils.getOutputDirectory(
+ outputDirectory,
+ depProject.getBuild().getFinalName(),
+ configSource,
+ moduleProjectInterpolator,
+ artifactProjectInterpolator);
+
+ final String destName = AssemblyFormatUtils.evaluateFileNameMapping(
+ dependencySet.getOutputFileNameMapping(),
+ depArtifact,
+ configSource.getProject(),
+ moduleArtifact,
+ configSource,
+ moduleProjectInterpolator,
+ artifactProjectInterpolator);
String target;
// omit the last char if ends with / or \\
- if ( outputDirectory.endsWith( "/" ) || outputDirectory.endsWith( "\\" ) )
- {
+ if (outputDirectory.endsWith("/") || outputDirectory.endsWith("\\")) {
target = outputDirectory + destName;
- }
- else
- {
+ } else {
target = outputDirectory + "/" + destName;
}
- try
- {
- final int mode = TypeConversionUtils.modeToInt( dependencySet.getFileMode(), LOGGER );
- if ( mode > -1 )
- {
- archiver.addFile( source, target, mode );
- }
- else
- {
- archiver.addFile( source, target );
+ try {
+ final int mode = TypeConversionUtils.modeToInt(dependencySet.getFileMode(), LOGGER);
+ if (mode > -1) {
+ archiver.addFile(source, target, mode);
+ } else {
+ archiver.addFile(source, target);
}
- }
- catch ( final ArchiverException e )
- {
- throw new ArchiveCreationException( "Error adding file to archive: " + e.getMessage(), e );
+ } catch (final ArchiverException e) {
+ throw new ArchiveCreationException("Error adding file to archive: " + e.getMessage(), e);
}
}
- public List<DependencySet> getDependencySets()
- {
+ public List<DependencySet> getDependencySets() {
return dependencySets;
}
- public void setDefaultOutputDirectory( final String defaultOutputDirectory )
- {
+ public void setDefaultOutputDirectory(final String defaultOutputDirectory) {
this.defaultOutputDirectory = defaultOutputDirectory;
}
- public void setDefaultOutputFileNameMapping( final String defaultOutputFileNameMapping )
- {
+ public void setDefaultOutputFileNameMapping(final String defaultOutputFileNameMapping) {
this.defaultOutputFileNameMapping = defaultOutputFileNameMapping;
}
- public void setModuleProject( final MavenProject moduleProject )
- {
+ public void setModuleProject(final MavenProject moduleProject) {
this.moduleProject = moduleProject;
}
- public void setModuleArtifact( final Artifact moduleArtifact )
- {
+ public void setModuleArtifact(final Artifact moduleArtifact) {
this.moduleArtifact = moduleArtifact;
}
}
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 591b5006..2ecdbf6d 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.task;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,11 @@ package org.apache.maven.plugins.assembly.archive.task;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.task;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
import org.apache.maven.plugins.assembly.utils.AssemblyFormatUtils;
@@ -26,15 +29,10 @@ import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.util.DefaultFileSet;
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
/**
*
*/
-public class AddDirectoryTask
-{
+public class AddDirectoryTask {
private final File directory;
@@ -52,30 +50,22 @@ public class AddDirectoryTask
private int fileMode = -1;
- public AddDirectoryTask( final File directory, InputStreamTransformer transformers )
- {
+ public AddDirectoryTask(final File directory, InputStreamTransformer transformers) {
this.directory = directory;
this.transformer = transformers;
}
- public AddDirectoryTask( final File directory )
- {
- this( directory, null );
+ public AddDirectoryTask(final File directory) {
+ this(directory, null);
}
- public void execute( final Archiver archiver )
- throws ArchiveCreationException
- {
- if ( ".".equals( outputDirectory ) )
- {
+ public void execute(final Archiver archiver) throws ArchiveCreationException {
+ if (".".equals(outputDirectory)) {
outputDirectory = "";
- }
- else if ( "..".equals( outputDirectory ) )
- {
- throw new ArchiveCreationException(
- "Cannot add source directory: " + directory + " to archive-path: " + outputDirectory
- + ". All paths must be within the archive root directory." );
+ } else if ("..".equals(outputDirectory)) {
+ throw new ArchiveCreationException("Cannot add source directory: " + directory + " to archive-path: "
+ + outputDirectory + ". All paths must be within the archive root directory.");
}
final int oldDirMode = archiver.getOverrideDirectoryMode();
@@ -84,43 +74,33 @@ public class AddDirectoryTask
boolean fileModeSet = false;
boolean dirModeSet = false;
- try
- {
- if ( directoryMode != -1 )
- {
- archiver.setDirectoryMode( directoryMode );
+ try {
+ if (directoryMode != -1) {
+ archiver.setDirectoryMode(directoryMode);
dirModeSet = true;
}
- if ( fileMode != -1 )
- {
- archiver.setFileMode( fileMode );
+ if (fileMode != -1) {
+ archiver.setFileMode(fileMode);
fileModeSet = true;
}
- if ( directory.exists() )
- {
+ if (directory.exists()) {
List<String> directoryExcludes;
- if ( excludes != null && !excludes.isEmpty() )
- {
- directoryExcludes = new ArrayList<>( excludes );
- }
- else
- {
+ if (excludes != null && !excludes.isEmpty()) {
+ directoryExcludes = new ArrayList<>(excludes);
+ } else {
directoryExcludes = new ArrayList<>();
}
- try
- {
+ try {
String[] includesArray = null;
- if ( includes != null && !includes.isEmpty() )
- {
+ if (includes != null && !includes.isEmpty()) {
includesArray = new String[includes.size()];
int i = 0;
- for ( String include : includes )
- {
- includesArray[i++] = normalize( include );
+ for (String include : includes) {
+ includesArray[i++] = normalize(include);
}
}
@@ -128,83 +108,66 @@ public class AddDirectoryTask
final String[] excludesArray = new String[directoryExcludes.size()];
int i = 0;
- for ( String directoryExclude : directoryExcludes )
- {
- excludesArray[i++] = normalize( directoryExclude );
+ for (String directoryExclude : directoryExcludes) {
+ excludesArray[i++] = normalize(directoryExclude);
}
final DefaultFileSet fs = new DefaultFileSet();
- fs.setUsingDefaultExcludes( useDefaultExcludes );
- fs.setPrefix( outputDirectory );
- fs.setDirectory( directory );
- fs.setIncludes( includesArray );
- fs.setExcludes( excludesArray );
- if ( transformer != null )
- {
- fs.setStreamTransformer( transformer );
+ fs.setUsingDefaultExcludes(useDefaultExcludes);
+ fs.setPrefix(outputDirectory);
+ fs.setDirectory(directory);
+ fs.setIncludes(includesArray);
+ fs.setExcludes(excludesArray);
+ if (transformer != null) {
+ fs.setStreamTransformer(transformer);
}
- archiver.addFileSet( fs );
- }
- catch ( final ArchiverException e )
- {
- throw new ArchiveCreationException( "Error adding directory to archive: " + e.getMessage(), e );
+ archiver.addFileSet(fs);
+ } catch (final ArchiverException e) {
+ throw new ArchiveCreationException("Error adding directory to archive: " + e.getMessage(), e);
}
}
- }
- finally
- {
- if ( dirModeSet )
- {
- archiver.setDirectoryMode( oldDirMode );
+ } finally {
+ if (dirModeSet) {
+ archiver.setDirectoryMode(oldDirMode);
}
- if ( fileModeSet )
- {
- archiver.setFileMode( oldFileMode );
+ if (fileModeSet) {
+ archiver.setFileMode(oldFileMode);
}
}
}
- private String normalize( String include )
- {
- String value = AssemblyFormatUtils.fixRelativeRefs( include );
+ private String normalize(String include) {
+ String value = AssemblyFormatUtils.fixRelativeRefs(include);
- if ( value.startsWith( "/" ) || value.startsWith( "\\" ) )
- {
- value = value.substring( 1 );
+ if (value.startsWith("/") || value.startsWith("\\")) {
+ value = value.substring(1);
}
return value;
}
- public void setExcludes( final List<String> excludes )
- {
+ public void setExcludes(final List<String> excludes) {
this.excludes = excludes;
}
- public void setIncludes( final List<String> includes )
- {
+ public void setIncludes(final List<String> includes) {
this.includes = includes;
}
- public void setOutputDirectory( final String outputDirectory )
- {
+ public void setOutputDirectory(final String outputDirectory) {
this.outputDirectory = outputDirectory;
}
- public void setDirectoryMode( final int directoryMode )
- {
+ public void setDirectoryMode(final int directoryMode) {
this.directoryMode = directoryMode;
}
- public void setFileMode( final int fileMode )
- {
+ public void setFileMode(final int fileMode) {
this.fileMode = fileMode;
}
- public void setUseDefaultExcludes( final boolean useDefaultExcludes )
- {
+ public void setUseDefaultExcludes(final boolean useDefaultExcludes) {
this.useDefaultExcludes = useDefaultExcludes;
}
-
}
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 9c5db1c3..8cf6a766 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.task;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.archive.task;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.task;
import java.io.File;
import java.util.ArrayList;
@@ -42,9 +41,8 @@ import org.slf4j.LoggerFactory;
/**
*
*/
-public class AddFileSetsTask
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( AddFileSetsTask.class );
+public class AddFileSetsTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AddFileSetsTask.class);
private final List<FileSet> fileSets;
@@ -52,19 +50,16 @@ public class AddFileSetsTask
private MavenProject moduleProject;
- public AddFileSetsTask( final List<FileSet> fileSets )
- {
+ public AddFileSetsTask(final List<FileSet> fileSets) {
this.fileSets = fileSets;
}
- public AddFileSetsTask( final FileSet... fileSets )
- {
- this.fileSets = new ArrayList<>( Arrays.asList( fileSets ) );
+ public AddFileSetsTask(final FileSet... fileSets) {
+ this.fileSets = new ArrayList<>(Arrays.asList(fileSets));
}
- public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException
- {
+ public void execute(final Archiver archiver, final AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException {
// don't need this check here. it's more efficient here, but the logger is not actually
// used until addFileSet(..)...and the check should be there in case someone extends the
// class.
@@ -72,32 +67,28 @@ public class AddFileSetsTask
final File archiveBaseDir = configSource.getArchiveBaseDirectory();
- if ( archiveBaseDir != null )
- {
- if ( !archiveBaseDir.exists() )
- {
+ if (archiveBaseDir != null) {
+ if (!archiveBaseDir.exists()) {
throw new ArchiveCreationException(
- "The archive base directory '" + archiveBaseDir.getAbsolutePath() + "' does not exist" );
- }
- else if ( !archiveBaseDir.isDirectory() )
- {
- throw new ArchiveCreationException( "The archive base directory '" + archiveBaseDir.getAbsolutePath()
- + "' exists, but it is not a directory" );
+ "The archive base directory '" + archiveBaseDir.getAbsolutePath() + "' does not exist");
+ } else if (!archiveBaseDir.isDirectory()) {
+ throw new ArchiveCreationException("The archive base directory '" + archiveBaseDir.getAbsolutePath()
+ + "' exists, but it is not a directory");
}
}
- for ( final FileSet fileSet : fileSets )
- {
- addFileSet( fileSet, archiver, configSource, archiveBaseDir );
+ for (final FileSet fileSet : fileSets) {
+ addFileSet(fileSet, archiver, configSource, archiveBaseDir);
}
}
- void addFileSet( final FileSet fileSet, final Archiver archiver, final AssemblerConfigurationSource configSource,
- final File archiveBaseDir )
- throws AssemblyFormattingException, ArchiveCreationException
- {
- if ( project == null )
- {
+ void addFileSet(
+ final FileSet fileSet,
+ final Archiver archiver,
+ final AssemblerConfigurationSource configSource,
+ final File archiveBaseDir)
+ throws AssemblyFormattingException, ArchiveCreationException {
+ if (project == null) {
project = configSource.getProject();
}
@@ -105,115 +96,99 @@ public class AddFileSetsTask
String destDirectory = fileSet.getOutputDirectory();
- if ( destDirectory == null )
- {
+ if (destDirectory == null) {
destDirectory = fileSet.getDirectory();
- AssemblyFormatUtils.warnForPlatformSpecifics( LOGGER, destDirectory );
+ AssemblyFormatUtils.warnForPlatformSpecifics(LOGGER, destDirectory);
}
-
- destDirectory =
- AssemblyFormatUtils.getOutputDirectory( destDirectory, configSource.getFinalName(), configSource,
- AssemblyFormatUtils.moduleProjectInterpolator( moduleProject ),
- AssemblyFormatUtils.artifactProjectInterpolator( project ) );
-
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( "FileSet[" + destDirectory + "]" + " dir perms: " + Integer.toString(
- archiver.getOverrideDirectoryMode(), 8 ) + " file perms: " + Integer.toString(
- archiver.getOverrideFileMode(), 8 ) + ( fileSet.getLineEnding() == null
- ? ""
- : " lineEndings: " + fileSet.getLineEnding() ) );
+ destDirectory = AssemblyFormatUtils.getOutputDirectory(
+ destDirectory,
+ configSource.getFinalName(),
+ configSource,
+ AssemblyFormatUtils.moduleProjectInterpolator(moduleProject),
+ AssemblyFormatUtils.artifactProjectInterpolator(project));
+
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("FileSet[" + destDirectory + "]" + " dir perms: "
+ + Integer.toString(archiver.getOverrideDirectoryMode(), 8) + " file perms: "
+ + Integer.toString(archiver.getOverrideFileMode(), 8)
+ + (fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding()));
}
- LOGGER.debug( "The archive base directory is '" + archiveBaseDir + "'" );
+ LOGGER.debug("The archive base directory is '" + archiveBaseDir + "'");
- File fileSetDir = getFileSetDirectory( fileSet, basedir, archiveBaseDir );
+ File fileSetDir = getFileSetDirectory(fileSet, basedir, archiveBaseDir);
- if ( fileSetDir.exists() )
- {
- InputStreamTransformer fileSetTransformers =
- ReaderFormatter.getFileSetTransformers( configSource,
- fileSet.isFiltered(),
- new HashSet<>( fileSet.getNonFilteredFileExtensions() ),
- fileSet.getLineEnding() );
- if ( fileSetTransformers == null )
- {
- LOGGER.debug( "NOT reformatting any files in " + fileSetDir );
+ if (fileSetDir.exists()) {
+ InputStreamTransformer fileSetTransformers = ReaderFormatter.getFileSetTransformers(
+ configSource,
+ fileSet.isFiltered(),
+ new HashSet<>(fileSet.getNonFilteredFileExtensions()),
+ fileSet.getLineEnding());
+ if (fileSetTransformers == null) {
+ LOGGER.debug("NOT reformatting any files in " + fileSetDir);
}
- if ( fileSetDir.getPath().equals( File.separator ) )
- {
+ if (fileSetDir.getPath().equals(File.separator)) {
throw new AssemblyFormattingException(
- "Your assembly descriptor specifies a directory of " + File.separator
- + ", which is your *entire* file system.\nThese are not the files you are looking for" );
+ "Your assembly descriptor specifies a directory of " + File.separator
+ + ", which is your *entire* file system.\nThese are not the files you are looking for");
}
- final AddDirectoryTask task = new AddDirectoryTask( fileSetDir, fileSetTransformers );
+ final AddDirectoryTask task = new AddDirectoryTask(fileSetDir, fileSetTransformers);
- final int dirMode = TypeConversionUtils.modeToInt( fileSet.getDirectoryMode(), LOGGER );
- if ( dirMode != -1 )
- {
- task.setDirectoryMode( dirMode );
+ final int dirMode = TypeConversionUtils.modeToInt(fileSet.getDirectoryMode(), LOGGER);
+ if (dirMode != -1) {
+ task.setDirectoryMode(dirMode);
}
- final int fileMode = TypeConversionUtils.modeToInt( fileSet.getFileMode(), LOGGER );
- if ( fileMode != -1 )
- {
- task.setFileMode( fileMode );
+ final int fileMode = TypeConversionUtils.modeToInt(fileSet.getFileMode(), LOGGER);
+ if (fileMode != -1) {
+ task.setFileMode(fileMode);
}
- task.setUseDefaultExcludes( fileSet.isUseDefaultExcludes() );
- task.setExcludes( fileSet.getExcludes() );
- task.setIncludes( fileSet.getIncludes() );
- task.setOutputDirectory( destDirectory );
+ task.setUseDefaultExcludes(fileSet.isUseDefaultExcludes());
+ task.setExcludes(fileSet.getExcludes());
+ task.setIncludes(fileSet.getIncludes());
+ task.setOutputDirectory(destDirectory);
- task.execute( archiver );
+ task.execute(archiver);
}
}
- File getFileSetDirectory( final FileSet fileSet, final File basedir, final File archiveBaseDir )
- throws ArchiveCreationException, AssemblyFormattingException
- {
+ File getFileSetDirectory(final FileSet fileSet, final File basedir, final File archiveBaseDir)
+ throws ArchiveCreationException, AssemblyFormattingException {
String sourceDirectory = fileSet.getDirectory();
- if ( sourceDirectory == null || sourceDirectory.trim().length() < 1 )
- {
+ if (sourceDirectory == null || sourceDirectory.trim().length() < 1) {
sourceDirectory = basedir.getAbsolutePath();
}
File fileSetDir;
- if ( archiveBaseDir == null )
- {
- fileSetDir = new File( sourceDirectory );
+ if (archiveBaseDir == null) {
+ fileSetDir = new File(sourceDirectory);
// If the file is not absolute then it's a subpath of the current project basedir
// For OS compatibility we also must treat any path starting with "/" as absolute
// as File#isAbsolute() returns false for /absolutePath under Windows :(
// Note that in Windows an absolute path with / will be on the 'current drive'.
// But I think we can live with this.
- if ( ! AssemblyFileUtils.isAbsolutePath( fileSetDir ) )
- {
- fileSetDir = new File( basedir, sourceDirectory );
+ if (!AssemblyFileUtils.isAbsolutePath(fileSetDir)) {
+ fileSetDir = new File(basedir, sourceDirectory);
}
- }
- else
- {
- fileSetDir = new File( archiveBaseDir, sourceDirectory );
+ } else {
+ fileSetDir = new File(archiveBaseDir, sourceDirectory);
}
return fileSetDir;
}
- public void setProject( final MavenProject project )
- {
+ public void setProject(final MavenProject project) {
this.project = project;
}
- public void setModuleProject( final MavenProject moduleProject )
- {
+ public void setModuleProject(final MavenProject moduleProject) {
this.moduleProject = moduleProject;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/ArchiverTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/ArchiverTask.java
index 81663343..4777d885 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/ArchiverTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/ArchiverTask.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.archive.task;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.archive.task;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.archive.task;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
@@ -28,10 +27,8 @@ import org.codehaus.plexus.archiver.Archiver;
/**
*
*/
-public interface ArchiverTask
-{
-
- void execute( Archiver archiver, AssemblerConfigurationSource configSource )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException;
+public interface ArchiverTask {
+ void execute(Archiver archiver, AssemblerConfigurationSource configSource)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException;
}
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 1cec0b21..9081af35 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.artifact;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.artifact;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.artifact;
import javax.inject.Inject;
import javax.inject.Named;
@@ -52,136 +51,121 @@ import static java.util.Objects.requireNonNull;
*/
@Singleton
@Named
-public class DefaultDependencyResolver implements DependencyResolver
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultDependencyResolver.class );
+public class DefaultDependencyResolver implements DependencyResolver {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDependencyResolver.class);
private final ArtifactHandlerManager artifactHandlerManager;
@Inject
- public DefaultDependencyResolver( ArtifactHandlerManager artifactHandlerManager )
- {
- this.artifactHandlerManager = requireNonNull( artifactHandlerManager );
+ public DefaultDependencyResolver(ArtifactHandlerManager artifactHandlerManager) {
+ this.artifactHandlerManager = requireNonNull(artifactHandlerManager);
}
@Override
- public Map<DependencySet, Set<Artifact>> resolveDependencySets( final Assembly assembly, ModuleSet moduleSet,
- final AssemblerConfigurationSource configSource,
- List<DependencySet> dependencySets )
- throws DependencyResolutionException
- {
+ public Map<DependencySet, Set<Artifact>> resolveDependencySets(
+ final Assembly assembly,
+ ModuleSet moduleSet,
+ final AssemblerConfigurationSource configSource,
+ List<DependencySet> dependencySets)
+ throws DependencyResolutionException {
Map<DependencySet, Set<Artifact>> result = new LinkedHashMap<>();
- for ( DependencySet dependencySet : dependencySets )
- {
+ for (DependencySet dependencySet : dependencySets) {
final MavenProject currentProject = configSource.getProject();
final ResolutionManagementInfo info = new ResolutionManagementInfo();
- updateDependencySetResolutionRequirements( dependencySet, info, currentProject );
- updateModuleSetResolutionRequirements( moduleSet, dependencySet, info, configSource );
-
- result.put( dependencySet, info.getArtifacts() );
+ updateDependencySetResolutionRequirements(dependencySet, info, currentProject);
+ updateModuleSetResolutionRequirements(moduleSet, dependencySet, info, configSource);
+ result.put(dependencySet, info.getArtifacts());
}
return result;
}
@Override
- public Map<DependencySet, Set<Artifact>> resolveDependencySets( final Assembly assembly,
- final AssemblerConfigurationSource configSource,
- List<DependencySet> dependencySets )
- throws DependencyResolutionException
- {
+ public Map<DependencySet, Set<Artifact>> resolveDependencySets(
+ final Assembly assembly,
+ final AssemblerConfigurationSource configSource,
+ List<DependencySet> dependencySets)
+ throws DependencyResolutionException {
Map<DependencySet, Set<Artifact>> result = new LinkedHashMap<>();
- for ( DependencySet dependencySet : dependencySets )
- {
+ for (DependencySet dependencySet : dependencySets) {
final MavenProject currentProject = configSource.getProject();
final ResolutionManagementInfo info = new ResolutionManagementInfo();
- updateDependencySetResolutionRequirements( dependencySet, info, currentProject );
-
- result.put( dependencySet, info.getArtifacts() );
+ updateDependencySetResolutionRequirements(dependencySet, info, currentProject);
+ result.put(dependencySet, info.getArtifacts());
}
return result;
}
- void updateModuleSetResolutionRequirements( ModuleSet set, DependencySet dependencySet,
- final ResolutionManagementInfo requirements,
- final AssemblerConfigurationSource configSource )
- throws DependencyResolutionException
- {
+ void updateModuleSetResolutionRequirements(
+ ModuleSet set,
+ DependencySet dependencySet,
+ final ResolutionManagementInfo requirements,
+ final AssemblerConfigurationSource configSource)
+ throws DependencyResolutionException {
final ModuleBinaries binaries = set.getBinaries();
- if ( binaries != null )
- {
+ if (binaries != null) {
Set<MavenProject> projects;
- try
- {
- projects = ModuleSetAssemblyPhase.getModuleProjects( set, configSource, LOGGER );
- }
- catch ( final ArchiveCreationException e )
- {
- throw new DependencyResolutionException( "Error determining project-set for moduleSet with binaries.",
- e );
+ try {
+ projects = ModuleSetAssemblyPhase.getModuleProjects(set, configSource, LOGGER);
+ } catch (final ArchiveCreationException e) {
+ throw new DependencyResolutionException(
+ "Error determining project-set for moduleSet with binaries.", e);
}
- for ( final MavenProject p : projects )
- {
- if ( p.getArtifact() == null )
- {
- p.setArtifact( createArtifact( p.getGroupId(), p.getArtifactId(),
- p.getVersion(), p.getPackaging() ) );
+ for (final MavenProject p : projects) {
+ if (p.getArtifact() == null) {
+ p.setArtifact(createArtifact(p.getGroupId(), p.getArtifactId(), p.getVersion(), p.getPackaging()));
}
}
- if ( binaries.isIncludeDependencies() )
- {
- updateDependencySetResolutionRequirements( dependencySet, requirements,
- projects.toArray( new MavenProject[0] ) );
+ if (binaries.isIncludeDependencies()) {
+ updateDependencySetResolutionRequirements(
+ dependencySet, requirements, projects.toArray(new MavenProject[0]));
}
}
}
- private Artifact createArtifact( String groupId, String artifactId, String version, String type )
- {
+ private Artifact createArtifact(String groupId, String artifactId, String version, String type) {
VersionRange versionRange = null;
- if ( version != null )
- {
- versionRange = VersionRange.createFromVersion( version );
+ if (version != null) {
+ versionRange = VersionRange.createFromVersion(version);
}
- return new DefaultArtifact( groupId, artifactId, versionRange, null, type, null,
- artifactHandlerManager.getArtifactHandler( type ), false );
+ return new DefaultArtifact(
+ groupId,
+ artifactId,
+ versionRange,
+ null,
+ type,
+ null,
+ artifactHandlerManager.getArtifactHandler(type),
+ false);
}
- void updateDependencySetResolutionRequirements( final DependencySet set,
- final ResolutionManagementInfo requirements,
- final MavenProject... projects )
- throws DependencyResolutionException
- {
- for ( final MavenProject project : projects )
- {
- if ( project == null )
- {
+ void updateDependencySetResolutionRequirements(
+ final DependencySet set, final ResolutionManagementInfo requirements, final MavenProject... projects)
+ throws DependencyResolutionException {
+ for (final MavenProject project : projects) {
+ if (project == null) {
continue;
}
Set<Artifact> dependencyArtifacts = null;
- if ( set.isUseTransitiveDependencies() )
- {
+ if (set.isUseTransitiveDependencies()) {
dependencyArtifacts = project.getArtifacts();
- }
- else
- {
+ } else {
dependencyArtifacts = project.getDependencyArtifacts();
}
- requirements.addArtifacts( dependencyArtifacts );
- LOGGER.debug( "Dependencies for project: " + project.getId() + " are:\n" + StringUtils.join(
- dependencyArtifacts.iterator(), "\n" ) );
+ requirements.addArtifacts(dependencyArtifacts);
+ LOGGER.debug("Dependencies for project: " + project.getId() + " are:\n"
+ + StringUtils.join(dependencyArtifacts.iterator(), "\n"));
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolutionException.java b/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolutionException.java
index 3de98b7c..f03c0988 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolutionException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolutionException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.artifact;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,19 +16,16 @@ package org.apache.maven.plugins.assembly.artifact;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.artifact;
/**
*
*/
-public class DependencyResolutionException
- extends Exception
-{
+public class DependencyResolutionException extends Exception {
private static final long serialVersionUID = 1L;
- public DependencyResolutionException( final String message, final Throwable error )
- {
- super( message, error );
+ public DependencyResolutionException(final String message, final Throwable error) {
+ super(message, error);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolver.java b/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolver.java
index d4d9beaf..7db1079c 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/artifact/DependencyResolver.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.artifact;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,11 @@ package org.apache.maven.plugins.assembly.artifact;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.artifact;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
@@ -25,27 +28,22 @@ import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.model.DependencySet;
import org.apache.maven.plugins.assembly.model.ModuleSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* Convenience component that aids in the resolution of dependency artifacts, according to various configurations such
* as transitivity flag and scope.
*
*
*/
-public interface DependencyResolver
-{
-
- Map<DependencySet, Set<Artifact>> resolveDependencySets( final Assembly assembly, ModuleSet moduleSet,
- final AssemblerConfigurationSource configSource,
- List<DependencySet> dependencySets )
- throws DependencyResolutionException;
+public interface DependencyResolver {
- Map<DependencySet, Set<Artifact>> resolveDependencySets( final Assembly assembly,
- final AssemblerConfigurationSource configSource,
- List<DependencySet> dependencySets )
- throws DependencyResolutionException;
+ Map<DependencySet, Set<Artifact>> resolveDependencySets(
+ Assembly assembly,
+ ModuleSet moduleSet,
+ AssemblerConfigurationSource configSource,
+ List<DependencySet> dependencySets)
+ throws DependencyResolutionException;
+ Map<DependencySet, Set<Artifact>> resolveDependencySets(
+ Assembly assembly, AssemblerConfigurationSource configSource, List<DependencySet> dependencySets)
+ throws DependencyResolutionException;
}
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 a66c4ac8..afb83960 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.artifact;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,80 +16,61 @@ package org.apache.maven.plugins.assembly.artifact;
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.artifact.Artifact;
+package org.apache.maven.plugins.assembly.artifact;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.apache.maven.artifact.Artifact;
+
/**
* Helper class used to accumulate scopes and modules (with binaries included) that are used in an assembly, for the
* purposes of creating an aggregated managed-version map with dependency version conflicts resolved.
*
* @author jdcasey
*/
-class ResolutionManagementInfo
-{
+class ResolutionManagementInfo {
private final LinkedHashSet<Artifact> artifacts = new LinkedHashSet<>();
- Set<Artifact> getArtifacts()
- {
+ Set<Artifact> getArtifacts() {
return artifacts;
}
- void addArtifacts( final Set<Artifact> a )
- {
- for ( Artifact artifact : a )
- {
- addOneArtifact( artifact );
+ void addArtifacts(final Set<Artifact> a) {
+ for (Artifact artifact : a) {
+ addOneArtifact(artifact);
}
- artifacts.addAll( a );
+ artifacts.addAll(a);
}
- private void addOneArtifact( Artifact artifact )
- {
- for ( Artifact existing : artifacts )
- {
- if ( existing.equals( artifact ) )
- {
- if ( isScopeUpgrade( artifact, existing ) )
- {
- artifacts.remove( existing );
- artifacts.add( artifact );
+ private void addOneArtifact(Artifact artifact) {
+ for (Artifact existing : artifacts) {
+ if (existing.equals(artifact)) {
+ if (isScopeUpgrade(artifact, existing)) {
+ artifacts.remove(existing);
+ artifacts.add(artifact);
return;
}
}
}
}
- private boolean isScopeUpgrade( Artifact a, Artifact existing )
- {
- return scopeValue( a.getScope() ) > scopeValue( existing.getScope() );
+ private boolean isScopeUpgrade(Artifact a, Artifact existing) {
+ return scopeValue(a.getScope()) > scopeValue(existing.getScope());
}
- private int scopeValue( final String scope )
- {
- if ( Artifact.SCOPE_COMPILE.equals( scope ) )
- {
+ private int scopeValue(final String scope) {
+ if (Artifact.SCOPE_COMPILE.equals(scope)) {
return 5;
- }
- else if ( Artifact.SCOPE_PROVIDED.equals( scope ) )
- {
+ } else if (Artifact.SCOPE_PROVIDED.equals(scope)) {
return 4;
- }
- else if ( Artifact.SCOPE_RUNTIME.equals( scope ) )
- {
+ } else if (Artifact.SCOPE_RUNTIME.equals(scope)) {
return 3;
- }
- else if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
- {
+ } else if (Artifact.SCOPE_SYSTEM.equals(scope)) {
return 2;
- }
- else if ( Artifact.SCOPE_TEST.equals( scope ) )
- {
+ } else if (Artifact.SCOPE_TEST.equals(scope)) {
return 1;
}
return 0;
}
-
}
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 572880ca..93190791 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
-import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.ResourceIterator;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+package org.apache.maven.plugins.assembly.filter;
import java.io.BufferedReader;
import java.io.File;
@@ -39,108 +31,96 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-abstract class AbstractLineAggregatingHandler
- implements ContainerDescriptorHandler
-{
+import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.ResourceIterator;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+
+abstract class AbstractLineAggregatingHandler implements ContainerDescriptorHandler {
private Map<String, List<String>> catalog = new HashMap<>();
private boolean excludeOverride = false;
- protected abstract String getOutputPathPrefix( final FileInfo fileInfo );
+ protected abstract String getOutputPathPrefix(FileInfo fileInfo);
- protected abstract boolean fileMatches( final FileInfo fileInfo );
+ protected abstract boolean fileMatches(FileInfo fileInfo);
- String getEncoding()
- {
+ String getEncoding() {
return "UTF-8";
}
@Override
- public void finalizeArchiveCreation( final Archiver archiver )
- {
+ public void finalizeArchiveCreation(final Archiver archiver) {
// this will prompt the isSelected() call, below, for all resources added to the archive.
// FIXME: This needs to be corrected in the AbstractArchiver, where
// runArchiveFinalizers() is called before regular resources are added...
// which is done because the manifest needs to be added first, and the
// manifest-creation component is a finalizer in the assembly plugin...
- for ( final ResourceIterator it = archiver.getResources(); it.hasNext(); )
- {
+ for (final ResourceIterator it = archiver.getResources(); it.hasNext(); ) {
it.next();
}
- addToArchive( archiver );
+ addToArchive(archiver);
}
- void addToArchive( final Archiver archiver )
- {
- for ( final Map.Entry<String, List<String>> entry : catalog.entrySet() )
- {
+ void addToArchive(final Archiver archiver) {
+ for (final Map.Entry<String, List<String>> entry : catalog.entrySet()) {
final String name = entry.getKey();
- final String fname = new File( name ).getName();
+ final String fname = new File(name).getName();
File f;
- try
- {
- f = Files.createTempFile( "assembly-" + fname, ".tmp" ).toFile();
+ try {
+ f = Files.createTempFile("assembly-" + fname, ".tmp").toFile();
f.deleteOnExit();
- try ( PrintWriter writer =
- new PrintWriter( new OutputStreamWriter( new FileOutputStream( f ), getEncoding() ) ) )
- {
- for ( final String line : entry.getValue() )
- {
- writer.println( line );
+ try (PrintWriter writer =
+ new PrintWriter(new OutputStreamWriter(new FileOutputStream(f), getEncoding()))) {
+ for (final String line : entry.getValue()) {
+ writer.println(line);
}
}
- }
- catch ( final IOException e )
- {
+ } catch (final IOException e) {
throw new ArchiverException(
- "Error adding aggregated content for: " + fname + " to finalize archive creation. Reason: "
- + e.getMessage(), e );
+ "Error adding aggregated content for: " + fname + " to finalize archive creation. Reason: "
+ + e.getMessage(),
+ e);
}
excludeOverride = true;
- archiver.addFile( f, name );
+ archiver.addFile(f, name);
excludeOverride = false;
}
}
@Override
- public void finalizeArchiveExtraction( final UnArchiver unArchiver )
- {
- }
+ public void finalizeArchiveExtraction(final UnArchiver unArchiver) {}
@Override
- public List<String> getVirtualFiles()
- {
- return new ArrayList<>( catalog.keySet() );
+ public List<String> getVirtualFiles() {
+ return new ArrayList<>(catalog.keySet());
}
@Override
- public boolean isSelected( final FileInfo fileInfo )
- throws IOException
- {
- if ( excludeOverride )
- {
+ public boolean isSelected(final FileInfo fileInfo) throws IOException {
+ if (excludeOverride) {
return true;
}
- String name = AssemblyFileUtils.normalizeFileInfo( fileInfo );
+ String name = AssemblyFileUtils.normalizeFileInfo(fileInfo);
- if ( fileInfo.isFile() && fileMatches( fileInfo ) )
- {
- name = getOutputPathPrefix( fileInfo ) + new File( name ).getName();
+ if (fileInfo.isFile() && fileMatches(fileInfo)) {
+ name = getOutputPathPrefix(fileInfo) + new File(name).getName();
- List<String> lines = catalog.get( name );
- if ( lines == null )
- {
+ List<String> lines = catalog.get(name);
+ if (lines == null) {
lines = new ArrayList<>();
- catalog.put( name, lines );
+ catalog.put(name, lines);
}
- readLines( fileInfo, lines );
+ readLines(fileInfo, lines);
return false;
}
@@ -148,30 +128,21 @@ abstract class AbstractLineAggregatingHandler
return true;
}
- void readLines( final FileInfo fileInfo, final List<String> lines )
- throws IOException
- {
- try ( BufferedReader reader =
- new BufferedReader( new InputStreamReader( fileInfo.getContents(), getEncoding() ) ) )
- {
- for ( String line = reader.readLine(); line != null; line = reader.readLine() )
- {
- if ( !lines.contains( line ) )
- {
- lines.add( line );
+ void readLines(final FileInfo fileInfo, final List<String> lines) throws IOException {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(fileInfo.getContents(), getEncoding()))) {
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ if (!lines.contains(line)) {
+ lines.add(line);
}
}
}
}
- protected final Map<String, List<String>> getCatalog()
- {
+ protected final Map<String, List<String>> getCatalog() {
return catalog;
}
- protected final void setCatalog( final Map<String, List<String>> catalog )
- {
+ protected final void setCatalog(final Map<String, List<String>> catalog) {
this.catalog = catalog;
}
-
}
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 d64f3ca5..c5f1960a 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,18 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.commons.io.input.XmlStreamReader;
-import org.apache.commons.io.output.XmlStreamWriter;
-import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.ResourceIterator;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.components.io.fileselectors.FileInfo;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import org.codehaus.plexus.util.xml.Xpp3DomWriter;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+package org.apache.maven.plugins.assembly.filter;
import javax.inject.Named;
@@ -44,16 +31,26 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.input.XmlStreamReader;
+import org.apache.commons.io.output.XmlStreamWriter;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.ResourceIterator;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
/**
* <code>plexus</code>: Plexus Components XML file filter <code>META-INF/plexus/components.xml</code>.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*
*/
-@Named( "plexus" )
-public class ComponentsXmlArchiverFileFilter
- implements ContainerDescriptorHandler
-{
+@Named("plexus")
+public class ComponentsXmlArchiverFileFilter implements ContainerDescriptorHandler {
public static final String COMPONENTS_XML_PATH = "META-INF/plexus/components.xml";
// [jdcasey] Switched visibility to protected to allow testing. Also, because this class isn't final, it should
@@ -63,152 +60,116 @@ public class ComponentsXmlArchiverFileFilter
private boolean excludeOverride = false;
- void addComponentsXml( final Reader componentsReader )
- throws XmlPullParserException, IOException
- {
- Xpp3Dom newDom = Xpp3DomBuilder.build( componentsReader );
+ void addComponentsXml(final Reader componentsReader) throws XmlPullParserException, IOException {
+ Xpp3Dom newDom = Xpp3DomBuilder.build(componentsReader);
- if ( newDom != null )
- {
- newDom = newDom.getChild( "components" );
+ if (newDom != null) {
+ newDom = newDom.getChild("components");
}
- if ( newDom != null )
- {
+ if (newDom != null) {
final Xpp3Dom[] children = newDom.getChildren();
- for ( final Xpp3Dom component : children )
- {
- if ( components == null )
- {
+ for (final Xpp3Dom component : children) {
+ if (components == null) {
components = new LinkedHashMap<>();
}
- final String role = component.getChild( "role" ).getValue();
- final Xpp3Dom child = component.getChild( "role-hint" );
+ final String role = component.getChild("role").getValue();
+ final Xpp3Dom child = component.getChild("role-hint");
final String roleHint = child != null ? child.getValue() : "";
final String key = role + roleHint;
- if ( !components.containsKey( key ) )
- {
- components.put( key, component );
+ if (!components.containsKey(key)) {
+ components.put(key, component);
}
}
}
}
- private void addToArchive( final Archiver archiver )
- throws IOException
- {
- if ( components != null )
- {
- final File f = Files.createTempFile( "maven-assembly-plugin", "tmp" ).toFile();
+ private void addToArchive(final Archiver archiver) throws IOException {
+ if (components != null) {
+ final File f = Files.createTempFile("maven-assembly-plugin", "tmp").toFile();
f.deleteOnExit();
-
- try ( Writer fileWriter = new XmlStreamWriter( Files.newOutputStream( f.toPath() ) ) )
- {
- final Xpp3Dom dom = new Xpp3Dom( "component-set" );
- final Xpp3Dom componentDom = new Xpp3Dom( "components" );
- dom.addChild( componentDom );
+ try (Writer fileWriter = new XmlStreamWriter(Files.newOutputStream(f.toPath()))) {
+ final Xpp3Dom dom = new Xpp3Dom("component-set");
+ final Xpp3Dom componentDom = new Xpp3Dom("components");
+ dom.addChild(componentDom);
- for ( final Xpp3Dom component : components.values() )
- {
- componentDom.addChild( component );
+ for (final Xpp3Dom component : components.values()) {
+ componentDom.addChild(component);
}
- Xpp3DomWriter.write( fileWriter, dom );
+ Xpp3DomWriter.write(fileWriter, dom);
}
excludeOverride = true;
- archiver.addFile( f, COMPONENTS_XML_PATH );
+ archiver.addFile(f, COMPONENTS_XML_PATH);
excludeOverride = false;
}
}
@Override
- public void finalizeArchiveCreation( final Archiver archiver )
- {
+ public void finalizeArchiveCreation(final Archiver archiver) {
// this will prompt the isSelected() call, below, for all resources added to the archive.
// FIXME: This needs to be corrected in the AbstractArchiver, where
// runArchiveFinalizers() is called before regular resources are added...
// which is done because the manifest needs to be added first, and the
// manifest-creation component is a finalizer in the assembly plugin...
- for ( final ResourceIterator it = archiver.getResources(); it.hasNext(); )
- {
+ for (final ResourceIterator it = archiver.getResources(); it.hasNext(); ) {
it.next();
}
- try
- {
- addToArchive( archiver );
- }
- catch ( final IOException e )
- {
- throw new ArchiverException( "Error finalizing component-set for archive. Reason: " + e.getMessage(), e );
+ try {
+ addToArchive(archiver);
+ } catch (final IOException e) {
+ throw new ArchiverException("Error finalizing component-set for archive. Reason: " + e.getMessage(), e);
}
}
@Override
- public List<String> getVirtualFiles()
- {
- if ( ( components != null ) && !components.isEmpty() )
- {
- return Collections.singletonList( COMPONENTS_XML_PATH );
+ public List<String> getVirtualFiles() {
+ if ((components != null) && !components.isEmpty()) {
+ return Collections.singletonList(COMPONENTS_XML_PATH);
}
return null;
}
@Override
- public boolean isSelected( final FileInfo fileInfo )
- throws IOException
- {
- if ( fileInfo.isFile() )
- {
- if ( excludeOverride )
- {
+ public boolean isSelected(final FileInfo fileInfo) throws IOException {
+ if (fileInfo.isFile()) {
+ if (excludeOverride) {
return true;
}
- String entry = fileInfo.getName().replace( '\\', '/' );
+ String entry = fileInfo.getName().replace('\\', '/');
- if ( entry.startsWith( "/" ) )
- {
- entry = entry.substring( 1 );
+ if (entry.startsWith("/")) {
+ entry = entry.substring(1);
}
- if ( ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH.equals( entry ) )
- {
- try ( Reader reader = new BufferedReader( new XmlStreamReader( fileInfo.getContents() ) ) )
- {
- addComponentsXml( reader );
- }
- catch ( final XmlPullParserException e )
- {
+ if (ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH.equals(entry)) {
+ try (Reader reader = new BufferedReader(new XmlStreamReader(fileInfo.getContents()))) {
+ addComponentsXml(reader);
+ } catch (final XmlPullParserException e) {
final IOException error =
- new IOException( "Error finalizing component-set for archive. Reason: " + e.getMessage(), e );
+ new IOException("Error finalizing component-set for archive. Reason: " + e.getMessage(), e);
throw error;
}
return false;
- }
- else
- {
+ } else {
return true;
}
- }
- else
- {
+ } else {
return true;
}
}
@Override
- public void finalizeArchiveExtraction( final UnArchiver unarchiver )
- {
- }
-
+ public void finalizeArchiveExtraction(final UnArchiver unarchiver) {}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/ContainerDescriptorHandler.java b/src/main/java/org/apache/maven/plugins/assembly/filter/ContainerDescriptorHandler.java
index be305da6..087b3c64 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/ContainerDescriptorHandler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/ContainerDescriptorHandler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.filter;
import org.codehaus.plexus.archiver.ArchiveFinalizer;
import org.codehaus.plexus.components.io.fileselectors.FileSelector;
@@ -25,8 +24,4 @@ import org.codehaus.plexus.components.io.fileselectors.FileSelector;
/**
*
*/
-public interface ContainerDescriptorHandler
- extends ArchiveFinalizer, FileSelector
-{
-
-}
+public interface ContainerDescriptorHandler extends ArchiveFinalizer, FileSelector {}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfServicesHandler.java b/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfServicesHandler.java
index 3caf1e6b..5aa4eba4 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfServicesHandler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfServicesHandler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.filter;
import javax.inject.Named;
@@ -28,35 +27,27 @@ import org.codehaus.plexus.components.io.fileselectors.FileInfo;
/**
* <code>metaInf-services</code>: <code>META-INF/services/*</code> aggregating handler.
*/
-@Named( "metaInf-services" )
-public class MetaInfServicesHandler
- extends AbstractLineAggregatingHandler
-{
+@Named("metaInf-services")
+public class MetaInfServicesHandler extends AbstractLineAggregatingHandler {
private static final String SERVICES_PATH_PREFIX = "META-INF/services/";
@Override
- protected String getOutputPathPrefix( final FileInfo fileInfo )
- {
- return Paths.get( fileInfo.getName() ).getParent().toString() + "/";
+ protected String getOutputPathPrefix(final FileInfo fileInfo) {
+ return Paths.get(fileInfo.getName()).getParent().toString() + "/";
}
@Override
- protected boolean fileMatches( final FileInfo fileInfo )
- {
+ protected boolean fileMatches(final FileInfo fileInfo) {
final String path = fileInfo.getName();
String leftover = null;
- if ( path.startsWith( SERVICES_PATH_PREFIX ) )
- {
- leftover = path.substring( SERVICES_PATH_PREFIX.length() );
- }
- else if ( path.startsWith( "/META-INF/services/" ) )
- {
- leftover = path.substring( SERVICES_PATH_PREFIX.length() - 1 );
+ if (path.startsWith(SERVICES_PATH_PREFIX)) {
+ leftover = path.substring(SERVICES_PATH_PREFIX.length());
+ } else if (path.startsWith("/META-INF/services/")) {
+ leftover = path.substring(SERVICES_PATH_PREFIX.length() - 1);
}
return leftover != null && leftover.length() > 0;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfSpringHandler.java b/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfSpringHandler.java
index 1bf10723..c8701fd1 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfSpringHandler.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/filter/MetaInfSpringHandler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.filter;
import javax.inject.Named;
@@ -26,35 +25,27 @@ import org.codehaus.plexus.components.io.fileselectors.FileInfo;
/**
* <code>metaInf-spring</code>: Spring's <code>META-INF/spring.*</code> aggregating handler.
*/
-@Named( "metaInf-spring" )
-public class MetaInfSpringHandler
- extends AbstractLineAggregatingHandler
-{
+@Named("metaInf-spring")
+public class MetaInfSpringHandler extends AbstractLineAggregatingHandler {
private static final String SPRING_PATH_PREFIX = "META-INF/";
@Override
- protected String getOutputPathPrefix( final FileInfo fileInfo )
- {
+ protected String getOutputPathPrefix(final FileInfo fileInfo) {
return SPRING_PATH_PREFIX;
}
@Override
- protected boolean fileMatches( final FileInfo fileInfo )
- {
+ protected boolean fileMatches(final FileInfo fileInfo) {
final String path = fileInfo.getName();
String leftover = null;
- if ( path.startsWith( "/META-INF/spring." ) )
- {
- leftover = path.substring( "/META-INF/spring.".length() );
- }
- else if ( path.startsWith( "META-INF/spring." ) )
- {
- leftover = path.substring( "META-INF/spring.".length() - 1 );
+ if (path.startsWith("/META-INF/spring.")) {
+ leftover = path.substring("/META-INF/spring.".length());
+ } else if (path.startsWith("META-INF/spring.")) {
+ leftover = path.substring("META-INF/spring.".length() - 1);
}
return leftover != null && leftover.length() > 0;
}
-
}
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 a0f42049..8246e156 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,7 @@ package org.apache.maven.plugins.assembly.filter;
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
-import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.components.io.fileselectors.FileInfo;
-import org.codehaus.plexus.util.IOUtil;
+package org.apache.maven.plugins.assembly.filter;
import javax.inject.Named;
@@ -44,15 +36,21 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
+import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+import org.codehaus.plexus.util.IOUtil;
+
/**
* <code>file-aggregator</code>: Generic aggregating handler, configured with filePattern and outputPath.
*/
-@Named( "file-aggregator" )
-public class SimpleAggregatingDescriptorHandler implements ContainerDescriptorHandler
-{
+@Named("file-aggregator")
+public class SimpleAggregatingDescriptorHandler implements ContainerDescriptorHandler {
// component configuration.
- @SuppressWarnings( "FieldCanBeLocal" )
+ @SuppressWarnings("FieldCanBeLocal")
private final String commentChars = "#";
private final StringWriter aggregateWriter = new StringWriter();
@@ -68,101 +66,83 @@ public class SimpleAggregatingDescriptorHandler implements ContainerDescriptorHa
private boolean overrideFilterAction;
@Override
- public void finalizeArchiveCreation( final Archiver archiver )
- {
+ public void finalizeArchiveCreation(final Archiver archiver) {
checkConfig();
- if ( outputPath.endsWith( "/" ) )
- {
- throw new ArchiverException( "Cannot write aggregated properties to a directory. "
- + "You must specify a file name in the outputPath configuration for this"
- + " handler. (handler: " + getClass().getName() );
+ if (outputPath.endsWith("/")) {
+ throw new ArchiverException("Cannot write aggregated properties to a directory. "
+ + "You must specify a file name in the outputPath configuration for this"
+ + " handler. (handler: " + getClass().getName());
}
- if ( outputPath.startsWith( "/" ) )
- {
- outputPath = outputPath.substring( 1 );
+ if (outputPath.startsWith("/")) {
+ outputPath = outputPath.substring(1);
}
final File temp = writePropertiesFile();
overrideFilterAction = true;
- archiver.addFile( temp, outputPath );
+ archiver.addFile(temp, outputPath);
overrideFilterAction = false;
}
- private File writePropertiesFile()
- {
+ private File writePropertiesFile() {
File f;
- try
- {
- f = Files.createTempFile( "maven-assembly-plugin", "tmp" ).toFile();
+ try {
+ f = Files.createTempFile("maven-assembly-plugin", "tmp").toFile();
f.deleteOnExit();
- try ( Writer writer = getWriter( f ) )
- {
- writer.write( commentChars + " Aggregated on " + new Date() + " from: " );
+ try (Writer writer = getWriter(f)) {
+ writer.write(commentChars + " Aggregated on " + new Date() + " from: ");
- for ( final String filename : filenames )
- {
- writer.write( "\n" + commentChars + " " + filename );
+ for (final String filename : filenames) {
+ writer.write("\n" + commentChars + " " + filename);
}
- writer.write( "\n\n" );
- writer.write( aggregateWriter.toString() );
+ writer.write("\n\n");
+ writer.write(aggregateWriter.toString());
}
- }
- catch ( final IOException e )
- {
+ } catch (final IOException e) {
throw new ArchiverException(
- "Error adding aggregated properties to finalize archive creation. Reason: " + e.getMessage(), e );
+ "Error adding aggregated properties to finalize archive creation. Reason: " + e.getMessage(), e);
}
return f;
}
- private Writer getWriter( File f )
- throws FileNotFoundException
- {
+ private Writer getWriter(File f) throws FileNotFoundException {
Writer writer;
- writer = AssemblyFileUtils.isPropertyFile( f )
- ? new OutputStreamWriter( new FileOutputStream( f ), StandardCharsets.ISO_8859_1 )
- : new OutputStreamWriter( new FileOutputStream( f ) ); // Still platform encoding
+ writer = AssemblyFileUtils.isPropertyFile(f)
+ ? new OutputStreamWriter(new FileOutputStream(f), StandardCharsets.ISO_8859_1)
+ : new OutputStreamWriter(new FileOutputStream(f)); // Still platform encoding
return writer;
}
@Override
- public void finalizeArchiveExtraction( final UnArchiver unarchiver )
- {
- }
+ public void finalizeArchiveExtraction(final UnArchiver unarchiver) {}
@Override
- public List<String> getVirtualFiles()
- {
+ public List<String> getVirtualFiles() {
checkConfig();
- return Collections.singletonList( outputPath );
+ return Collections.singletonList(outputPath);
}
@Override
- public boolean isSelected( final FileInfo fileInfo )
- throws IOException
- {
+ public boolean isSelected(final FileInfo fileInfo) throws IOException {
checkConfig();
- if ( overrideFilterAction )
- {
+ if (overrideFilterAction) {
return true;
}
- String name = AssemblyFileUtils.normalizeFileInfo( fileInfo );
+ String name = AssemblyFileUtils.normalizeFileInfo(fileInfo);
- if ( fileInfo.isFile() && name.matches( filePattern ) )
- {
- readProperties( fileInfo );
- filenames.add( name );
+ if (fileInfo.isFile() && name.matches(filePattern)) {
+ readProperties(fileInfo);
+ filenames.add(name);
return false;
}
@@ -170,52 +150,43 @@ public class SimpleAggregatingDescriptorHandler implements ContainerDescriptorHa
return true;
}
- private void checkConfig()
- {
- if ( filePattern == null || outputPath == null )
- {
+ private void checkConfig() {
+ if (filePattern == null || outputPath == null) {
throw new IllegalStateException(
- "You must configure filePattern and outputPath in your containerDescriptorHandler declaration." );
+ "You must configure filePattern and outputPath in your containerDescriptorHandler declaration.");
}
}
- private void readProperties( final FileInfo fileInfo )
- throws IOException
- {
- try ( StringWriter writer = new StringWriter();
- Reader reader = AssemblyFileUtils.isPropertyFile( fileInfo.getName() )
- ? new InputStreamReader( fileInfo.getContents(), StandardCharsets.ISO_8859_1 )
- : new InputStreamReader( fileInfo.getContents() ) ) // platform encoding
+ private void readProperties(final FileInfo fileInfo) throws IOException {
+ try (StringWriter writer = new StringWriter();
+ Reader reader = AssemblyFileUtils.isPropertyFile(fileInfo.getName())
+ ? new InputStreamReader(fileInfo.getContents(), StandardCharsets.ISO_8859_1)
+ : new InputStreamReader(fileInfo.getContents())) // platform encoding
{
- IOUtil.copy( reader, writer );
+ IOUtil.copy(reader, writer);
final String content = writer.toString();
- aggregateWriter.write( "\n" );
- aggregateWriter.write( content );
+ aggregateWriter.write("\n");
+ aggregateWriter.write(content);
}
}
- @SuppressWarnings( "UnusedDeclaration" )
- public String getFilePattern()
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public String getFilePattern() {
return filePattern;
}
- @SuppressWarnings( "UnusedDeclaration" )
- public void setFilePattern( final String filePattern )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setFilePattern(final String filePattern) {
this.filePattern = filePattern;
}
- @SuppressWarnings( "UnusedDeclaration" )
- public String getOutputPath()
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public String getOutputPath() {
return outputPath;
}
- @SuppressWarnings( "UnusedDeclaration" )
- public void setOutputPath( final String outputPath )
- {
+ @SuppressWarnings("UnusedDeclaration")
+ public void setOutputPath(final String outputPath) {
this.outputPath = outputPath;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/format/AssemblyFormattingException.java b/src/main/java/org/apache/maven/plugins/assembly/format/AssemblyFormattingException.java
index 6346f6a1..eee27a76 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/format/AssemblyFormattingException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/format/AssemblyFormattingException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.format;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,24 +16,20 @@ package org.apache.maven.plugins.assembly.format;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.format;
/**
*
*/
-public class AssemblyFormattingException
- extends Exception
-{
+public class AssemblyFormattingException extends Exception {
private static final long serialVersionUID = 1L;
- public AssemblyFormattingException( final String message, final Throwable error )
- {
- super( message, error );
+ public AssemblyFormattingException(final String message, final Throwable error) {
+ super(message, error);
}
- public AssemblyFormattingException( final String message )
- {
- super( message );
+ public AssemblyFormattingException(final String message) {
+ super(message);
}
-
}
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 8906d4de..3f7daf71 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.format;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,16 @@ package org.apache.maven.plugins.assembly.format;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.format;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
@@ -29,138 +37,117 @@ import org.apache.maven.shared.filtering.MavenReaderFilterRequest;
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
/**
*
*/
-public class ReaderFormatter
-{
- private static Reader createReaderFilter( Reader source, String escapeString, List<String> delimiters,
- AssemblerConfigurationSource configSource, boolean isPropertiesFile,
- Properties additionalProperties )
- throws IOException
- {
- try
- {
-
- MavenReaderFilterRequest filterRequest =
- new MavenReaderFilterRequest( source, true, configSource.getProject(), configSource.getFilters(),
- isPropertiesFile, configSource.getMavenSession(), additionalProperties );
-
- filterRequest.setEscapeString( escapeString );
+public class ReaderFormatter {
+ private static Reader createReaderFilter(
+ Reader source,
+ String escapeString,
+ List<String> delimiters,
+ AssemblerConfigurationSource configSource,
+ boolean isPropertiesFile,
+ Properties additionalProperties)
+ throws IOException {
+ try {
+
+ MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(
+ source,
+ true,
+ configSource.getProject(),
+ configSource.getFilters(),
+ isPropertiesFile,
+ configSource.getMavenSession(),
+ additionalProperties);
+
+ filterRequest.setEscapeString(escapeString);
// if these are NOT set, just use the defaults, which are '${*}' and '@'.
- if ( delimiters != null && !delimiters.isEmpty() )
- {
+ if (delimiters != null && !delimiters.isEmpty()) {
LinkedHashSet<String> delims = new LinkedHashSet<>();
- for ( String delim : delimiters )
- {
- if ( delim == null )
- {
+ for (String delim : delimiters) {
+ if (delim == null) {
// FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution.
- delims.add( "${*}" );
- }
- else
- {
- delims.add( delim );
+ delims.add("${*}");
+ } else {
+ delims.add(delim);
}
}
- filterRequest.setDelimiters( delims );
- }
- else
- {
- filterRequest.setDelimiters( filterRequest.getDelimiters() );
+ filterRequest.setDelimiters(delims);
+ } else {
+ filterRequest.setDelimiters(filterRequest.getDelimiters());
}
- filterRequest.setInjectProjectBuildFilters( configSource.isIncludeProjectBuildFilters() );
- return configSource.getMavenReaderFilter().filter( filterRequest );
- }
- catch ( MavenFilteringException e )
- {
- IOException ioe = new IOException( "Error filtering file '" + source + "': " + e.getMessage(), e );
+ filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters());
+ return configSource.getMavenReaderFilter().filter(filterRequest);
+ } catch (MavenFilteringException e) {
+ IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage(), e);
throw ioe;
}
}
-
- private static boolean isForbiddenFiletypes( PlexusIoResource plexusIoResource )
- {
+ private static boolean isForbiddenFiletypes(PlexusIoResource plexusIoResource) {
String fileName = plexusIoResource.getName().toLowerCase();
- return ( fileName.endsWith( ".zip" ) || fileName.endsWith( ".jar" ) );
+ return (fileName.endsWith(".zip") || fileName.endsWith(".jar"));
}
- private static void checkifFileTypeIsAppropriateForLineEndingTransformation( PlexusIoResource plexusIoResource )
- throws IOException
- {
- if ( isForbiddenFiletypes( plexusIoResource ) )
- {
- throw new IOException( "Cannot transform line endings on this kind of file: " + plexusIoResource.getName()
- + "\nDoing so is more or less guaranteed to destroy the file, and it indicates"
- + " a problem with your assembly descriptor."
- + "\nThis error message is new as of 2.5.3. "
- + "\nEarlier versions of assembly-plugin will silently destroy your file. "
- + "Fix your descriptor" );
+ private static void checkifFileTypeIsAppropriateForLineEndingTransformation(PlexusIoResource plexusIoResource)
+ throws IOException {
+ if (isForbiddenFiletypes(plexusIoResource)) {
+ throw new IOException("Cannot transform line endings on this kind of file: " + plexusIoResource.getName()
+ + "\nDoing so is more or less guaranteed to destroy the file, and it indicates"
+ + " a problem with your assembly descriptor."
+ + "\nThis error message is new as of 2.5.3. "
+ + "\nEarlier versions of assembly-plugin will silently destroy your file. "
+ + "Fix your descriptor");
}
-
}
- public static InputStreamTransformer getFileSetTransformers( final AssemblerConfigurationSource configSource,
- final boolean isFiltered,
- final Set<String> nonFilteredFileExtensions,
- String fileSetLineEnding )
- throws AssemblyFormattingException
- {
- final LineEndings lineEndingToUse = LineEndingsUtils.getLineEnding( fileSetLineEnding );
+ public static InputStreamTransformer getFileSetTransformers(
+ final AssemblerConfigurationSource configSource,
+ final boolean isFiltered,
+ final Set<String> nonFilteredFileExtensions,
+ String fileSetLineEnding)
+ throws AssemblyFormattingException {
+ final LineEndings lineEndingToUse = LineEndingsUtils.getLineEnding(fileSetLineEnding);
- final boolean transformLineEndings = !LineEndings.keep.equals( lineEndingToUse );
+ final boolean transformLineEndings = !LineEndings.keep.equals(lineEndingToUse);
- if ( transformLineEndings || isFiltered )
- {
- return new InputStreamTransformer()
- {
+ if (transformLineEndings || isFiltered) {
+ return new InputStreamTransformer() {
@Override
- public InputStream transform( PlexusIoResource plexusIoResource,
- InputStream inputStream )
- throws IOException
- {
+ public InputStream transform(PlexusIoResource plexusIoResource, InputStream inputStream)
+ throws IOException {
final String fileName = plexusIoResource.getName();
- for ( String extension : nonFilteredFileExtensions )
- {
- if ( fileName.endsWith( '.' + extension ) )
- {
+ for (String extension : nonFilteredFileExtensions) {
+ if (fileName.endsWith('.' + extension)) {
return inputStream;
}
}
-
+
InputStream result = inputStream;
- if ( isFiltered )
- {
- boolean isPropertyFile = AssemblyFileUtils.isPropertyFile( plexusIoResource.getName() );
+ if (isFiltered) {
+ boolean isPropertyFile = AssemblyFileUtils.isPropertyFile(plexusIoResource.getName());
final String encoding = isPropertyFile ? "ISO-8859-1" : configSource.getEncoding();
Reader source = encoding != null
- ? new InputStreamReader( inputStream, encoding )
- : new InputStreamReader( inputStream ); // wtf platform encoding ? TODO: Fix this
- Reader filtered =
- createReaderFilter( source, configSource.getEscapeString(), configSource.getDelimiters(),
- configSource, isPropertyFile, configSource.getAdditionalProperties() );
+ ? new InputStreamReader(inputStream, encoding)
+ : new InputStreamReader(inputStream); // wtf platform encoding ? TODO: Fix this
+ Reader filtered = createReaderFilter(
+ source,
+ configSource.getEscapeString(),
+ configSource.getDelimiters(),
+ configSource,
+ isPropertyFile,
+ configSource.getAdditionalProperties());
result = encoding != null
- ? new ReaderInputStream( filtered, encoding )
- : new ReaderInputStream( filtered );
+ ? new ReaderInputStream(filtered, encoding)
+ : new ReaderInputStream(filtered);
}
- if ( transformLineEndings )
- {
- checkifFileTypeIsAppropriateForLineEndingTransformation( plexusIoResource );
- result = LineEndingsUtils.lineEndingConverter( result, lineEndingToUse );
+ if (transformLineEndings) {
+ checkifFileTypeIsAppropriateForLineEndingTransformation(plexusIoResource);
+ result = LineEndingsUtils.lineEndingConverter(result, lineEndingToUse);
}
return result;
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjectConsumer.java b/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjectConsumer.java
index 6f9ca364..e672407a 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjectConsumer.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjectConsumer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.functions;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,13 @@ package org.apache.maven.plugins.assembly.functions;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.functions;
import org.apache.maven.project.MavenProject;
/**
*
*/
-public interface MavenProjectConsumer
-{
- void accept( MavenProject project );
+public interface MavenProjectConsumer {
+ void accept(MavenProject project);
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjects.java b/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjects.java
index 77e298e2..3cf6e914 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjects.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/functions/MavenProjects.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.functions;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,67 +16,55 @@ package org.apache.maven.plugins.assembly.functions;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.functions;
+
+import java.util.List;
+import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
-import java.util.List;
-import java.util.Set;
-
/**
*
*/
-public class MavenProjects
-{
- public static void without( Iterable<MavenProject> source, String packagingType, MavenProjectConsumer consumer )
- {
- for ( MavenProject project : source )
- {
- if ( !packagingType.equals( project.getPackaging() ) )
- {
- consumer.accept( project );
+public class MavenProjects {
+ public static void without(Iterable<MavenProject> source, String packagingType, MavenProjectConsumer consumer) {
+ for (MavenProject project : source) {
+ if (!packagingType.equals(project.getPackaging())) {
+ consumer.accept(project);
}
}
}
- public static void select( Iterable<MavenProject> source, String packagingType, MavenProjectConsumer consumer )
- {
- for ( MavenProject project : source )
- {
- if ( packagingType.equals( project.getPackaging() ) )
- {
- consumer.accept( project );
+ public static void select(Iterable<MavenProject> source, String packagingType, MavenProjectConsumer consumer) {
+ for (MavenProject project : source) {
+ if (packagingType.equals(project.getPackaging())) {
+ consumer.accept(project);
}
}
}
- public static void select( Iterable<MavenProject> source, String packagingType, MavenProjectConsumer include,
- MavenProjectConsumer excluded )
- {
- for ( MavenProject project : source )
- {
- if ( packagingType.equals( project.getPackaging() ) )
- {
- include.accept( project );
- }
- else
- {
- excluded.accept( project );
+ public static void select(
+ Iterable<MavenProject> source,
+ String packagingType,
+ MavenProjectConsumer include,
+ MavenProjectConsumer excluded) {
+ for (MavenProject project : source) {
+ if (packagingType.equals(project.getPackaging())) {
+ include.accept(project);
+ } else {
+ excluded.accept(project);
}
}
}
- public static Artifact findArtifactByClassifier( MavenProject mavenProject, String classifier )
- {
+ public static Artifact findArtifactByClassifier(MavenProject mavenProject, String classifier) {
final List<Artifact> attachments = mavenProject.getAttachedArtifacts();
- if ( ( attachments != null ) && !attachments.isEmpty() )
- {
- for ( final Artifact attachment : attachments )
- {
- if ( classifier.equals( attachment.getClassifier() ) )
- {
+ if ((attachments != null) && !attachments.isEmpty()) {
+ for (final Artifact attachment : attachments) {
+ if (classifier.equals(attachment.getClassifier())) {
return attachment;
}
}
@@ -86,31 +72,23 @@ public class MavenProjects
return null;
}
-
- public static MavenProjectConsumer log( final Logger logger )
- {
- return new MavenProjectConsumer()
- {
+ public static MavenProjectConsumer log(final Logger logger) {
+ return new MavenProjectConsumer() {
@Override
- public void accept( MavenProject project )
- {
- final String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+ public void accept(MavenProject project) {
+ final String projectId = ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId());
- logger.debug( "Excluding POM-packaging module: " + projectId );
+ logger.debug("Excluding POM-packaging module: " + projectId);
}
};
}
- public static MavenProjectConsumer addTo( final Set<MavenProject> set )
- {
- return new MavenProjectConsumer()
- {
+ public static MavenProjectConsumer addTo(final Set<MavenProject> set) {
+ return new MavenProjectConsumer() {
@Override
- public void accept( MavenProject project )
- {
- set.add( project );
+ public void accept(MavenProject project) {
+ set.add(project);
}
};
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/functions/ModuleSetConsumer.java b/src/main/java/org/apache/maven/plugins/assembly/functions/ModuleSetConsumer.java
index a0fcc730..e4ec1dce 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/functions/ModuleSetConsumer.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/functions/ModuleSetConsumer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.functions;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.functions;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.functions;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
@@ -28,9 +27,8 @@ import org.apache.maven.plugins.assembly.model.ModuleSet;
/**
*
*/
-public interface ModuleSetConsumer
-{
- void accept( ModuleSet resolvedModule )
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- DependencyResolutionException;
+public interface ModuleSetConsumer {
+ void accept(ModuleSet resolvedModule)
+ throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
+ DependencyResolutionException;
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/internal/DebugConfigurationListener.java b/src/main/java/org/apache/maven/plugins/assembly/internal/DebugConfigurationListener.java
index 5da66aca..2db5f3e2 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/internal/DebugConfigurationListener.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/internal/DebugConfigurationListener.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.internal;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.assembly.internal;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.internal;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.internal;
import java.lang.reflect.Array;
@@ -27,31 +26,24 @@ import org.slf4j.Logger;
/**
* Copy of deprecated {@link org.apache.maven.plugin.DebugConfigurationListener} updated to Slf4j.
*/
-public class DebugConfigurationListener
- implements ConfigurationListener
-{
+public class DebugConfigurationListener implements ConfigurationListener {
private final Logger logger;
- public DebugConfigurationListener( Logger logger )
- {
+ public DebugConfigurationListener(Logger logger) {
this.logger = logger;
}
@Override
- public void notifyFieldChangeUsingSetter( String fieldName, Object value, Object target )
- {
- if ( logger.isDebugEnabled() )
- {
- logger.debug( " (s) " + fieldName + " = " + toString( value ) );
+ public void notifyFieldChangeUsingSetter(String fieldName, Object value, Object target) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(" (s) " + fieldName + " = " + toString(value));
}
}
@Override
- public void notifyFieldChangeUsingReflection( String fieldName, Object value, Object target )
- {
- if ( logger.isDebugEnabled() )
- {
- logger.debug( " (f) " + fieldName + " = " + toString( value ) );
+ public void notifyFieldChangeUsingReflection(String fieldName, Object value, Object target) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(" (f) " + fieldName + " = " + toString(value));
}
}
@@ -61,30 +53,23 @@ public class DebugConfigurationListener
* @param obj The object to create a string representation for, may be <code>null</code>.
* @return The string representation, never <code>null</code>.
*/
- private String toString( Object obj )
- {
+ private String toString(Object obj) {
String str;
- if ( obj != null && obj.getClass().isArray() )
- {
- int n = Array.getLength( obj );
- StringBuilder buf = new StringBuilder( 256 );
- buf.append( '[' );
- for ( int i = 0; i < n; i++ )
- {
- if ( i > 0 )
- {
- buf.append( ", " );
+ if (obj != null && obj.getClass().isArray()) {
+ int n = Array.getLength(obj);
+ StringBuilder buf = new StringBuilder(256);
+ buf.append('[');
+ for (int i = 0; i < n; i++) {
+ if (i > 0) {
+ buf.append(", ");
}
- buf.append( Array.get( obj, i ) );
+ buf.append(Array.get(obj, i));
}
- buf.append( ']' );
+ buf.append(']');
str = buf.toString();
- }
- else
- {
- str = String.valueOf( obj );
+ } else {
+ str = String.valueOf(obj);
}
return str;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/internal/SarPlexusIoResourceCollection.java b/src/main/java/org/apache/maven/plugins/assembly/internal/SarPlexusIoResourceCollection.java
index 70b64331..b3a766a7 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/internal/SarPlexusIoResourceCollection.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/internal/SarPlexusIoResourceCollection.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.internal;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.internal;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.internal;
import javax.inject.Named;
import javax.inject.Provider;
@@ -30,12 +29,10 @@ import org.codehaus.plexus.components.io.resources.PlexusIoZipFileResourceCollec
* Provider for "sar" {@link PlexusIoResourceCollection}.
*/
@Singleton
-@Named( "sar" )
-public class SarPlexusIoResourceCollection implements Provider<PlexusIoResourceCollection>
-{
+@Named("sar")
+public class SarPlexusIoResourceCollection implements Provider<PlexusIoResourceCollection> {
@Override
- public PlexusIoResourceCollection get()
- {
+ public PlexusIoResourceCollection get() {
return new PlexusIoZipFileResourceCollection();
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/internal/SarUnArchiverProvider.java b/src/main/java/org/apache/maven/plugins/assembly/internal/SarUnArchiverProvider.java
index 0859da20..2ecb9099 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/internal/SarUnArchiverProvider.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/internal/SarUnArchiverProvider.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.internal;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.internal;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.internal;
import javax.inject.Named;
import javax.inject.Provider;
@@ -30,12 +29,10 @@ import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
* Provider for "sar" {@link UnArchiver}.
*/
@Singleton
-@Named( "sar" )
-public class SarUnArchiverProvider implements Provider<UnArchiver>
-{
+@Named("sar")
+public class SarUnArchiverProvider implements Provider<UnArchiver> {
@Override
- public UnArchiver get()
- {
+ public UnArchiver get() {
return new ZipUnArchiver();
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluator.java b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluator.java
index d85ca991..2ae15a01 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluator.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.interpolation;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,9 @@ package org.apache.maven.plugins.assembly.interpolation;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.interpolation;
+
+import java.io.File;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.io.DefaultAssemblyReader;
@@ -29,14 +30,10 @@ import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
import org.codehaus.plexus.interpolation.fixed.InterpolationState;
-import java.io.File;
-
/**
*
*/
-public class AssemblyExpressionEvaluator
- implements ExpressionEvaluator
-{
+public class AssemblyExpressionEvaluator implements ExpressionEvaluator {
private final AssemblerConfigurationSource configSource;
@@ -44,40 +41,32 @@ public class AssemblyExpressionEvaluator
private final PrefixAwareRecursionInterceptor interceptor;
- public AssemblyExpressionEvaluator( AssemblerConfigurationSource configSource )
- {
+ public AssemblyExpressionEvaluator(AssemblerConfigurationSource configSource) {
this.configSource = configSource;
final MavenProject project = configSource.getProject();
final FixedStringSearchInterpolator projectInterpolator =
- DefaultAssemblyReader.createProjectInterpolator( project );
- interpolator = AssemblyInterpolator.fullInterpolator( project, projectInterpolator, configSource );
- interceptor = new PrefixAwareRecursionInterceptor( InterpolationConstants.PROJECT_PREFIXES, true );
+ DefaultAssemblyReader.createProjectInterpolator(project);
+ interpolator = AssemblyInterpolator.fullInterpolator(project, projectInterpolator, configSource);
+ interceptor = new PrefixAwareRecursionInterceptor(InterpolationConstants.PROJECT_PREFIXES, true);
}
@Override
- public File alignToBaseDirectory( File f )
- {
+ public File alignToBaseDirectory(File f) {
String basePath = configSource.getBasedir().getAbsolutePath();
String path = f.getPath();
- if ( !f.isAbsolute() && !path.startsWith( basePath ) )
- {
- return new File( configSource.getBasedir(), path );
- }
- else
- {
+ if (!f.isAbsolute() && !path.startsWith(basePath)) {
+ return new File(configSource.getBasedir(), path);
+ } else {
return f;
}
}
@Override
- public Object evaluate( String expression )
- throws ExpressionEvaluationException
- {
+ public Object evaluate(String expression) throws ExpressionEvaluationException {
InterpolationState is = new InterpolationState();
- is.setRecursionInterceptor( interceptor );
- return interpolator.interpolate( expression, is );
+ is.setRecursionInterceptor(interceptor);
+ return interpolator.interpolate(expression, is);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolationException.java b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolationException.java
index fafb8298..5d8e1f90 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolationException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/interpolation/AssemblyInterpolationException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.interpolation;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,18 +16,15 @@ package org.apache.maven.plugins.assembly.interpolation;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.interpolation;
/**
*
*/
-public class AssemblyInterpolationException
- extends Exception
-{
+public class AssemblyInterpolationException extends Exception {
private static final long serialVersionUID = 1L;
- public AssemblyInterpolationException( final String message, final Throwable cause )
- {
- super( message, cause );
+ public AssemblyInterpolationException(final String message, final Throwable cause) {
+ super(message, cause);
}
-
}
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 ef32b851..1a3cba05 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.interpolation;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,13 @@ package org.apache.maven.plugins.assembly.interpolation;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.interpolation;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader;
@@ -31,57 +36,40 @@ import org.codehaus.plexus.interpolation.fixed.InterpolationState;
import org.codehaus.plexus.interpolation.object.FieldBasedObjectInterpolator;
import org.slf4j.Logger;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
*
*/
-public class AssemblyInterpolator
-{
+public class AssemblyInterpolator {
private static final Set<String> INTERPOLATION_BLACKLIST;
- static
- {
+ static {
final Set<String> blacklist = new HashSet<>();
- blacklist.add( "outputFileNameMapping" );
- blacklist.add( "outputDirectoryMapping" );
- blacklist.add( "outputDirectory" );
+ blacklist.add("outputFileNameMapping");
+ blacklist.add("outputDirectoryMapping");
+ blacklist.add("outputDirectory");
INTERPOLATION_BLACKLIST = blacklist;
}
- public AssemblyInterpolator()
- throws IOException
- {
- }
+ public AssemblyInterpolator() throws IOException {}
public static AssemblyXpp3Reader.ContentTransformer assemblyInterpolator(
- final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger )
- {
- final Set<String> blacklistFields =
- new HashSet<>( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
- blacklistFields.addAll( INTERPOLATION_BLACKLIST );
-
- return new AssemblyXpp3Reader.ContentTransformer()
- {
+ final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger) {
+ final Set<String> blacklistFields = new HashSet<>(FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES);
+ blacklistFields.addAll(INTERPOLATION_BLACKLIST);
+
+ return new AssemblyXpp3Reader.ContentTransformer() {
@Override
- public String transform( String source, String contextDescription )
- {
- if ( blacklistFields.contains( contextDescription ) )
- {
+ public String transform(String source, String contextDescription) {
+ if (blacklistFields.contains(contextDescription)) {
return source;
}
- String interpolated = interpolator.interpolate( source, is );
- if ( !source.equals( interpolated ) && logger.isDebugEnabled() )
- {
+ String interpolated = interpolator.interpolate(source, is);
+ if (!source.equals(interpolated) && logger.isDebugEnabled()) {
logger.debug(
- "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated );
+ "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated);
}
return interpolated;
}
@@ -89,85 +77,71 @@ public class AssemblyInterpolator
}
public static ComponentXpp3Reader.ContentTransformer componentInterpolator(
- final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger )
- {
- final Set<String> blacklistFields =
- new HashSet<>( FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES );
- blacklistFields.addAll( INTERPOLATION_BLACKLIST );
-
- return new ComponentXpp3Reader.ContentTransformer()
- {
+ final FixedStringSearchInterpolator interpolator, final InterpolationState is, final Logger logger) {
+ final Set<String> blacklistFields = new HashSet<>(FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES);
+ blacklistFields.addAll(INTERPOLATION_BLACKLIST);
+
+ return new ComponentXpp3Reader.ContentTransformer() {
@Override
- public String transform( String source, String contextDescription )
- {
- if ( blacklistFields.contains( contextDescription ) )
- {
+ public String transform(String source, String contextDescription) {
+ if (blacklistFields.contains(contextDescription)) {
return source;
}
- String interpolated = interpolator.interpolate( source, is );
- if ( !source.equals( interpolated ) )
- {
+ String interpolated = interpolator.interpolate(source, is);
+ if (!source.equals(interpolated)) {
logger.debug(
- "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated );
+ "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated);
}
return interpolated;
}
};
}
-
- public static void checkErrors( AssemblyId assemblyId, InterpolationState interpolationState, Logger logger )
- {
- if ( interpolationState.asList() != null && interpolationState.asList().size() > 0 && logger.isDebugEnabled() )
- {
+ public static void checkErrors(AssemblyId assemblyId, InterpolationState interpolationState, Logger logger) {
+ if (interpolationState.asList() != null && interpolationState.asList().size() > 0 && logger.isDebugEnabled()) {
final StringBuilder sb = new StringBuilder();
- sb.append( "One or more minor errors occurred while interpolating the assembly with ID: " ).append(
- assemblyId ).append( ":\n" );
+ sb.append("One or more minor errors occurred while interpolating the assembly with ID: ")
+ .append(assemblyId)
+ .append(":\n");
- @SuppressWarnings( "unchecked" ) final List<Object> warnings = interpolationState.asList();
- for ( final Object warning : warnings )
- {
- sb.append( '\n' ).append( warning );
+ @SuppressWarnings("unchecked")
+ final List<Object> warnings = interpolationState.asList();
+ for (final Object warning : warnings) {
+ sb.append('\n').append(warning);
}
- sb.append( "\n\nThese values were SKIPPED, but the assembly process will continue.\n" );
+ sb.append("\n\nThese values were SKIPPED, but the assembly process will continue.\n");
- logger.debug( sb.toString() );
+ logger.debug(sb.toString());
}
}
- public static FixedStringSearchInterpolator fullInterpolator( final MavenProject project,
- final FixedStringSearchInterpolator projectIp,
- final AssemblerConfigurationSource configSource )
- {
- FixedStringSearchInterpolator fixedStringSearchInterpolator =
- FixedStringSearchInterpolator.create( configSource.getRepositoryInterpolator(),
- configSource.getCommandLinePropsInterpolator(),
- configSource.getEnvInterpolator(), projectIp );
- return fixedStringSearchInterpolator.withPostProcessor(
- new PathTranslatingPostProcessor( project.getBasedir() ) );
-
+ public static FixedStringSearchInterpolator fullInterpolator(
+ final MavenProject project,
+ final FixedStringSearchInterpolator projectIp,
+ final AssemblerConfigurationSource configSource) {
+ FixedStringSearchInterpolator fixedStringSearchInterpolator = FixedStringSearchInterpolator.create(
+ configSource.getRepositoryInterpolator(),
+ configSource.getCommandLinePropsInterpolator(),
+ configSource.getEnvInterpolator(),
+ projectIp);
+ return fixedStringSearchInterpolator.withPostProcessor(new PathTranslatingPostProcessor(project.getBasedir()));
}
- private static final class PathTranslatingPostProcessor
- implements InterpolationPostProcessor
- {
+ private static final class PathTranslatingPostProcessor implements InterpolationPostProcessor {
private final File basedir;
- PathTranslatingPostProcessor( final File basedir )
- {
+ PathTranslatingPostProcessor(final File basedir) {
this.basedir = basedir;
}
@Override
- public Object execute( final String expression, final Object value )
- {
- final String path = String.valueOf( value );
- return AssemblyFileUtils.makePathRelativeTo( path, basedir );
+ public Object execute(final String expression, final Object value) {
+ final String path = String.valueOf(value);
+ return AssemblyFileUtils.makePathRelativeTo(path, basedir);
}
-
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReadException.java b/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReadException.java
index abf9de8a..f0558985 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReadException.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReadException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,24 +16,20 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
/**
*
*/
-public class AssemblyReadException
- extends Exception
-{
+public class AssemblyReadException extends Exception {
private static final long serialVersionUID = 1L;
- public AssemblyReadException( final String message, final Throwable cause )
- {
- super( message, cause );
+ public AssemblyReadException(final String message, final Throwable cause) {
+ super(message, cause);
}
- public AssemblyReadException( final String message )
- {
- super( message );
+ public AssemblyReadException(final String message) {
+ super(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReader.java b/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReader.java
index fe991921..22766ec8 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReader.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/AssemblyReader.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,31 +16,30 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
+
+import java.io.File;
+import java.util.List;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugins.assembly.model.Assembly;
-import java.io.File;
-import java.util.List;
-
/**
*
*/
-public interface AssemblyReader
-{
-
- List<Assembly> readAssemblies( AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException;
+public interface AssemblyReader {
- Assembly getAssemblyForDescriptorReference( String ref, AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException;
+ List<Assembly> readAssemblies(AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException;
- Assembly getAssemblyFromDescriptorFile( File file, AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException;
+ Assembly getAssemblyForDescriptorReference(String ref, AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException;
- void includeSiteInAssembly( Assembly assembly, AssemblerConfigurationSource configSource )
- throws MojoFailureException, InvalidAssemblerConfigurationException;
+ Assembly getAssemblyFromDescriptorFile(File file, AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException;
+ void includeSiteInAssembly(Assembly assembly, AssemblerConfigurationSource configSource)
+ throws MojoFailureException, InvalidAssemblerConfigurationException;
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/ClasspathResourceLocatorStrategy.java b/src/main/java/org/apache/maven/plugins/assembly/io/ClasspathResourceLocatorStrategy.java
index 7d65decb..99f8bdcc 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/ClasspathResourceLocatorStrategy.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/ClasspathResourceLocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +16,14 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
import java.net.URL;
/**
* classpath resource locator strategy.
*/
-class ClasspathResourceLocatorStrategy
- implements LocatorStrategy
-{
+class ClasspathResourceLocatorStrategy implements LocatorStrategy {
private String tempFilePrefix = "location.";
@@ -37,31 +34,24 @@ class ClasspathResourceLocatorStrategy
/**
* Create instance.
*/
- ClasspathResourceLocatorStrategy()
- {
- }
+ ClasspathResourceLocatorStrategy() {}
/** {@inheritDoc} */
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- URL resource = cloader.getResource( locationSpecification );
+ URL resource = cloader.getResource(locationSpecification);
Location location = null;
- if ( resource != null )
- {
- location = new URLLocation( resource, locationSpecification, tempFilePrefix, tempFileSuffix,
- tempFileDeleteOnExit );
- }
- else
- {
- messageHolder.addMessage( "Failed to resolve classpath resource: " + locationSpecification
- + " from classloader: " + cloader );
+ if (resource != null) {
+ location = new URLLocation(
+ resource, locationSpecification, tempFilePrefix, tempFileSuffix, tempFileDeleteOnExit);
+ } else {
+ messageHolder.addMessage(
+ "Failed to resolve classpath resource: " + locationSpecification + " from classloader: " + cloader);
}
return location;
}
-
}
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 e41199e7..b2f0388b 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
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +16,23 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
import javax.inject.Named;
import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
@@ -52,49 +63,34 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
*
*/
@Singleton
@Named
-public class DefaultAssemblyReader implements AssemblyReader
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultAssemblyReader.class );
+public class DefaultAssemblyReader implements AssemblyReader {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAssemblyReader.class);
- public static FixedStringSearchInterpolator createProjectInterpolator( MavenProject project )
- {
+ public static FixedStringSearchInterpolator createProjectInterpolator(MavenProject project) {
// CHECKSTYLE_OFF: LineLength
- return FixedStringSearchInterpolator.create( new PrefixedPropertiesValueSource( InterpolationConstants.PROJECT_PROPERTIES_PREFIXES,
- project.getProperties(), true ),
- new PrefixedObjectValueSource( InterpolationConstants.PROJECT_PREFIXES,
- project, true ) );
+ return FixedStringSearchInterpolator.create(
+ new PrefixedPropertiesValueSource(
+ InterpolationConstants.PROJECT_PROPERTIES_PREFIXES, project.getProperties(), true),
+ new PrefixedObjectValueSource(InterpolationConstants.PROJECT_PREFIXES, project, true));
// CHECKSTYLE_ON: LineLength
}
@Override
- public List<Assembly> readAssemblies( final AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException
- {
+ public List<Assembly> readAssemblies(final AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
final Locator locator = new Locator();
final List<LocatorStrategy> strategies = new ArrayList<>();
- strategies.add( new RelativeFileLocatorStrategy( configSource.getBasedir() ) );
- strategies.add( new FileLocatorStrategy() );
+ strategies.add(new RelativeFileLocatorStrategy(configSource.getBasedir()));
+ strategies.add(new FileLocatorStrategy());
final List<LocatorStrategy> refStrategies = new ArrayList<>();
- refStrategies.add( new PrefixedClasspathLocatorStrategy( "/assemblies/" ) );
+ refStrategies.add(new PrefixedClasspathLocatorStrategy("/assemblies/"));
final List<Assembly> assemblies = new ArrayList<>();
@@ -102,263 +98,211 @@ public class DefaultAssemblyReader implements AssemblyReader
final String[] descriptorRefs = configSource.getDescriptorReferences();
final File descriptorSourceDirectory = configSource.getDescriptorSourceDirectory();
- if ( ( descriptors != null ) && ( descriptors.length > 0 ) )
- {
- locator.setStrategies( strategies );
- for ( String descriptor1 : descriptors )
- {
- LOGGER.info( "Reading assembly descriptor: " + descriptor1 );
- addAssemblyFromDescriptor( descriptor1, locator, configSource, assemblies );
+ if ((descriptors != null) && (descriptors.length > 0)) {
+ locator.setStrategies(strategies);
+ for (String descriptor1 : descriptors) {
+ LOGGER.info("Reading assembly descriptor: " + descriptor1);
+ addAssemblyFromDescriptor(descriptor1, locator, configSource, assemblies);
}
}
- if ( ( descriptorRefs != null ) && ( descriptorRefs.length > 0 ) )
- {
- locator.setStrategies( refStrategies );
- for ( String descriptorRef : descriptorRefs )
- {
- addAssemblyForDescriptorReference( descriptorRef, configSource, assemblies );
+ if ((descriptorRefs != null) && (descriptorRefs.length > 0)) {
+ locator.setStrategies(refStrategies);
+ for (String descriptorRef : descriptorRefs) {
+ addAssemblyForDescriptorReference(descriptorRef, configSource, assemblies);
}
}
- if ( ( descriptorSourceDirectory != null ) && descriptorSourceDirectory.isDirectory() )
- {
+ if ((descriptorSourceDirectory != null) && descriptorSourceDirectory.isDirectory()) {
// CHECKSTYLE_OFF: LineLength
- locator.setStrategies( Collections.<LocatorStrategy>singletonList( new RelativeFileLocatorStrategy( descriptorSourceDirectory ) ) );
+ locator.setStrategies(Collections.<LocatorStrategy>singletonList(
+ new RelativeFileLocatorStrategy(descriptorSourceDirectory)));
// CHECKSTYLE_ON: LineLength
final DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir( descriptorSourceDirectory );
- scanner.setIncludes( new String[] { "**/*.xml" } );
+ scanner.setBasedir(descriptorSourceDirectory);
+ scanner.setIncludes(new String[] {"**/*.xml"});
scanner.addDefaultExcludes();
scanner.scan();
final String[] paths = scanner.getIncludedFiles();
- for ( String path : paths )
- {
- addAssemblyFromDescriptor( path, locator, configSource, assemblies );
+ for (String path : paths) {
+ addAssemblyFromDescriptor(path, locator, configSource, assemblies);
}
}
- if ( assemblies.isEmpty() )
- {
- if ( configSource.isIgnoreMissingDescriptor() )
- {
- LOGGER.debug( "Ignoring missing assembly descriptors per configuration. "
- + "See messages above for specifics." );
- }
- else
- {
- throw new AssemblyReadException( "No assembly descriptors found." );
+ if (assemblies.isEmpty()) {
+ if (configSource.isIgnoreMissingDescriptor()) {
+ LOGGER.debug("Ignoring missing assembly descriptors per configuration. "
+ + "See messages above for specifics.");
+ } else {
+ throw new AssemblyReadException("No assembly descriptors found.");
}
}
// check unique IDs
final Set<String> ids = new HashSet<>();
- for ( final Assembly assembly : assemblies )
- {
- if ( !ids.add( assembly.getId() ) )
- {
- LOGGER.warn( "The assembly id " + assembly.getId() + " is used more than once." );
+ for (final Assembly assembly : assemblies) {
+ if (!ids.add(assembly.getId())) {
+ LOGGER.warn("The assembly id " + assembly.getId() + " is used more than once.");
}
-
}
return assemblies;
}
@Override
- public Assembly getAssemblyForDescriptorReference( final String ref,
- final AssemblerConfigurationSource configSource )
- throws AssemblyReadException,
- InvalidAssemblerConfigurationException
- {
- return addAssemblyForDescriptorReference( ref, configSource, new ArrayList<Assembly>( 1 ) );
+ public Assembly getAssemblyForDescriptorReference(final String ref, final AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
+ return addAssemblyForDescriptorReference(ref, configSource, new ArrayList<Assembly>(1));
}
@Override
- public Assembly getAssemblyFromDescriptorFile( final File file, final AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException
- {
- return addAssemblyFromDescriptorFile( file, configSource, new ArrayList<Assembly>( 1 ) );
+ public Assembly getAssemblyFromDescriptorFile(final File file, final AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
+ return addAssemblyFromDescriptorFile(file, configSource, new ArrayList<Assembly>(1));
}
- private Assembly addAssemblyForDescriptorReference( final String ref,
- final AssemblerConfigurationSource configSource,
- final List<Assembly> assemblies )
- throws AssemblyReadException,
- InvalidAssemblerConfigurationException
- {
- final InputStream resourceAsStream = getClass().getResourceAsStream( "/assemblies/" + ref + ".xml" );
-
- if ( resourceAsStream == null )
- {
- if ( configSource.isIgnoreMissingDescriptor() )
- {
- LOGGER.debug( "Ignoring missing assembly descriptor with ID '" + ref + "' per configuration." );
+ private Assembly addAssemblyForDescriptorReference(
+ final String ref, final AssemblerConfigurationSource configSource, final List<Assembly> assemblies)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
+ final InputStream resourceAsStream = getClass().getResourceAsStream("/assemblies/" + ref + ".xml");
+
+ if (resourceAsStream == null) {
+ if (configSource.isIgnoreMissingDescriptor()) {
+ LOGGER.debug("Ignoring missing assembly descriptor with ID '" + ref + "' per configuration.");
return null;
- }
- else
- {
- throw new AssemblyReadException( "Descriptor with ID '" + ref + "' not found" );
+ } else {
+ throw new AssemblyReadException("Descriptor with ID '" + ref + "' not found");
}
}
- try ( Reader reader = new XmlStreamReader( resourceAsStream ) )
- {
- final Assembly assembly = readAssembly( reader, ref, null, configSource );
- assemblies.add( assembly );
+ try (Reader reader = new XmlStreamReader(resourceAsStream)) {
+ final Assembly assembly = readAssembly(reader, ref, null, configSource);
+ assemblies.add(assembly);
return assembly;
- }
- catch ( final IOException e )
- {
- throw new AssemblyReadException( "Problem with descriptor with ID '" + ref + "'", e );
+ } catch (final IOException e) {
+ throw new AssemblyReadException("Problem with descriptor with ID '" + ref + "'", e);
}
}
- private Assembly addAssemblyFromDescriptorFile( final File descriptor,
- final AssemblerConfigurationSource configSource,
- final List<Assembly> assemblies )
- throws AssemblyReadException,
- InvalidAssemblerConfigurationException
- {
- if ( !descriptor.exists() )
- {
- if ( configSource.isIgnoreMissingDescriptor() )
- {
- LOGGER.debug( "Ignoring missing assembly descriptor: '" + descriptor + "' per configuration." );
+ private Assembly addAssemblyFromDescriptorFile(
+ final File descriptor, final AssemblerConfigurationSource configSource, final List<Assembly> assemblies)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
+ if (!descriptor.exists()) {
+ if (configSource.isIgnoreMissingDescriptor()) {
+ LOGGER.debug("Ignoring missing assembly descriptor: '" + descriptor + "' per configuration.");
return null;
- }
- else
- {
- throw new AssemblyReadException( "Descriptor: '" + descriptor + "' not found" );
+ } else {
+ throw new AssemblyReadException("Descriptor: '" + descriptor + "' not found");
}
}
- try ( Reader r = new XmlStreamReader( descriptor ) )
- {
+ try (Reader r = new XmlStreamReader(descriptor)) {
final Assembly assembly =
- readAssembly( r, descriptor.getAbsolutePath(), descriptor.getParentFile(), configSource );
+ readAssembly(r, descriptor.getAbsolutePath(), descriptor.getParentFile(), configSource);
- assemblies.add( assembly );
+ assemblies.add(assembly);
return assembly;
- }
- catch ( final IOException e )
- {
- throw new AssemblyReadException( "Error reading assembly descriptor: " + descriptor, e );
+ } catch (final IOException e) {
+ throw new AssemblyReadException("Error reading assembly descriptor: " + descriptor, e);
}
}
- private Assembly addAssemblyFromDescriptor( final String spec, final Locator locator,
- final AssemblerConfigurationSource configSource,
- final List<Assembly> assemblies )
- throws AssemblyReadException, InvalidAssemblerConfigurationException
- {
- final Location location = locator.resolve( spec );
-
- if ( location == null )
- {
- if ( configSource.isIgnoreMissingDescriptor() )
- {
- LOGGER.debug( "Ignoring missing assembly descriptor with ID '" + spec
- + "' per configuration.\nLocator output was:\n\n" + locator.getMessageHolder().render() );
+ private Assembly addAssemblyFromDescriptor(
+ final String spec,
+ final Locator locator,
+ final AssemblerConfigurationSource configSource,
+ final List<Assembly> assemblies)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
+ final Location location = locator.resolve(spec);
+
+ if (location == null) {
+ if (configSource.isIgnoreMissingDescriptor()) {
+ LOGGER.debug("Ignoring missing assembly descriptor with ID '" + spec
+ + "' per configuration.\nLocator output was:\n\n"
+ + locator.getMessageHolder().render());
return null;
- }
- else
- {
- throw new AssemblyReadException( "Error locating assembly descriptor: " + spec + "\n\n"
- + locator.getMessageHolder().render() );
+ } else {
+ throw new AssemblyReadException("Error locating assembly descriptor: " + spec + "\n\n"
+ + locator.getMessageHolder().render());
}
}
-
- try ( Reader r = new XmlStreamReader( location.getInputStream() ) )
- {
+ try (Reader r = new XmlStreamReader(location.getInputStream())) {
File dir = null;
- if ( location.getFile() != null )
- {
+ if (location.getFile() != null) {
dir = location.getFile().getParentFile();
}
- final Assembly assembly = readAssembly( r, spec, dir, configSource );
+ final Assembly assembly = readAssembly(r, spec, dir, configSource);
- assemblies.add( assembly );
+ assemblies.add(assembly);
return assembly;
- }
- catch ( final IOException e )
- {
- throw new AssemblyReadException( "Error reading assembly descriptor: " + spec, e );
+ } catch (final IOException e) {
+ throw new AssemblyReadException("Error reading assembly descriptor: " + spec, e);
}
}
- public Assembly readAssembly( Reader reader, final String locationDescription, final File assemblyDir,
- final AssemblerConfigurationSource configSource )
- throws AssemblyReadException, InvalidAssemblerConfigurationException
- {
+ public Assembly readAssembly(
+ Reader reader,
+ final String locationDescription,
+ final File assemblyDir,
+ final AssemblerConfigurationSource configSource)
+ throws AssemblyReadException, InvalidAssemblerConfigurationException {
Assembly assembly;
final MavenProject project = configSource.getProject();
- try
- {
+ try {
InterpolationState is = new InterpolationState();
final RecursionInterceptor interceptor =
- new PrefixAwareRecursionInterceptor( InterpolationConstants.PROJECT_PREFIXES, true );
- is.setRecursionInterceptor( interceptor );
+ new PrefixAwareRecursionInterceptor(InterpolationConstants.PROJECT_PREFIXES, true);
+ is.setRecursionInterceptor(interceptor);
FixedStringSearchInterpolator interpolator =
- AssemblyInterpolator.fullInterpolator( project, createProjectInterpolator( project ), configSource );
+ AssemblyInterpolator.fullInterpolator(project, createProjectInterpolator(project), configSource);
AssemblyXpp3Reader.ContentTransformer transformer =
- AssemblyInterpolator.assemblyInterpolator( interpolator, is, LOGGER );
+ AssemblyInterpolator.assemblyInterpolator(interpolator, is, LOGGER);
- final AssemblyXpp3Reader r = new AssemblyXpp3Reader( transformer );
- assembly = r.read( reader );
+ final AssemblyXpp3Reader r = new AssemblyXpp3Reader(transformer);
+ assembly = r.read(reader);
ComponentXpp3Reader.ContentTransformer ctrans =
- AssemblyInterpolator.componentInterpolator( interpolator, is, LOGGER );
- mergeComponentsWithMainAssembly( assembly, assemblyDir, configSource, ctrans );
- debugPrintAssembly( "After assembly is interpolated:", assembly );
+ AssemblyInterpolator.componentInterpolator(interpolator, is, LOGGER);
+ mergeComponentsWithMainAssembly(assembly, assemblyDir, configSource, ctrans);
+ debugPrintAssembly("After assembly is interpolated:", assembly);
- AssemblyInterpolator.checkErrors( AssemblyId.createAssemblyId( assembly ), is, LOGGER );
+ AssemblyInterpolator.checkErrors(AssemblyId.createAssemblyId(assembly), is, LOGGER);
reader.close();
reader = null;
- }
- catch ( final IOException | XmlPullParserException e )
- {
- throw new AssemblyReadException( "Error reading descriptor: " + locationDescription + ": " + e.getMessage(),
- e );
- }
- finally
- {
- IOUtil.close( reader );
+ } catch (final IOException | XmlPullParserException e) {
+ throw new AssemblyReadException(
+ "Error reading descriptor: " + locationDescription + ": " + e.getMessage(), e);
+ } finally {
+ IOUtil.close(reader);
}
- if ( assembly.isIncludeSiteDirectory() )
- {
- includeSiteInAssembly( assembly, configSource );
+ if (assembly.isIncludeSiteDirectory()) {
+ includeSiteInAssembly(assembly, configSource);
}
return assembly;
}
- private void debugPrintAssembly( final String message, final Assembly assembly )
- {
+ private void debugPrintAssembly(final String message, final Assembly assembly) {
final StringWriter sWriter = new StringWriter();
- try
- {
- new AssemblyXpp3Writer().write( sWriter, assembly );
- }
- catch ( final IOException e )
- {
- LOGGER.debug( "Failed to print debug message with assembly descriptor listing, and message: "
- + message, e );
+ try {
+ new AssemblyXpp3Writer().write(sWriter, assembly);
+ } catch (final IOException e) {
+ LOGGER.debug("Failed to print debug message with assembly descriptor listing, and message: " + message, e);
}
- LOGGER.debug( message + "\n\n" + sWriter.toString() + "\n\n" );
+ LOGGER.debug(message + "\n\n" + sWriter.toString() + "\n\n");
}
/**
@@ -369,58 +313,52 @@ public class DefaultAssemblyReader implements AssemblyReader
* @param transformer the component interpolator
* @throws AssemblyReadException
*/
- protected void mergeComponentsWithMainAssembly( final Assembly assembly, final File assemblyDir,
- final AssemblerConfigurationSource configSource,
- ComponentXpp3Reader.ContentTransformer transformer )
- throws AssemblyReadException
- {
+ protected void mergeComponentsWithMainAssembly(
+ final Assembly assembly,
+ final File assemblyDir,
+ final AssemblerConfigurationSource configSource,
+ ComponentXpp3Reader.ContentTransformer transformer)
+ throws AssemblyReadException {
final Locator locator = new Locator();
- if ( assemblyDir != null && assemblyDir.exists() && assemblyDir.isDirectory() )
- {
- locator.addStrategy( new RelativeFileLocatorStrategy( assemblyDir ) );
+ if (assemblyDir != null && assemblyDir.exists() && assemblyDir.isDirectory()) {
+ locator.addStrategy(new RelativeFileLocatorStrategy(assemblyDir));
}
// allow absolute paths in componentDescriptor... MASSEMBLY-486
- locator.addStrategy( new RelativeFileLocatorStrategy( configSource.getBasedir() ) );
- locator.addStrategy( new FileLocatorStrategy() );
- locator.addStrategy( new ClasspathResourceLocatorStrategy() );
+ locator.addStrategy(new RelativeFileLocatorStrategy(configSource.getBasedir()));
+ locator.addStrategy(new FileLocatorStrategy());
+ locator.addStrategy(new ClasspathResourceLocatorStrategy());
- final AssemblyExpressionEvaluator aee = new AssemblyExpressionEvaluator( configSource );
+ final AssemblyExpressionEvaluator aee = new AssemblyExpressionEvaluator(configSource);
final List<String> componentLocations = assembly.getComponentDescriptors();
- for ( String location : componentLocations )
- {
+ for (String location : componentLocations) {
// allow expressions in path to component descriptor... MASSEMBLY-486
- try
- {
- location = aee.evaluate( location ).toString();
- }
- catch ( final Exception eee )
- {
- LOGGER.error( "Error interpolating componentDescriptor: " + location, eee );
+ try {
+ location = aee.evaluate(location).toString();
+ } catch (final Exception eee) {
+ LOGGER.error("Error interpolating componentDescriptor: " + location, eee);
}
- final Location resolvedLocation = locator.resolve( location );
+ final Location resolvedLocation = locator.resolve(location);
- if ( resolvedLocation == null )
- {
- throw new AssemblyReadException( "Failed to locate component descriptor: " + location );
+ if (resolvedLocation == null) {
+ throw new AssemblyReadException("Failed to locate component descriptor: " + location);
}
Component component = null;
- try ( Reader reader = new InputStreamReader( resolvedLocation.getInputStream() ) )
- {
- component = new ComponentXpp3Reader( transformer ).read( reader );
- }
- catch ( final IOException | XmlPullParserException e )
- {
- throw new AssemblyReadException( "Error reading component descriptor: " + location + " (resolved to: "
- + resolvedLocation.getSpecification() + ")", e );
+ try (Reader reader = new InputStreamReader(resolvedLocation.getInputStream())) {
+ component = new ComponentXpp3Reader(transformer).read(reader);
+ } catch (final IOException | XmlPullParserException e) {
+ throw new AssemblyReadException(
+ "Error reading component descriptor: " + location + " (resolved to: "
+ + resolvedLocation.getSpecification() + ")",
+ e);
}
- mergeComponentWithAssembly( component, assembly );
+ mergeComponentWithAssembly(component, assembly);
}
}
@@ -430,64 +368,56 @@ public class DefaultAssemblyReader implements AssemblyReader
* @param component The component
* @param assembly The assembly
*/
- protected void mergeComponentWithAssembly( final Component component, final Assembly assembly )
- {
+ protected void mergeComponentWithAssembly(final Component component, final Assembly assembly) {
final List<ContainerDescriptorHandlerConfig> containerHandlerDescriptors =
- component.getContainerDescriptorHandlers();
+ component.getContainerDescriptorHandlers();
- for ( final ContainerDescriptorHandlerConfig cfg : containerHandlerDescriptors )
- {
- assembly.addContainerDescriptorHandler( cfg );
+ for (final ContainerDescriptorHandlerConfig cfg : containerHandlerDescriptors) {
+ assembly.addContainerDescriptorHandler(cfg);
}
final List<DependencySet> dependencySetList = component.getDependencySets();
- for ( final DependencySet dependencySet : dependencySetList )
- {
- assembly.addDependencySet( dependencySet );
+ for (final DependencySet dependencySet : dependencySetList) {
+ assembly.addDependencySet(dependencySet);
}
final List<FileSet> fileSetList = component.getFileSets();
- for ( final FileSet fileSet : fileSetList )
- {
- assembly.addFileSet( fileSet );
+ for (final FileSet fileSet : fileSetList) {
+ assembly.addFileSet(fileSet);
}
final List<FileItem> fileList = component.getFiles();
- for ( final FileItem fileItem : fileList )
- {
- assembly.addFile( fileItem );
+ for (final FileItem fileItem : fileList) {
+ assembly.addFile(fileItem);
}
final List<ModuleSet> moduleSets = component.getModuleSets();
- for ( final ModuleSet moduleSet : moduleSets )
- {
- assembly.addModuleSet( moduleSet );
+ for (final ModuleSet moduleSet : moduleSets) {
+ assembly.addModuleSet(moduleSet);
}
}
@Override
- public void includeSiteInAssembly( final Assembly assembly, final AssemblerConfigurationSource configSource )
- throws InvalidAssemblerConfigurationException
- {
+ public void includeSiteInAssembly(final Assembly assembly, final AssemblerConfigurationSource configSource)
+ throws InvalidAssemblerConfigurationException {
final File siteDirectory = configSource.getSiteDirectory();
- if ( !siteDirectory.exists() )
- {
- throw new InvalidAssemblerConfigurationException( "site did not exist in the target directory - "
- + "please run site:site before creating the assembly" );
+ if (!siteDirectory.exists()) {
+ throw new InvalidAssemblerConfigurationException("site did not exist in the target directory - "
+ + "please run site:site before creating the assembly");
}
- LOGGER.info( "Adding site directory to assembly : " + siteDirectory );
+ LOGGER.info("Adding site directory to assembly : " + siteDirectory);
final FileSet siteFileSet = new FileSet();
- siteFileSet.setDirectory( siteDirectory.getPath() );
+ siteFileSet.setDirectory(siteDirectory.getPath());
- siteFileSet.setOutputDirectory( "/site" );
+ siteFileSet.setOutputDirectory("/site");
- assembly.addFileSet( siteFileSet );
+ assembly.addFileSet(siteFileSet);
}
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
index 5826f5df..de354f4b 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/DefaultMessageHolder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -29,9 +28,7 @@ import java.util.List;
* Default Message Holder.
*
*/
-class DefaultMessageHolder
- implements MessageHolder
-{
+class DefaultMessageHolder implements MessageHolder {
private List<Message> messages = new ArrayList<Message>();
@@ -46,15 +43,13 @@ class DefaultMessageHolder
/**
* Create instance.
*/
- DefaultMessageHolder()
- {
- this.messageLevelStates = MessageLevels.getLevelStates( MessageLevels.LEVEL_INFO );
+ DefaultMessageHolder() {
+ this.messageLevelStates = MessageLevels.getLevelStates(MessageLevels.LEVEL_INFO);
}
/** {@inheritDoc} */
- public MessageHolder addMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( defaultMessageLevel, messagePart, error );
+ public MessageHolder addMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(defaultMessageLevel, messagePart, error);
}
/**
@@ -63,19 +58,17 @@ class DefaultMessageHolder
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addMessage( int level, CharSequence messagePart, Throwable error )
- {
- newMessage( level );
- append( messagePart.toString() );
- append( error );
+ MessageHolder addMessage(int level, CharSequence messagePart, Throwable error) {
+ newMessage(level);
+ append(messagePart.toString());
+ append(error);
return this;
}
/** {@inheritDoc} */
- public MessageHolder addMessage( CharSequence messagePart )
- {
- return addMessage( defaultMessageLevel, messagePart );
+ public MessageHolder addMessage(CharSequence messagePart) {
+ return addMessage(defaultMessageLevel, messagePart);
}
/**
@@ -83,18 +76,16 @@ class DefaultMessageHolder
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- protected MessageHolder addMessage( int level, CharSequence messagePart )
- {
- newMessage( level );
- append( messagePart.toString() );
+ protected MessageHolder addMessage(int level, CharSequence messagePart) {
+ newMessage(level);
+ append(messagePart.toString());
return this;
}
/** {@inheritDoc} */
- public MessageHolder addMessage( Throwable error )
- {
- return addMessage( defaultMessageLevel, error );
+ public MessageHolder addMessage(Throwable error) {
+ return addMessage(defaultMessageLevel, error);
}
/**
@@ -102,50 +93,43 @@ class DefaultMessageHolder
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- protected MessageHolder addMessage( int level, Throwable error )
- {
- newMessage( level );
- append( error );
+ protected MessageHolder addMessage(int level, Throwable error) {
+ newMessage(level);
+ append(error);
return this;
}
/** {@inheritDoc} */
- public MessageHolder append( CharSequence messagePart )
- {
- if ( currentMessage == null )
- {
+ public MessageHolder append(CharSequence messagePart) {
+ if (currentMessage == null) {
newMessage();
}
- currentMessage.append( messagePart.toString() );
+ currentMessage.append(messagePart.toString());
return this;
}
/** {@inheritDoc} */
- public MessageHolder append( Throwable error )
- {
- if ( currentMessage == null )
- {
+ public MessageHolder append(Throwable error) {
+ if (currentMessage == null) {
newMessage();
}
- currentMessage.setError( error );
+ currentMessage.setError(error);
return this;
}
/** {@inheritDoc} */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return messages.isEmpty();
}
/** {@inheritDoc} */
- public MessageHolder newMessage()
- {
- newMessage( defaultMessageLevel );
+ public MessageHolder newMessage() {
+ newMessage(defaultMessageLevel);
return this;
}
@@ -153,50 +137,42 @@ class DefaultMessageHolder
/**
* @param messageLevel message level.
*/
- protected void newMessage( int messageLevel )
- {
- if ( onDemandSink != null && currentMessage != null )
- {
- renderTo( currentMessage, onDemandSink );
+ protected void newMessage(int messageLevel) {
+ if (onDemandSink != null && currentMessage != null) {
+ renderTo(currentMessage, onDemandSink);
}
- currentMessage = new Message( messageLevel, onDemandSink );
- messages.add( currentMessage );
+ currentMessage = new Message(messageLevel, onDemandSink);
+ messages.add(currentMessage);
}
/** {@inheritDoc} */
- public String render()
- {
+ public String render() {
StringBuffer buffer = new StringBuffer();
int counter = 1;
- for ( Iterator<Message> it = messages.iterator(); it.hasNext(); )
- {
+ for (Iterator<Message> it = messages.iterator(); it.hasNext(); ) {
Message message = (Message) it.next();
int ml = message.getMessageLevel();
- if ( ml >= messageLevelStates.length || ml < 0 )
- {
+ if (ml >= messageLevelStates.length || ml < 0) {
ml = MessageLevels.LEVEL_DEBUG;
}
- if ( !messageLevelStates[ml] )
- {
+ if (!messageLevelStates[ml]) {
continue;
}
CharSequence content = message.render();
- String label = MessageLevels.getLevelLabel( message.getMessageLevel() );
+ String label = MessageLevels.getLevelLabel(message.getMessageLevel());
- if ( content.length() > label.length() + 3 )
- {
- buffer.append( '[' ).append( counter++ ).append( "] " );
- buffer.append( content.toString() );
+ if (content.length() > label.length() + 3) {
+ buffer.append('[').append(counter++).append("] ");
+ buffer.append(content.toString());
- if ( it.hasNext() )
- {
- buffer.append( "\n\n" );
+ if (it.hasNext()) {
+ buffer.append("\n\n");
}
}
}
@@ -205,13 +181,11 @@ class DefaultMessageHolder
}
/** {@inheritDoc} */
- public int size()
- {
+ public int size() {
return messages.size();
}
- private static final class Message
- {
+ private static final class Message {
private StringBuffer message = new StringBuffer();
private Throwable error;
@@ -220,63 +194,56 @@ class DefaultMessageHolder
private final MessageSink onDemandSink;
- Message( int messageLevel, MessageSink onDemandSink )
- {
+ Message(int messageLevel, MessageSink onDemandSink) {
this.messageLevel = messageLevel;
this.onDemandSink = onDemandSink;
}
- public Message setError( Throwable pError )
- {
+ public Message setError(Throwable pError) {
this.error = pError;
return this;
}
- public Message append( CharSequence pMessage )
- {
- this.message.append( pMessage.toString() );
+ public Message append(CharSequence pMessage) {
+ this.message.append(pMessage.toString());
return this;
}
/**
* @return message level.
*/
- public int getMessageLevel()
- {
+ public int getMessageLevel() {
return messageLevel;
}
/**
* @return Sequence.
*/
- public CharSequence render()
- {
+ public CharSequence render() {
StringBuffer buffer = new StringBuffer();
- if ( onDemandSink == null )
- {
- buffer.append( '[' ).append( MessageLevels.getLevelLabel( messageLevel ) ).append( "] " );
+ if (onDemandSink == null) {
+ buffer.append('[')
+ .append(MessageLevels.getLevelLabel(messageLevel))
+ .append("] ");
}
- if ( message != null && message.length() > 0 )
- {
- buffer.append( message );
+ if (message != null && message.length() > 0) {
+ buffer.append(message);
- if ( error != null )
- {
- buffer.append( '\n' );
+ if (error != null) {
+ buffer.append('\n');
}
}
- if ( error != null )
- {
- buffer.append( "Error:\n" );
+ if (error != null) {
+ buffer.append("Error:\n");
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
- error.printStackTrace( pw );
+ PrintWriter pw = new PrintWriter(sw);
+ error.printStackTrace(pw);
- buffer.append( sw.toString() );
+ buffer.append(sw.toString());
}
return buffer;
@@ -284,143 +251,119 @@ class DefaultMessageHolder
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, messagePart, error );
+ public MessageHolder addDebugMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, messagePart );
+ public MessageHolder addDebugMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, error );
+ public MessageHolder addDebugMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, error);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, messagePart, error );
+ public MessageHolder addErrorMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_ERROR, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, messagePart );
+ public MessageHolder addErrorMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_ERROR, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, error );
+ public MessageHolder addErrorMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_ERROR, error);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_INFO, messagePart, error );
+ public MessageHolder addInfoMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_INFO, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_INFO, messagePart );
+ public MessageHolder addInfoMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_INFO, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_INFO, error );
+ public MessageHolder addInfoMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_INFO, error);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, messagePart, error );
+ public MessageHolder addSevereMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, messagePart );
+ public MessageHolder addSevereMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, error );
+ public MessageHolder addSevereMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, error);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, messagePart, error );
+ public MessageHolder addWarningMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_WARNING, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, messagePart );
+ public MessageHolder addWarningMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_WARNING, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, error );
+ public MessageHolder addWarningMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_WARNING, error);
}
/** {@inheritDoc} */
- public int countDebugMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_DEBUG );
+ public int countDebugMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_DEBUG);
}
/** {@inheritDoc} */
- public int countErrorMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_ERROR );
+ public int countErrorMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_ERROR);
}
/** {@inheritDoc} */
- public int countInfoMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_INFO );
+ public int countInfoMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_INFO);
}
/** {@inheritDoc} */
- public int countMessages()
- {
+ public int countMessages() {
return size();
}
/** {@inheritDoc} */
- public int countSevereMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_SEVERE );
+ public int countSevereMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_SEVERE);
}
/** {@inheritDoc} */
- public int countWarningMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_WARNING );
+ public int countWarningMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_WARNING);
}
/**
* @param messageLevel leve.
* @return number of messages.
*/
- private int countMessagesOfType( int messageLevel )
- {
+ private int countMessagesOfType(int messageLevel) {
int count = 0;
- for ( Message message : messages )
- {
- if ( messageLevel == message.getMessageLevel() )
- {
+ for (Message message : messages) {
+ if (messageLevel == message.getMessageLevel()) {
count++;
}
}
@@ -429,136 +372,112 @@ class DefaultMessageHolder
}
/** {@inheritDoc} */
- public boolean isDebugEnabled()
- {
+ public boolean isDebugEnabled() {
return messageLevelStates[MessageLevels.LEVEL_DEBUG];
}
/** {@inheritDoc} */
- public boolean isErrorEnabled()
- {
+ public boolean isErrorEnabled() {
return messageLevelStates[MessageLevels.LEVEL_ERROR];
}
/** {@inheritDoc} */
- public boolean isInfoEnabled()
- {
+ public boolean isInfoEnabled() {
return messageLevelStates[MessageLevels.LEVEL_INFO];
}
/** {@inheritDoc} */
- public boolean isSevereEnabled()
- {
+ public boolean isSevereEnabled() {
return messageLevelStates[MessageLevels.LEVEL_SEVERE];
}
/** {@inheritDoc} */
- public boolean isWarningEnabled()
- {
+ public boolean isWarningEnabled() {
return messageLevelStates[MessageLevels.LEVEL_WARNING];
}
/** {@inheritDoc} */
- public MessageHolder newDebugMessage()
- {
- if ( isDebugEnabled() )
- {
- newMessage( MessageLevels.LEVEL_DEBUG );
+ public MessageHolder newDebugMessage() {
+ if (isDebugEnabled()) {
+ newMessage(MessageLevels.LEVEL_DEBUG);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newErrorMessage()
- {
- if ( isErrorEnabled() )
- {
- newMessage( MessageLevels.LEVEL_ERROR );
+ public MessageHolder newErrorMessage() {
+ if (isErrorEnabled()) {
+ newMessage(MessageLevels.LEVEL_ERROR);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newInfoMessage()
- {
- if ( isInfoEnabled() )
- {
- newMessage( MessageLevels.LEVEL_INFO );
+ public MessageHolder newInfoMessage() {
+ if (isInfoEnabled()) {
+ newMessage(MessageLevels.LEVEL_INFO);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newSevereMessage()
- {
- if ( isSevereEnabled() )
- {
- newMessage( MessageLevels.LEVEL_SEVERE );
+ public MessageHolder newSevereMessage() {
+ if (isSevereEnabled()) {
+ newMessage(MessageLevels.LEVEL_SEVERE);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newWarningMessage()
- {
- if ( isWarningEnabled() )
- {
- newMessage( MessageLevels.LEVEL_WARNING );
+ public MessageHolder newWarningMessage() {
+ if (isWarningEnabled()) {
+ newMessage(MessageLevels.LEVEL_WARNING);
}
return this;
}
/** {@inheritDoc} */
- public void setDebugEnabled( boolean enabled )
- {
+ public void setDebugEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_DEBUG] = enabled;
}
/** {@inheritDoc} */
- public void setErrorEnabled( boolean enabled )
- {
+ public void setErrorEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_ERROR] = enabled;
}
/** {@inheritDoc} */
- public void setInfoEnabled( boolean enabled )
- {
+ public void setInfoEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_INFO] = enabled;
}
/** {@inheritDoc} */
- public void setSevereEnabled( boolean enabled )
- {
+ public void setSevereEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_SEVERE] = enabled;
}
/** {@inheritDoc} */
- public void setWarningEnabled( boolean enabled )
- {
+ public void setWarningEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_WARNING] = enabled;
}
/** {@inheritDoc} */
- public void flush()
- {
- if ( onDemandSink != null && currentMessage != null )
- {
- renderTo( currentMessage, onDemandSink );
+ public void flush() {
+ if (onDemandSink != null && currentMessage != null) {
+ renderTo(currentMessage, onDemandSink);
currentMessage = null;
}
}
/** {@inheritDoc} */
- public void render( MessageSink sink )
- {
- for ( Message message : messages )
- {
- renderTo( message, sink );
+ public void render(MessageSink sink) {
+ for (Message message : messages) {
+ renderTo(message, sink);
}
}
@@ -566,29 +485,26 @@ class DefaultMessageHolder
* @param message {@link Message}
* @param sink {@link MessageSink}
*/
- protected void renderTo( Message message, MessageSink sink )
- {
- switch ( message.getMessageLevel() )
- {
- case ( MessageLevels.LEVEL_SEVERE ):
- sink.severe( message.render().toString() );
+ protected void renderTo(Message message, MessageSink sink) {
+ switch (message.getMessageLevel()) {
+ case (MessageLevels.LEVEL_SEVERE):
+ sink.severe(message.render().toString());
break;
- case ( MessageLevels.LEVEL_ERROR ):
- sink.error( message.render().toString() );
+ case (MessageLevels.LEVEL_ERROR):
+ sink.error(message.render().toString());
break;
- case ( MessageLevels.LEVEL_WARNING ):
- sink.warning( message.render().toString() );
+ case (MessageLevels.LEVEL_WARNING):
+ sink.warning(message.render().toString());
break;
- case ( MessageLevels.LEVEL_INFO ):
- sink.info( message.render().toString() );
+ case (MessageLevels.LEVEL_INFO):
+ sink.info(message.render().toString());
break;
default:
- sink.debug( message.render().toString() );
+ sink.debug(message.render().toString());
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java b/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java
index 02e66047..ecebc33b 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.assembly.io;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.assembly.io;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.assembly.io;
import java.io.File;
import java.io.FileInputStream;
@@ -26,14 +25,11 @@ import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
-
/**
* file location implementation.
*
*/
-class FileLocation
- implements Location
-{
+class FileLocation implements Location {
private File file;
private FileChannel channel;
@@ -44,8 +40,7 @@ class FileLocation
* @param file {@link File}
* @param specification spec
*/
- FileLocation( File file, String specification )
- {
+ FileLocation(File file, String specification) {
this.file = file;
this.specification = specification;
}
@@ -53,43 +48,31 @@ class FileLocation
/**
* @param specification spec
*/
- FileLocation( String specification )
- {
+ FileLocation(String specification) {
this.specification = specification;
}
@Override
- public void close()
- {
- if ( ( channel != null ) && channel.isOpen() )
- {
- try
- {
+ public void close() {
+ if ((channel != null) && channel.isOpen()) {
+ try {
channel.close();
- }
- catch ( IOException e )
- {
- //swallow it.
+ } catch (IOException e) {
+ // swallow it.
}
}
- if ( stream != null )
- {
- try
- {
+ if (stream != null) {
+ try {
stream.close();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// swallow it.
}
}
}
@Override
- public File getFile()
- throws IOException
- {
+ public File getFile() throws IOException {
initFile();
return unsafeGetFile();
@@ -98,8 +81,7 @@ class FileLocation
/**
* @return {@link File}
*/
- File unsafeGetFile()
- {
+ File unsafeGetFile() {
return file;
}
@@ -107,69 +89,53 @@ class FileLocation
* initialize file.
* @throws IOException in case of error
*/
- protected void initFile()
- throws IOException
- {
... 16001 lines suppressed ...