You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2014/10/23 23:01:38 UTC
svn commit: r1633948 [18/21] - in /maven/plugins/branches/MASSEMBLY-704: ./
integration-test-archetype/
integration-test-archetype/src/main/resources/META-INF/maven/
integration-test-archetype/src/main/resources/archetype-resources/
integration-test-ar...
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java Thu Oct 23 21:01:23 2014
@@ -44,6 +44,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.shared.filtering.MavenFileFilter;
+import org.apache.maven.shared.filtering.MavenReaderFilter;
import org.codehaus.plexus.configuration.PlexusConfiguration;
/**
@@ -60,7 +61,7 @@ public abstract class AbstractAssemblyMo
* The character encoding scheme to be applied when filtering resources.
*/
@Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
- protected String encoding;
+ private String encoding;
/**
* Expressions preceded with this String won't be interpolated.
@@ -69,7 +70,7 @@ public abstract class AbstractAssemblyMo
* @since 2.4
*/
@Parameter( property = "assembly.escapeString" )
- protected String escapeString;
+ private String escapeString;
/**
* Flag allowing one or more executions of the assembly plugin to be configured as skipped for a particular build.
@@ -130,14 +131,15 @@ public abstract class AbstractAssemblyMo
/**
* Specifies the formats of the assembly.
* Multiple formats can be supplied and the Assembly Plugin will generate an archive for each desired formats.
- * When deploying your project, all file formats specified will also be deployed. A format is specified by supplying one of the following
+ * When deploying your project, all file formats specified will also be deployed. A format is specified by supplying
+ * one of the following
* values in a <format> subelement:
* <ul>
* <li><em>dir</em> - Creates a directory</li>
* <li><em>zip</em> - Creates a ZIP file format</li>
* <li><em>tar</em> - Creates a TAR format</li>
- * <li><em>tar.gz</em> - Creates a gzip'd TAR format</li>
- * <li><em>tar.bz2</em> - Creates a bzip'd TAR format</li>
+ * <li><em>tar.gz</em> or <em>tgz</em> - Creates a gzip'd TAR format</li>
+ * <li><em>tar.bz2</em> or <em>tbz2</em> - Creates a bzip'd TAR format</li>
* </ul>
*/
@Parameter
@@ -161,8 +163,7 @@ public abstract class AbstractAssemblyMo
/**
* A list of references to assembly descriptors available on the plugin's classpath. The default classpath
- * includes these built-in descriptors: <code>bin</code>,
- * <code>jar-with-dependencies</code>, <code>src</code>, and
+ * includes these built-in descriptors: <code>bin</code>, <code>jar-with-dependencies</code>, <code>src</code>, and
* <code>project</code>. You can add others by adding dependencies
* to the plugin.
*/
@@ -189,7 +190,7 @@ public abstract class AbstractAssemblyMo
*/
@Deprecated
@Parameter( property = "descriptorId" )
- protected String descriptorId;
+ private String descriptorId;
/**
* Assembly XML Descriptor file. This must be the path to your customized descriptor file.
@@ -198,11 +199,11 @@ public abstract class AbstractAssemblyMo
*/
@Deprecated
@Parameter( property = "descriptor" )
- protected String descriptor;
+ private String descriptor;
/**
* Sets the TarArchiver behavior on file paths with more than 100 characters length. Valid values are: "warn"
- * (default), "fail", "truncate", "gnu", or "omit".
+ * (default), "fail", "truncate", "gnu", "posix", "posix_warn" or "omit".
*/
@Parameter( property = "assembly.tarLongFileMode", defaultValue = "warn" )
private String tarLongFileMode;
@@ -226,6 +227,12 @@ public abstract class AbstractAssemblyMo
private MavenFileFilter mavenFileFilter;
/**
+ * Maven shared filtering utility.
+ */
+ @Component
+ private MavenReaderFilter mavenReaderFilter;
+
+ /**
* The Maven Session Object
*/
@Parameter( defaultValue = "${session}", readonly = true, required = true )
@@ -256,13 +263,13 @@ public abstract class AbstractAssemblyMo
* Set to false to exclude the assembly id from the assembly final name.
*/
@Parameter( property = "assembly.appendAssemblyId", defaultValue = "true" )
- protected boolean appendAssemblyId;
+ boolean appendAssemblyId;
/**
* Set to true in order to not fail when a descriptor is missing.
*/
@Parameter( property = "assembly.ignoreMissingDescriptor", defaultValue = "false" )
- protected boolean ignoreMissingDescriptor;
+ private boolean ignoreMissingDescriptor;
/**
* This is a set of instructions to the archive builder, especially for building .jar files. It enables you to
@@ -275,13 +282,21 @@ public abstract class AbstractAssemblyMo
/**
* The list of extra filter properties files to be used along with System properties, project
* properties, and filter properties files specified in the POM build/filters section, which
- * should be used for the filtering during the current mojo execution.
- * <br/>
+ * should be used for the filtering during the current mojo execution. <br/>
* Normally, these will be configured from a plugin's execution section, to provide a different
* set of filters for a particular execution.
*/
@Parameter
- protected List<String> filters;
+ private List<String> filters;
+
+ /**
+ * If True (default) then the ${project.build.filters} are also used in addition to any
+ * further filters defined for the Assembly.
+ *
+ * @since 2.4.2
+ */
+ @Parameter( property = "assembly.includeProjectBuildFilters", defaultValue = "true" )
+ private boolean includeProjectBuildFilters;
/**
* Controls whether the assembly plugin tries to attach the resulting assembly to the project.
@@ -317,6 +332,7 @@ public abstract class AbstractAssemblyMo
* For instance, to direct an assembly with the "ear" format to use a particular deployment descriptor, you should
* specify the following for the archiverConfig value in your plugin configuration: <br/>
* <p/>
+ *
* <pre>
* <appxml>${project.basedir}/somepath/app.xml</appxml>
* </pre>
@@ -338,8 +354,8 @@ public abstract class AbstractAssemblyMo
/**
* This will cause the assembly to only update an existing archive, if it exists.
* <p>
- * <strong>Note:</strong> The property that can be used on the command line
- * was misspelled as "assembly.updatOnly" in versions prior to version 2.4.
+ * <strong>Note:</strong> The property that can be used on the command line was misspelled as "assembly.updatOnly"
+ * in versions prior to version 2.4.
* </p>
*
* @since 2.2
@@ -349,7 +365,8 @@ public abstract class AbstractAssemblyMo
/**
* <p>
- * will use the jvm chmod, this is available for user and all level group level will be ignored
+ * will use the jvm chmod, this is available for user and all level group level will be ignored As of
+ * assembly-plugin 2.5, this flag is ignored for users of java7+
* </p>
*
* @since 2.2
@@ -373,10 +390,33 @@ public abstract class AbstractAssemblyMo
private boolean ignorePermissions;
/**
+ * <p>
+ * Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form
+ * 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.
+ * </p>
+ * <p>
+ * So, the default filtering delimiters might be specified as:
+ * </p>
+ *
+ * <pre>
+ * <delimiters>
+ * <delimiter>${*}</delimiter>
+ * <delimiter>@</delimiter>
+ * </delimiters>
+ * </pre>
+ * <p>
+ * Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).
+ * </p>
+ *
+ * @since 2.4
+ */
+ @Parameter
+ private List<String> delimiters;
+
+ /**
* Create the binary distribution.
*
* @throws org.apache.maven.plugin.MojoExecutionException
- *
*/
public void execute()
throws MojoExecutionException, MojoFailureException
@@ -406,79 +446,98 @@ public abstract class AbstractAssemblyMo
catch ( final InvalidAssemblerConfigurationException e )
{
throw new MojoFailureException( assemblyReader, e.getMessage(), "Mojo configuration is invalid: "
- + e.getMessage() );
+ + e.getMessage() );
}
// TODO: include dependencies marked for distribution under certain formats
// TODO: how, might we plug this into an installer, such as NSIS?
boolean warnedAboutMainProjectArtifact = false;
- for (final Assembly assembly : assemblies) {
- try {
- final String fullName = AssemblyFormatUtils.getDistributionName(assembly, this);
+ for ( final Assembly assembly : assemblies )
+ {
+ try
+ {
+ final String fullName = AssemblyFormatUtils.getDistributionName( assembly, this );
List<String> effectiveFormats = formats;
- if (effectiveFormats == null || effectiveFormats.size() == 0) {
+ if ( effectiveFormats == null || effectiveFormats.size() == 0 )
+ {
effectiveFormats = assembly.getFormats();
}
- if (effectiveFormats == null || effectiveFormats.size() == 0) {
- throw new MojoFailureException("No formats specified in the execution parameters or the assembly descriptor.");
+ if ( effectiveFormats == null || effectiveFormats.size() == 0 )
+ {
+ throw new MojoFailureException(
+ "No formats specified in the execution parameters or the assembly descriptor." );
}
- for (final String format : effectiveFormats) {
+ for ( final String format : effectiveFormats )
+ {
final File destFile =
- assemblyArchiver.createArchive(assembly, fullName, format, this, isRecompressZippedFiles());
+ assemblyArchiver.createArchive( assembly, fullName, format, this, isRecompressZippedFiles() );
final MavenProject project = getProject();
final String classifier = getClassifier();
- final String type = project.getArtifact()
- .getType();
+ final String type = project.getArtifact().getType();
- if (attach && destFile.isFile()) {
- if (isAssemblyIdAppended()) {
- projectHelper.attachArtifact(project, format, assembly.getId(), destFile);
- } else if (classifier != null) {
- projectHelper.attachArtifact(project, format, classifier, destFile);
- } else if (!"pom".equals(type) && format.equals(type)) {
- if (!warnedAboutMainProjectArtifact) {
+ if ( attach && destFile.isFile() )
+ {
+ if ( isAssemblyIdAppended() )
+ {
+ projectHelper.attachArtifact( project, format, assembly.getId(), destFile );
+ }
+ else if ( classifier != null )
+ {
+ projectHelper.attachArtifact( project, format, classifier, destFile );
+ }
+ else if ( !"pom".equals( type ) && format.equals( type ) )
+ {
+ if ( !warnedAboutMainProjectArtifact )
+ {
final StringBuilder message = new StringBuilder();
- message.append("Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.");
- message.append("\nInstead of attaching the assembly file: ")
- .append(destFile)
- .append(", it will become the file for main project artifact.");
- message.append("\nNOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-deterministic!");
+ message.append( "Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing." );
+ message.append( "\nInstead of attaching the assembly file: " ).append( destFile ).append( ", it will become the file for main project artifact." );
+ message.append( "\nNOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-deterministic!" );
- getLog().warn(message);
+ getLog().warn( message );
warnedAboutMainProjectArtifact = true;
}
- final File existingFile = project.getArtifact()
- .getFile();
- if ((existingFile != null) && existingFile.exists()) {
- getLog().warn("Replacing pre-existing project main-artifact file: " + existingFile
- + "\nwith assembly file: " + destFile);
+ final File existingFile = project.getArtifact().getFile();
+ if ( ( existingFile != null ) && existingFile.exists() )
+ {
+ getLog().warn( "Replacing pre-existing project main-artifact file: " + existingFile
+ + "\nwith assembly file: " + destFile );
}
- project.getArtifact()
- .setFile(destFile);
- } else {
- projectHelper.attachArtifact(project, format, null, destFile);
+ project.getArtifact().setFile( destFile );
}
- } else if (attach) {
- getLog().warn("Assembly file: "
- + destFile
- + " is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.");
+ else
+ {
+ projectHelper.attachArtifact( project, format, null, destFile );
+ }
+ }
+ else if ( attach )
+ {
+ getLog().warn( "Assembly file: "
+ + destFile
+ + " is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment." );
}
}
- } catch (final ArchiveCreationException e) {
- throw new MojoExecutionException("Failed to create assembly: " + e.getMessage(), e);
- } catch (final AssemblyFormattingException e) {
- throw new MojoExecutionException("Failed to create assembly: " + e.getMessage(), e);
- } catch (final InvalidAssemblerConfigurationException e) {
- throw new MojoFailureException(assembly, "Assembly is incorrectly configured: " + assembly.getId(),
- "Assembly: " + assembly.getId() + " is not configured correctly: "
- + e.getMessage());
+ }
+ catch ( final ArchiveCreationException e )
+ {
+ throw new MojoExecutionException( "Failed to create assembly: " + e.getMessage(), e );
+ }
+ catch ( final AssemblyFormattingException e )
+ {
+ throw new MojoExecutionException( "Failed to create assembly: " + e.getMessage(), e );
+ }
+ catch ( final InvalidAssemblerConfigurationException e )
+ {
+ throw new MojoFailureException( assembly, "Assembly is incorrectly configured: " + assembly.getId(),
+ "Assembly: " + assembly.getId() + " is not configured correctly: "
+ + e.getMessage() );
}
}
}
@@ -486,15 +545,14 @@ public abstract class AbstractAssemblyMo
/**
* Returns true if the current project is located at the Execution Root Directory (where mvn was launched)
*
- * @return
+ * @return if this is the execution root
*/
- protected boolean isThisTheExecutionRoot()
+ boolean isThisTheExecutionRoot()
{
final Log log = getLog();
log.debug( "Root Folder:" + mavenSession.getExecutionRootDirectory() );
log.debug( "Current Folder:" + basedir );
- final boolean result = mavenSession.getExecutionRootDirectory()
- .equalsIgnoreCase( basedir.toString() );
+ final boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase( basedir.toString() );
if ( result )
{
log.debug( "This is the execution root." );
@@ -507,12 +565,12 @@ public abstract class AbstractAssemblyMo
return result;
}
- protected AssemblyArchiver getAssemblyArchiver()
+ AssemblyArchiver getAssemblyArchiver()
{
return assemblyArchiver;
}
- protected AssemblyReader getAssemblyReader()
+ AssemblyReader getAssemblyReader()
{
return assemblyReader;
}
@@ -620,8 +678,7 @@ public abstract class AbstractAssemblyMo
{
if ( filters == null )
{
- filters = getProject().getBuild()
- .getFilters();
+ filters = getProject().getBuild().getFilters();
if ( filters == null )
{
filters = Collections.emptyList();
@@ -630,6 +687,11 @@ public abstract class AbstractAssemblyMo
return filters;
}
+ public boolean isIncludeProjectBuildFilters()
+ {
+ return includeProjectBuildFilters;
+ }
+
public List<MavenProject> getReactorProjects()
{
return reactorProjects;
@@ -656,20 +718,6 @@ public abstract class AbstractAssemblyMo
this.archive = archive;
}
- public void setArchiveBaseDirectory( final File archiveBaseDirectory )
- {
- this.archiveBaseDirectory = archiveBaseDirectory;
- }
-
- public void setAssemblyArchiver( final AssemblyArchiver assemblyArchiver )
- {
- this.assemblyArchiver = assemblyArchiver;
- }
-
- public void setAssemblyReader( final AssemblyReader assemblyReader )
- {
- this.assemblyReader = assemblyReader;
- }
public void setBasedir( final File basedir )
{
@@ -813,6 +861,11 @@ public abstract class AbstractAssemblyMo
return mavenFileFilter;
}
+ public MavenReaderFilter getMavenReaderFilter()
+ {
+ return mavenReaderFilter;
+ }
+
public boolean isUpdateOnly()
{
return updateOnly;
@@ -827,13 +880,13 @@ public abstract class AbstractAssemblyMo
{
return ignorePermissions;
}
-
+
public String getEncoding()
{
return encoding;
}
- protected boolean isRecompressZippedFiles()
+ boolean isRecompressZippedFiles()
{
return recompressZippedFiles;
}
@@ -842,4 +895,15 @@ public abstract class AbstractAssemblyMo
{
return escapeString;
}
+
+ public List<String> getDelimiters()
+ {
+ return delimiters;
+ }
+
+ public void setDelimiters( List<String> delimiters )
+ {
+ this.delimiters = delimiters;
+ }
+
}
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachedAssemblyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachedAssemblyMojo.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachedAssemblyMojo.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachedAssemblyMojo.java Thu Oct 23 21:01:23 2014
@@ -19,7 +19,6 @@ package org.apache.maven.plugin.assembly
* under the License.
*/
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/SingleAssemblyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/SingleAssemblyMojo.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/SingleAssemblyMojo.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/mojos/SingleAssemblyMojo.java Thu Oct 23 21:01:23 2014
@@ -21,6 +21,7 @@ package org.apache.maven.plugin.assembly
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
/**
@@ -32,7 +33,7 @@ import org.apache.maven.project.MavenPro
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
-@Mojo( name = "single", inheritByDefault = false, threadSafe = true )
+@Mojo( name = "single", inheritByDefault = false, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true )
public class SingleAssemblyMojo
extends AbstractAssemblyMojo
{
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java Thu Oct 23 21:01:23 2014
@@ -19,27 +19,16 @@ package org.apache.maven.plugin.assembly
* under the License.
*/
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-
import org.apache.maven.plugin.assembly.archive.ArchiveExpansionException;
-import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
-import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import java.io.File;
+import java.util.Locale;
/**
* @version $Id$
@@ -47,18 +36,6 @@ import javax.annotation.Nullable;
public final class AssemblyFileUtils
{
- public static final String LINE_ENDING_KEEP = "keep";
-
- public static final String LINE_ENDING_DOS = "dos";
-
- public static final String LINE_ENDING_WINDOWS = "windows";
-
- public static final String LINE_ENDING_UNIX = "unix";
-
- public static final String LINE_ENDING_CRLF = "crlf";
-
- public static final String LINE_ENDING_LF = "lf";
-
private AssemblyFileUtils()
{
// no op
@@ -104,11 +81,12 @@ public final class AssemblyFileUtils
return path;
}
- public static void verifyTempDirectoryAvailability( @Nonnull final File tempDir )
+ @SuppressWarnings( "ResultOfMethodCallIgnored" )
+ public static void verifyTempDirectoryAvailability( @Nonnull
+ final File tempDir )
{
if ( !tempDir.exists() )
{
- //noinspection ResultOfMethodCallIgnored
tempDir.mkdirs();
}
}
@@ -116,7 +94,7 @@ public final class AssemblyFileUtils
/**
* Unpacks the archive file.
*
- * @param source File to be unpacked.
+ * @param source File to be unpacked.
* @param destDir Location where to put the unpacked files.
*/
public static void unpack( File source, File destDir, ArchiverManager archiverManager )
@@ -138,158 +116,27 @@ public final class AssemblyFileUtils
}
}
- /**
- * Converts the line endings of a file, writing a new file.
- * The encoding of reading and writing can be specified.
- *
- * @param source The source file, not null
- * @param dest The destination file, not null
- * @param lineEndings This is the result of the getLineEndingChars(..) method in this utility class; the actual
- * line-ending characters, not null.
- * @param atEndOfFile The end-of-file line ending,
- * if true then the resulting file will have a new line at the end even if the input didn't have one,
- * if false then the resulting file will have no new line at the end even if the input did have one,
- * null to determine whether to have a new line at the end of the file based on the input file
- * @param encoding The encoding to use, null for platform encoding
- */
- public static void convertLineEndings( @Nonnull File source, @Nonnull File dest, String lineEndings,
- Boolean atEndOfFile, String encoding )
- throws IOException
+ @Nonnull
+ private static String normalizePath( @Nonnull String path )
{
- // MASSEMBLY-637, MASSEMBLY-96
- // find characters at the end of the file
- // needed to preserve the last line ending
- // only check for LF (as CRLF also ends in LF)
- String eofChars = "";
- if ( atEndOfFile == null )
- {
- RandomAccessFile raf = null;
- try
- {
- if ( source.length() >= 1 )
- {
- raf = new RandomAccessFile( source, "r" );
- raf.seek( source.length() - 1 );
- byte last = raf.readByte();
- if ( last == '\n' )
- {
- eofChars = lineEndings;
- }
- }
- }
- finally
- {
- if ( raf != null )
- {
- try
- {
- raf.close();
- }
- catch ( IOException ex )
- {
- // ignore
- }
- }
- }
- }
- else if (atEndOfFile == true )
- {
- eofChars = lineEndings;
- }
-
- BufferedReader in = null;
- BufferedWriter out = null;
- try
- {
- if ( encoding == null )
- {
- // platform encoding
- in = new BufferedReader( new InputStreamReader( new FileInputStream( source ) ) );
- out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( dest ) ) );
- }
- else
- {
- // MASSEMBLY-371
- in = new BufferedReader( new InputStreamReader( new FileInputStream( source ), encoding ) );
- out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( dest ), encoding ) );
- }
-
- String line;
-
- line = in.readLine();
- while ( line != null )
- {
- out.write( line );
- line = in.readLine();
- if ( line != null )
- {
- out.write( lineEndings );
- }
- else
- {
- out.write( eofChars );
- }
- }
-
- out.flush();
- }
- finally
- {
- IOUtil.close( in );
- IOUtil.close( out );
- }
+ return path.replace( '\\', '/' );
}
- @Nullable
- public static String getLineEndingCharacters( @Nullable String lineEnding )
- throws AssemblyFormattingException
+ @Nonnull
+ public static String normalizeFileInfo( @Nonnull FileInfo fileInfo )
{
- String value = lineEnding;
- if ( lineEnding != null )
- {
- if ( LINE_ENDING_KEEP.equals( lineEnding ) )
- {
- value = null;
- }
- else if ( LINE_ENDING_DOS.equals( lineEnding ) || LINE_ENDING_WINDOWS.equals( lineEnding )
- || LINE_ENDING_CRLF.equals( lineEnding ) )
- {
- value = "\r\n";
- }
- else if ( LINE_ENDING_UNIX.equals( lineEnding ) || LINE_ENDING_LF.equals( lineEnding ) )
- {
- value = "\n";
- }
- else
- {
- throw new AssemblyFormattingException( "Illegal lineEnding specified: '" + lineEnding + "'" );
- }
- }
-
- return value;
+ String name = fileInfo.getName();
+ name = normalizePath( name );
+ return name.replace( File.separatorChar, '/' ); // How can this be anything but a no-op
}
- public static void copyFile( File src, File dst )
- throws IOException
+ public static boolean isPropertyFile( String sourceName )
{
- FileChannel c1 = new RandomAccessFile( src, "r" ).getChannel();
- FileChannel c2 = new RandomAccessFile( dst, "rw" ).getChannel();
-
- long tCount = 0, size = c1.size();
- //noinspection StatementWithEmptyBody
- while ( ( tCount += c2.transferFrom( c1, 0, size - tCount ) ) < size )
- {
- }
-
- c1.close();
- c2.force( true );
- c2.close();
+ return sourceName.toLowerCase( Locale.ENGLISH ).endsWith( ".properties" );
}
- @Nonnull
- public static String normalizePath( @Nonnull String path )
+ public static boolean isPropertyFile( File file )
{
- return path.replace( '\\', '/' );
+ return isPropertyFile( file.getName());
}
-
}
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFormatUtils.java Thu Oct 23 21:01:23 2014
@@ -79,19 +79,6 @@ public final class AssemblyFormatUtils
return distributionName;
}
- /**
- * @deprecated Use
- * {@link AssemblyFormatUtils#getOutputDirectory(String, MavenProject, MavenProject, String, AssemblerConfigurationSource)}
- * instead.
- */
- @Deprecated
- public static String getOutputDirectory( final String output, final MavenProject mainProject,
- final MavenProject artifactProject, final String finalName )
- throws AssemblyFormattingException
- {
- return getOutputDirectory( output, mainProject, null, artifactProject, finalName, null );
- }
-
public static String getOutputDirectory( final String output, final MavenProject mainProject,
final MavenProject artifactProject, final String finalName,
final AssemblerConfigurationSource configSource )
@@ -240,7 +227,7 @@ public final class AssemblyFormatUtils
catch ( final IOException e )
{
throw new AssemblyFormattingException( "Failed to retrieve OS environment variables. Reason: "
- + e.getMessage(), e );
+ + e.getMessage(), e );
}
try
@@ -270,19 +257,6 @@ public final class AssemblyFormatUtils
return value;
}
- /**
- * @deprecated Use
- * {@link AssemblyFormatUtils#evaluateFileNameMapping(String, Artifact, MavenProject, MavenProject, AssemblerConfigurationSource)}
- * instead.
- */
- @Deprecated
- public static String evaluateFileNameMapping( final String expression, final Artifact artifact,
- final MavenProject mainProject, final MavenProject artifactProject )
- throws AssemblyFormattingException
- {
- return evaluateFileNameMapping( expression, artifact, mainProject, null, null, artifactProject, null );
- }
-
public static String evaluateFileNameMapping( final String expression, final Artifact artifact,
final MavenProject mainProject, final MavenProject artifactProject,
final AssemblerConfigurationSource configSource )
@@ -467,7 +441,7 @@ public final class AssemblyFormatUtils
catch ( final IOException e )
{
throw new AssemblyFormattingException( "Failed to retrieve OS environment variables. Reason: "
- + e.getMessage(), e );
+ + e.getMessage(), e );
}
try
@@ -477,7 +451,7 @@ public final class AssemblyFormatUtils
catch ( final InterpolationException e )
{
throw new AssemblyFormattingException( "Failed to interpolate output filename mapping. Reason: "
- + e.getMessage(), e );
+ + e.getMessage(), e );
}
value = StringUtils.replace( value, "//", "/" );
@@ -490,11 +464,9 @@ public final class AssemblyFormatUtils
public static String fixRelativeRefs( String src )
{
String value = src;
-
- String[] separators = {
- "/", "\\"
- };
-
+
+ String[] separators = { "/", "\\" };
+
String finalSep = null;
for ( String sep : separators )
{
@@ -502,12 +474,12 @@ public final class AssemblyFormatUtils
{
finalSep = sep;
}
-
- if (value.contains("." + sep))
+
+ if ( value.contains( "." + sep ) )
{
List<String> parts = new ArrayList<String>();
parts.addAll( Arrays.asList( value.split( sep.replace( "\\", "\\\\" ) ) ) );
-
+
for ( ListIterator<String> it = parts.listIterator(); it.hasNext(); )
{
String part = it.next();
@@ -525,16 +497,16 @@ public final class AssemblyFormatUtils
}
}
}
-
+
value = StringUtils.join( parts.iterator(), sep );
}
}
-
+
if ( finalSep != null && value.length() > 0 && !value.endsWith( finalSep ) )
{
value += finalSep;
}
-
+
return value;
}
}
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java Thu Oct 23 21:01:23 2014
@@ -80,9 +80,11 @@ public final class FilterUtils
}
}
- for (final PatternIncludesArtifactFilter f : allFilters) {
- if (f != null) {
- f.reportMissedCriteria(logger);
+ for ( final PatternIncludesArtifactFilter f : allFilters )
+ {
+ if ( f != null )
+ {
+ f.reportMissedCriteria( logger );
}
}
}
@@ -149,13 +151,16 @@ public final class FilterUtils
reportFilteringStatistics( allFilters, logger );
- for (final ArtifactFilter f : allFilters) {
- if (f instanceof StatisticsReportingArtifactFilter) {
+ for ( final ArtifactFilter f : allFilters )
+ {
+ if ( f instanceof StatisticsReportingArtifactFilter )
+ {
final StatisticsReportingArtifactFilter sFilter = (StatisticsReportingArtifactFilter) f;
- if (strictFiltering && sFilter.hasMissedCriteria()) {
+ if ( strictFiltering && sFilter.hasMissedCriteria() )
+ {
throw new InvalidAssemblerConfigurationException(
- "One or more filters had unmatched criteria. Check debug log for more information.");
+ "One or more filters had unmatched criteria. Check debug log for more information." );
}
}
}
@@ -163,16 +168,19 @@ public final class FilterUtils
public static void reportFilteringStatistics( final Collection<ArtifactFilter> filters, final Logger logger )
{
- for (final ArtifactFilter f : filters) {
- if (f instanceof StatisticsReportingArtifactFilter) {
+ for ( final ArtifactFilter f : filters )
+ {
+ if ( f instanceof StatisticsReportingArtifactFilter )
+ {
final StatisticsReportingArtifactFilter sFilter = (StatisticsReportingArtifactFilter) f;
- if (logger.isDebugEnabled()) {
- logger.debug("Statistics for " + sFilter + "\n");
+ if ( logger.isDebugEnabled() )
+ {
+ logger.debug( "Statistics for " + sFilter + "\n" );
}
- sFilter.reportMissedCriteria(logger);
- sFilter.reportFilteredArtifacts(logger);
+ sFilter.reportMissedCriteria( logger );
+ sFilter.reportFilteredArtifacts( logger );
}
}
}
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/TypeConversionUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/TypeConversionUtils.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/TypeConversionUtils.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/java/org/apache/maven/plugin/assembly/utils/TypeConversionUtils.java Thu Oct 23 21:01:23 2014
@@ -58,16 +58,16 @@ public final class TypeConversionUtils
if ( ( list != null ) && !list.isEmpty() )
{
- result = list.toArray(new String[list.size()]);
+ result = list.toArray( new String[list.size()] );
}
return result;
}
- public static int modeToInt( final String mode, final Logger logger ) throws AssemblyFormattingException
+ public static int modeToInt( final String mode, final Logger logger )
+ throws AssemblyFormattingException
{
- if ( mode == null || mode.trim()
- .length() < 1 )
+ if ( mode == null || mode.trim().length() < 1 )
{
return -1;
}
@@ -93,7 +93,7 @@ public final class TypeConversionUtils
{
final StringBuilder messages = new StringBuilder();
- messages.append("The mode: ").append(Integer.toString(mode, 8)).append(" contains nonsensical permissions:");
+ messages.append( "The mode: " ).append( Integer.toString( mode, 8 ) ).append( " contains nonsensical permissions:" );
boolean warn = false;
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/mdo/descriptor.mdo
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/mdo/descriptor.mdo?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/mdo/descriptor.mdo (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/mdo/descriptor.mdo Thu Oct 23 21:01:23 2014
@@ -106,8 +106,8 @@
<ul>
<li><b>"zip"</b> - Creates a ZIP file format</li>
<li><b>"tar"</b> - Creates a TAR format</li>
- <li><b>"tar.gz"</b> - Creates a gzip'd TAR format</li>
- <li><b>"tar.bz2"</b> - Creates a bzip'd TAR format</li>
+ <li><b>"tar.gz"</b> or <b>"tgz"</b> - Creates a gzip'd TAR format</li>
+ <li><b>"tar.bz2"</b> or <b>"tbz2"</b> - Creates a bzip'd TAR format</li>
<li><b>"jar"</b> - Creates a JAR format</li>
<li><b>"dir"</b> - Creates an exploded directory format</li>
<li><b>"war"</b> - Creates a WAR format</li>
Modified: maven/plugins/branches/MASSEMBLY-704/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/main/resources/META-INF/plexus/components.xml?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/main/resources/META-INF/plexus/components.xml Thu Oct 23 21:01:23 2014
@@ -33,19 +33,5 @@
<implementation>org.codehaus.plexus.components.io.resources.PlexusIoZipFileResourceCollection</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
-
- <component>
- <role>org.apache.maven.plugin.assembly.filter.ContainerDescriptorHandler</role>
- <role-hint>plexus</role-hint>
- <implementation>org.apache.maven.plugin.assembly.filter.ComponentsXmlArchiverFileFilter</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
-
- <component>
- <role>org.apache.maven.plugin.assembly.filter.ContainerDescriptorHandler</role>
- <role-hint>file-aggregator</role-hint>
- <implementation>org.apache.maven.plugin.assembly.filter.SimpleAggregatingDescriptorHandler</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
</components>
</component-set>
Modified: maven/plugins/branches/MASSEMBLY-704/src/site/apt/features.apt
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/site/apt/features.apt?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/site/apt/features.apt (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/site/apt/features.apt Thu Oct 23 21:01:23 2014
@@ -46,7 +46,7 @@ Features
* Reusable assembly-descriptor components <[2.1]>
- * Supported archive formats include: zip, tar, tar.gz, tar.bz2, jar, dir, war
+ * Supported archive formats include: zip, tar, tar.gz (or tgz), tar.bz2 (or tbz2), jar, dir, war
(and any other format that the ArchiveManager has been configured for).
Modified: maven/plugins/branches/MASSEMBLY-704/src/site/apt/index.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/site/apt/index.apt.vm?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/site/apt/index.apt.vm (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/site/apt/index.apt.vm Thu Oct 23 21:01:23 2014
@@ -50,9 +50,9 @@ ${project.name}
* tar
- * tar.gz
+ * tar.gz (or tgz)
- * tar.bz2
+ * tar.bz2 (or tbz2)
* jar
Modified: maven/plugins/branches/MASSEMBLY-704/src/site/resources/architecture/assembly-plugin-architecture-notes.html/index.html
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/site/resources/architecture/assembly-plugin-architecture-notes.html/index.html?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/site/resources/architecture/assembly-plugin-architecture-notes.html/index.html (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/site/resources/architecture/assembly-plugin-architecture-notes.html/index.html Thu Oct 23 21:01:23 2014
@@ -1,4 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Modified: maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiverTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiverTest.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiverTest.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiverTest.java Thu Oct 23 21:01:23 2014
@@ -19,32 +19,18 @@ package org.apache.maven.plugin.assembly
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
import junit.framework.Assert;
-
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
-import org.apache.maven.plugin.assembly.AssemblyContext;
-import org.apache.maven.plugin.assembly.DefaultAssemblyContext;
import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugin.assembly.archive.phase.AssemblyArchiverPhase;
import org.apache.maven.plugin.assembly.artifact.DependencyResolutionException;
import org.apache.maven.plugin.assembly.artifact.DependencyResolver;
import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
import org.apache.maven.plugin.assembly.model.Assembly;
-import org.apache.maven.plugin.assembly.testutils.MockManager;
+import org.apache.maven.plugin.assembly.resolved.ResolvedAssembly;
import org.apache.maven.plugin.assembly.testutils.TestFileManager;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.DefaultPlexusContainer;
@@ -54,7 +40,6 @@ import org.codehaus.plexus.archiver.Arch
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.FileSet;
-import org.codehaus.plexus.archiver.FinalizerEnabled;
import org.codehaus.plexus.archiver.ResourceIterator;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
@@ -68,12 +53,23 @@ import org.codehaus.plexus.logging.Logge
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.util.FileUtils;
import org.easymock.MockControl;
+import org.easymock.classextension.EasyMockSupport;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
public class DefaultAssemblyArchiverTest
-// extends PlexusTestCase
{
private static final TestFileManager fileManager = new TestFileManager( "def-assy-archiver.test.", "" );
@@ -89,12 +85,6 @@ public class DefaultAssemblyArchiverTest
container.start();
}
- public void shutdown()
- {
- container.dispose();
- }
-
- // @Override
@AfterClass
public static void tearDown()
throws Exception
@@ -106,18 +96,17 @@ public class DefaultAssemblyArchiverTest
public void failWhenAssemblyIdIsNull()
throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
{
- final MockManager mm = new MockManager();
- final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver( mm );
+ final EasyMockSupport mm = new EasyMockSupport();
- final MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
- mm.add( csControl );
+ final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver( mm );
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) csControl.getMock();
+ final AssemblerConfigurationSource configSource = mm.createControl().createMock(
+ AssemblerConfigurationSource.class );
mm.replayAll();
final DefaultAssemblyArchiver archiver = createSubject( macMgr, null, null );
- archiver.createArchive( new Assembly(), "full-name", "zip", configSource, false);
+ archiver.createArchive( new Assembly(), "full-name", "zip", configSource, false );
mm.verifyAll();
}
@@ -127,37 +116,26 @@ public class DefaultAssemblyArchiverTest
throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
IOException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver( mm );
macMgr.expectGetArchiver( "zip", Archiver.class );
macMgr.expectGetDestFile( new File( "test" ) );
- final MockControl phaseControl = MockControl.createControl( AssemblyArchiverPhase.class );
- mm.add( phaseControl );
-
- final AssemblyArchiverPhase phase = (AssemblyArchiverPhase) phaseControl.getMock();
+ final AssemblyArchiverPhase phase = mm.createControl().createMock(AssemblyArchiverPhase.class );
- phase.execute( null, null, null, null );
- phaseControl.setMatcher( MockControl.ALWAYS_MATCHER );
+ phase.execute( (ResolvedAssembly)anyObject(), (Archiver)anyObject(), (AssemblerConfigurationSource)anyObject() );
- final MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
- mm.add( csControl );
-
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) csControl.getMock();
+ final AssemblerConfigurationSource configSource =
+ mm.createControl().createMock( AssemblerConfigurationSource.class );
final File tempDir = fileManager.createTempDir();
FileUtils.deleteDirectory( tempDir );
- configSource.getTemporaryRootDirectory();
- csControl.setReturnValue( tempDir, MockControl.ZERO_OR_MORE );
-
- configSource.isDryRun();
- csControl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.isIgnoreDirFormatExtensions();
- csControl.setReturnValue( false, MockControl.ZERO_OR_MORE );
+ expect(configSource.getTemporaryRootDirectory()).andReturn( tempDir ).anyTimes();
+ expect( configSource.isDryRun()).andReturn( false ).anyTimes();
+ expect( configSource.isIgnoreDirFormatExtensions()).andReturn( false ).anyTimes();
final File outDir = fileManager.createTempDir();
@@ -176,33 +154,20 @@ public class DefaultAssemblyArchiverTest
fail( "Should never happen" );
}
- configSource.getOutputDirectory();
- csControl.setReturnValue( outDir );
-
- configSource.getFinalName();
- csControl.setReturnValue( "finalName" );
-
- configSource.getArchiverConfig();
- csControl.setReturnValue( null, MockControl.ZERO_OR_MORE );
-
- configSource.getWorkingDirectory();
- csControl.setReturnValue( new File( "." ), MockControl.ZERO_OR_MORE );
-
- configSource.isUpdateOnly();
- csControl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.isIgnorePermissions();
- csControl.setReturnValue( true, MockControl.ZERO_OR_MORE );
+ expect(configSource.getOutputDirectory()).andReturn( outDir );
+ expect( configSource.getFinalName() ).andReturn( "finalName" );
+ expect( configSource.getArchiverConfig()).andReturn( null ).anyTimes();
+ expect( configSource.getWorkingDirectory()).andReturn( new File( "." )).anyTimes();
+ expect( configSource.isUpdateOnly()).andReturn( false ).anyTimes();
+ expect( configSource.isIgnorePermissions()).andReturn( false ).anyTimes();
final Assembly assembly = new Assembly();
assembly.setId( "id" );
- final AssemblyContext context = new DefaultAssemblyContext();
-
try
{
- macMgr.dependencyResolver.resolve( assembly, configSource, context );
- macMgr.dependencyResolverControl.setMatcher( MockControl.ALWAYS_MATCHER );
+ expect( macMgr.dependencyResolver.resolve( assembly, configSource )).andReturn( new HashSet<Artifact>( ) );
+// macMgr.dependencyResolverControl.setMatcher( MockControl.ALWAYS_MATCHER );
}
catch ( final DependencyResolutionException e )
{
@@ -213,7 +178,7 @@ public class DefaultAssemblyArchiverTest
final DefaultAssemblyArchiver subject = createSubject( macMgr, Collections.singletonList( phase ), null );
- subject.createArchive( assembly, "full-name", "zip", configSource, false);
+ subject.createArchive( assembly, "full-name", "zip", configSource, false );
mm.verifyAll();
}
@@ -222,7 +187,7 @@ public class DefaultAssemblyArchiverTest
public void testCreateArchiver_ShouldConfigureArchiver()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver( mm );
@@ -230,53 +195,38 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "dummy", archiver );
- final MockControl configCtl = MockControl.createControl( AssemblerConfigurationSource.class );
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) configCtl.getMock();
+ final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class);
final String simpleConfig = "value";
- configSource.getArchiverConfig();
- configCtl.setReturnValue( "<configuration><simpleConfig>" + simpleConfig + "</simpleConfig></configuration>",
- MockControl.ZERO_OR_MORE );
+ expect( configSource.getArchiverConfig()).andReturn(
+ "<configuration><simpleConfig>" + simpleConfig + "</simpleConfig></configuration>").anyTimes();
final MavenProject project = new MavenProject( new Model() );
- configSource.getProject();
- configCtl.setReturnValue( project, MockControl.ZERO_OR_MORE );
-
- configSource.getMavenSession();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
+ expect(configSource.getProject()).andReturn( project ).anyTimes();
- configSource.isDryRun();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
+ expect(configSource.getMavenSession()).andReturn( null ).anyTimes();
- configSource.getWorkingDirectory();
- configCtl.setReturnValue( new File( "." ), MockControl.ZERO_OR_MORE );
+ expect(configSource.isDryRun()).andReturn( false ).anyTimes();
- configSource.isUpdateOnly();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
+ expect(configSource.getWorkingDirectory()).andReturn( new File( "." )).anyTimes();
- final MockControl lrCtl = MockControl.createControl( ArtifactRepository.class );
- final ArtifactRepository lr = (ArtifactRepository) lrCtl.getMock();
- mm.add( lrCtl );
+ expect(configSource.isUpdateOnly()).andReturn( false ).anyTimes();
- lr.getBasedir();
- lrCtl.setReturnValue( "/path/to/local/repo", MockControl.ZERO_OR_MORE );
+ final ArtifactRepository lr = mm.createMock( ArtifactRepository.class );
- configSource.getLocalRepository();
- configCtl.setReturnValue( lr, MockControl.ZERO_OR_MORE );
+ expect(lr.getBasedir()).andReturn( "/path/to/local/repo" ).anyTimes();
- configSource.isIgnorePermissions();
- configCtl.setReturnValue( true, MockControl.ZERO_OR_MORE );
-
- mm.add( configCtl );
+ expect(configSource.getLocalRepository()).andReturn( lr ).anyTimes();
+ expect(configSource.isIgnorePermissions()).andReturn( true );
mm.replayAll();
final DefaultAssemblyArchiver subject =
createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
- subject.createArchiver( "dummy", false, "finalName", configSource, null, false);
+ subject.createArchiver( "dummy", false, "finalName", configSource, null, false );
assertEquals( simpleConfig, archiver.getSimpleConfig() );
@@ -287,7 +237,7 @@ public class DefaultAssemblyArchiverTest
public void testCreateArchiver_ShouldCreateTarArchiverWithNoCompression()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
@@ -295,44 +245,32 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "tar", ttArchiver );
- final MockControl configCtl = MockControl.createControl( AssemblerConfigurationSource.class );
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) configCtl.getMock();
-
- configSource.getTarLongFileMode();
- configCtl.setReturnValue( TarLongFileMode.FAIL, MockControl.ZERO_OR_MORE );
+ final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- configSource.isDryRun();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
+ expect( configSource.getTarLongFileMode()).andReturn( TarLongFileMode.fail.toString()).anyTimes();
+ expect( configSource.isDryRun()).andReturn( false ).anyTimes();
- configSource.getArchiverConfig();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
+ expect( configSource.getArchiverConfig()).andReturn( null ).anyTimes();
- configSource.getProject();
- configCtl.setReturnValue( new MavenProject( new Model() ), MockControl.ZERO_OR_MORE );
+ expect( configSource.getProject()).andReturn( new MavenProject( new Model() ) ).anyTimes();
- configSource.getJarArchiveConfiguration();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
+ expect( configSource.getJarArchiveConfiguration()).andReturn( null ).anyTimes();
- configSource.getWorkingDirectory();
- configCtl.setReturnValue( new File( "." ), MockControl.ZERO_OR_MORE );
+ expect( configSource.getWorkingDirectory()).andReturn( new File( "." ) ).anyTimes();
- configSource.isUpdateOnly();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
+ expect( configSource.isUpdateOnly()).andReturn( false ).anyTimes();
- configSource.isIgnorePermissions();
- configCtl.setReturnValue( true, MockControl.ZERO_OR_MORE );
-
- mm.add( configCtl );
+ expect( configSource.isIgnorePermissions()).andReturn( true ).anyTimes();
mm.replayAll();
final DefaultAssemblyArchiver subject =
createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
- subject.createArchiver( "tar", false, "finalName", configSource, null, false);
+ subject.createArchiver( "tar", false, "finalName", configSource, null, false );
assertNull( ttArchiver.compressionMethod );
- assertEquals( TarLongFileMode.FAIL, ttArchiver.longFileMode.getValue() );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
mm.verifyAll();
}
@@ -341,7 +279,7 @@ public class DefaultAssemblyArchiverTest
public void testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestWarArchiver twArchiver = new TestWarArchiver();
@@ -349,41 +287,23 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "war", twArchiver );
- final MockControl configCtl = MockControl.createControl( AssemblerConfigurationSource.class );
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) configCtl.getMock();
-
- configSource.isDryRun();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.getArchiverConfig();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
-
- configSource.getMavenSession();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
-
- configSource.getProject();
- configCtl.setReturnValue( new MavenProject( new Model() ), MockControl.ZERO_OR_MORE );
-
- configSource.getJarArchiveConfiguration();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
+ final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- configSource.getWorkingDirectory();
- configCtl.setReturnValue( new File( "." ), MockControl.ZERO_OR_MORE );
-
- configSource.isUpdateOnly();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.isIgnorePermissions();
- configCtl.setReturnValue( true, MockControl.ZERO_OR_MORE );
-
- mm.add( configCtl );
+ expect( configSource.isDryRun()).andReturn( false ).anyTimes();
+ expect( configSource.getArchiverConfig()).andReturn( null ).anyTimes();
+ expect( configSource.getMavenSession()).andReturn( null ).anyTimes();
+ expect( configSource.getProject()).andReturn( new MavenProject( new Model() ) ).anyTimes();
+ expect( configSource.getJarArchiveConfiguration()).andReturn( null ).anyTimes();
+ expect( configSource.getWorkingDirectory()).andReturn( new File( "." ) ).anyTimes();
+ expect( configSource.isUpdateOnly()).andReturn( false ).anyTimes();
+ expect( configSource.isIgnorePermissions()).andReturn( true ).anyTimes();
mm.replayAll();
final DefaultAssemblyArchiver subject =
createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
- subject.createArchiver( "war", false, null, configSource, null, false);
+ subject.createArchiver( "war", false, null, configSource, null, false );
assertFalse( twArchiver.ignoreWebxml );
}
@@ -392,7 +312,7 @@ public class DefaultAssemblyArchiverTest
public void testCreateArchiver_ShouldCreateZipArchiver()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final ZipArchiver archiver = new ZipArchiver();
@@ -400,143 +320,28 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "zip", archiver );
- final MockControl configCtl = MockControl.createControl( AssemblerConfigurationSource.class );
- final AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) configCtl.getMock();
-
- configSource.isDryRun();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.getArchiverConfig();
- configCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );
-
- configSource.getWorkingDirectory();
- configCtl.setReturnValue( new File( "." ), MockControl.ZERO_OR_MORE );
-
- configSource.isUpdateOnly();
- configCtl.setReturnValue( false, MockControl.ZERO_OR_MORE );
-
- configSource.isIgnorePermissions();
- configCtl.setReturnValue( true, MockControl.ZERO_OR_MORE );
+ final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- mm.add( configCtl );
+ expect( configSource.isDryRun()).andReturn( false ).anyTimes();
+ expect( configSource.getArchiverConfig()).andReturn( null ).anyTimes();
+ expect( configSource.getWorkingDirectory()).andReturn( new File( "." ) ).anyTimes();
+ expect( configSource.isUpdateOnly()).andReturn( false ).anyTimes();
+ expect( configSource.getJarArchiveConfiguration()).andReturn( null ).anyTimes();
+ expect( configSource.isIgnorePermissions()).andReturn( true ).anyTimes();
mm.replayAll();
final DefaultAssemblyArchiver subject =
createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
- subject.createArchiver( "zip", false, null, configSource, null, false);
+ subject.createArchiver( "zip", false, null, configSource, null, false );
}
- // TODO: Re-implement these tests on the createArchiver(..) method. For now, they're no big loss.
- // public void testConfigureArchiverFinalizers_ShouldDoNothingWhenNotSupportedByArchiver()
- // {
- // MockManager mm = new MockManager();
- //
- // MockAndControlForArchiverManager macArchiverManager = new MockAndControlForArchiverManager( mm );
- //
- // macArchiverManager.createArchiver( Archiver.class );
- //
- // ComponentsXmlArchiverFileFilter filter = new ComponentsXmlArchiverFileFilter();
- //
- // mm.replayAll();
- //
- // DefaultAssemblyArchiver subject =
- // createSubject( macArchiverManager.archiverManager, Collections.EMPTY_LIST, null );
- //
- // subject.configureArchiverFinalizers( macArchiverManager.archiver, "format", null, filter );
- //
- // mm.verifyAll();
- // }
- //
- // public void testConfigureArchiverFinalizers_ShouldAddManifestFinalizerWhenSupportedByArchiver()
- // {
- // MockManager mm = new MockManager();
- //
- // MockAndControlForArchiverManager macArchiverManager = new MockAndControlForArchiverManager( mm );
- //
- // macArchiverManager.createArchiver( TestFinalizerFilteredArchiver.class );
- //
- // Set finalizerClasses = new HashSet();
- // finalizerClasses.add( ComponentsXmlArchiverFileFilter.class );
- // finalizerClasses.add( ManifestCreationFinalizer.class );
- //
- // macArchiverManager.expectSetArchiverFinalizers( finalizerClasses );
- //
- // ComponentsXmlArchiverFileFilter filter = new ComponentsXmlArchiverFileFilter();
- //
- // MockControl configCtl = MockControl.createControl( AssemblerConfigurationSource.class );
- // AssemblerConfigurationSource configSource = (AssemblerConfigurationSource) configCtl.getMock();
- //
- // Model model = new Model();
- // model.setGroupId( "group" );
- // model.setArtifactId( "artifact" );
- // model.setVersion( "1" );
- //
- // configSource.getProject();
- // configCtl.setReturnValue( new MavenProject( model ), MockControl.ZERO_OR_MORE );
- //
- // configSource.getJarArchiveConfiguration();
- // configCtl.setReturnValue( new MavenArchiveConfiguration() );
- //
- // mm.add( configCtl );
- //
- // mm.replayAll();
- //
- // DefaultAssemblyArchiver subject =
- // createSubject( macArchiverManager.archiverManager, Collections.EMPTY_LIST, null );
- //
- // subject.configureArchiverFinalizers( macArchiverManager.archiver, "jar", configSource, filter );
- //
- // mm.verifyAll();
- // }
- //
- // public void testConfigureArchiverFilters_ShouldDoNothingWhenNotSupportedByArchiver()
- // {
- // MockManager mm = new MockManager();
- //
- // MockAndControlForArchiverManager macArchiverManager = new MockAndControlForArchiverManager( mm );
- //
- // macArchiverManager.createArchiver( Archiver.class );
- //
- // ComponentsXmlArchiverFileFilter filter = new ComponentsXmlArchiverFileFilter();
- //
- // mm.replayAll();
- //
- // DefaultAssemblyArchiver subject =
- // createSubject( macArchiverManager.archiverManager, Collections.EMPTY_LIST, null );
- //
- // subject.configureArchiverFilters( macArchiverManager.archiver, filter );
- //
- // mm.verifyAll();
- // }
- //
- // public void testConfigureArchiverFilters_ShouldAddComponentsFilterWhenSupportedByArchiver()
- // {
- // MockManager mm = new MockManager();
- //
- // MockAndControlForArchiverManager macArchiverManager = new MockAndControlForArchiverManager( mm );
- //
- // macArchiverManager.createArchiver( TestFinalizerFilteredArchiver.class );
- // macArchiverManager.expectSetArchiverFilters();
- //
- // ComponentsXmlArchiverFileFilter filter = new ComponentsXmlArchiverFileFilter();
- //
- // mm.replayAll();
- //
- // DefaultAssemblyArchiver subject =
- // createSubject( macArchiverManager.archiverManager, Collections.EMPTY_LIST, null );
- //
- // subject.configureArchiverFilters( macArchiverManager.archiver, filter );
- //
- // mm.verifyAll();
- // }
-
@Test
public void testCreateWarArchiver_ShouldDisableIgnoreWebxmlOption()
throws NoSuchArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestWarArchiver twArchiver = new TestWarArchiver();
@@ -558,93 +363,112 @@ public class DefaultAssemblyArchiverTest
public void testCreateTarArchiver_ShouldNotInitializeCompression()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
+
+ subject.createTarArchiver( "tar", TarLongFileMode.fail );
+
+ assertNull( ttArchiver.compressionMethod );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
+
+ mm.verifyAll();
+ }
+
+ private DefaultAssemblyArchiver createSubject(EasyMockSupport mm,
+ TestTarArchiver ttArchiver) throws NoSuchArchiverException {
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver( mm );
macArchiverManager.expectGetArchiver( "tar", ttArchiver );
mm.replayAll();
- final DefaultAssemblyArchiver subject =
- createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ return createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ }
- subject.createTarArchiver( "tar", TarLongFileMode.FAIL );
+ @Test
+ public void testCreateTarArchiver_TarGzFormat_ShouldInitializeGZipCompression()
+ throws NoSuchArchiverException, ArchiverException
+ {
+ final EasyMockSupport mm = new EasyMockSupport();
- assertNull( ttArchiver.compressionMethod );
- assertEquals( TarLongFileMode.FAIL, ttArchiver.longFileMode.getValue() );
+ final TestTarArchiver ttArchiver = new TestTarArchiver();
+
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
+
+ subject.createTarArchiver( "tar.gz", TarLongFileMode.fail );
+
+ assertEquals( TarArchiver.TarCompressionMethod.gzip, ttArchiver.compressionMethod );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
mm.verifyAll();
}
@Test
- public void testCreateTarArchiver_ShouldInitializeGZipCompression()
+ public void testCreateTarArchiver_TgzFormat_ShouldInitializeGZipCompression()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
- final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver( mm );
-
- macArchiverManager.expectGetArchiver( "tar", ttArchiver );
-
- mm.replayAll();
-
- final DefaultAssemblyArchiver subject =
- createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
- subject.createTarArchiver( "tar.gz", TarLongFileMode.FAIL );
+ subject.createTarArchiver( "tgz", TarLongFileMode.fail );
- assertEquals( "gzip", ttArchiver.compressionMethod.getValue() );
- assertEquals( TarLongFileMode.FAIL, ttArchiver.longFileMode.getValue() );
+ assertEquals( TarArchiver.TarCompressionMethod.gzip, ttArchiver.compressionMethod );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
mm.verifyAll();
}
@Test
- public void testCreateTarArchiver_ShouldInitializeBZipCompression()
+ public void testCreateTarArchiver_TarBz2Format_ShouldInitializeBZipCompression()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
- final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver( mm );
-
- macArchiverManager.expectGetArchiver( "tar", ttArchiver );
-
- mm.replayAll();
-
- final DefaultAssemblyArchiver subject =
- createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
- subject.createTarArchiver( "tar.bz2", TarLongFileMode.FAIL );
+ subject.createTarArchiver( "tar.bz2", TarLongFileMode.fail );
- assertEquals( "bzip2", ttArchiver.compressionMethod.getValue() );
- assertEquals( TarLongFileMode.FAIL, ttArchiver.longFileMode.getValue() );
+ assertEquals( TarArchiver.TarCompressionMethod.bzip2, ttArchiver.compressionMethod );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
mm.verifyAll();
}
@Test
- public void testCreateTarArchiver_ShouldFailWithInvalidCompression()
+ public void testCreateTarArchiver_Tbz2Format_ShouldInitializeBZipCompression()
throws NoSuchArchiverException, ArchiverException
{
- final MockManager mm = new MockManager();
+ final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
- final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver( mm );
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
- macArchiverManager.expectGetArchiver( "tar", ttArchiver );
+ subject.createTarArchiver( "tbz2", TarLongFileMode.fail );
- mm.replayAll();
+ assertEquals( TarArchiver.TarCompressionMethod.bzip2, ttArchiver.compressionMethod );
+ assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
- final DefaultAssemblyArchiver subject =
- createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ mm.verifyAll();
+ }
+
+ @Test
+ public void testCreateTarArchiver_InvalidFormat_ShouldFailWithInvalidCompression()
+ throws NoSuchArchiverException, ArchiverException
+ {
+ final EasyMockSupport mm = new EasyMockSupport();
+
+ final TestTarArchiver ttArchiver = new TestTarArchiver();
+
+ final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
try
{
@@ -680,83 +504,59 @@ public class DefaultAssemblyArchiverTest
private final class MockAndControlForAssemblyArchiver
{
- ArchiverManager archiverManager;
-
- MockControl control;
+ final ArchiverManager archiverManager;
- MockControl archiverControl;
Archiver archiver;
- MockControl dependencyResolverControl;
+ final DependencyResolver dependencyResolver;
- DependencyResolver dependencyResolver;
+ private final EasyMockSupport mm;
- private final MockManager mm;
-
- public MockAndControlForAssemblyArchiver( final MockManager mm )
+ public MockAndControlForAssemblyArchiver( final EasyMockSupport mm )
{
this.mm = mm;
- control = MockControl.createControl( ArchiverManager.class );
- mm.add( control );
-
- archiverManager = (ArchiverManager) control.getMock();
+ archiverManager = mm.createControl().createMock( ArchiverManager.class );
- dependencyResolverControl = MockControl.createControl( DependencyResolver.class );
- mm.add( dependencyResolverControl );
+ dependencyResolver = mm.createControl().createMock( DependencyResolver.class );
- dependencyResolver = (DependencyResolver) dependencyResolverControl.getMock();
}
void expectGetDestFile( final File file )
{
- archiver.getDestFile();
- archiverControl.setReturnValue( file, MockControl.ZERO_OR_MORE );
+ expect(archiver.getDestFile()).andReturn( file ).anyTimes();
}
- void createArchiver( final Class<?> archiverClass )
+ void createArchiver( final Class<? extends Archiver> archiverClass )
{
- archiverControl = MockControl.createControl( archiverClass );
- mm.add( archiverControl );
+ archiver = mm.createControl().createMock(archiverClass);
- archiver = (Archiver) archiverControl.getMock();
-
- archiver.setForced( false );
- archiverControl.setMatcher( MockControl.ALWAYS_MATCHER );
- archiverControl.setVoidCallable( MockControl.ZERO_OR_MORE );
+ archiver.setForced( anyBoolean() );
+ expectLastCall().anyTimes();
archiver.setIgnorePermissions( false );
- archiverControl.setMatcher( MockControl.ALWAYS_MATCHER );
- archiverControl.setVoidCallable( MockControl.ZERO_OR_MORE );
+ expectLastCall().anyTimes();
}
- // void expectSetArchiverFilters()
- // {
- // ( ( FilterEnabled ) archiver ).setArchiveFilters( null );
- // archiverControl.setMatcher( MockControl.ALWAYS_MATCHER );
- // }
-
- void expectGetArchiver( final String format, final Class<?> archiverClass )
+ void expectGetArchiver( final String format, final Class<? extends Archiver> archiverClass )
{
createArchiver( archiverClass );
try
{
- archiverManager.getArchiver( format );
+ expect(archiverManager.getArchiver( format )).andReturn( archiver );
}
catch ( final NoSuchArchiverException e )
{
Assert.fail( "should never happen" );
}
- control.setReturnValue( archiver );
}
void expectGetArchiver( final String format, final Archiver archiver )
throws NoSuchArchiverException
{
- archiverManager.getArchiver( format );
- control.setReturnValue( archiver );
+ expect(archiverManager.getArchiver( format )).andReturn( archiver );
}
}
@@ -776,12 +576,6 @@ public class DefaultAssemblyArchiverTest
}
@Override
- public TarOptions getOptions()
- {
- return super.getOptions();
- }
-
- @Override
public void setCompression( final TarCompressionMethod mode )
{
compressionMethod = mode;
@@ -795,12 +589,6 @@ public class DefaultAssemblyArchiverTest
super.setLongfile( mode );
}
- @Override
- public void setOptions( final TarOptions options )
- {
- super.setOptions( options );
- }
-
}
private static final class TestWarArchiver
@@ -818,12 +606,6 @@ public class DefaultAssemblyArchiverTest
}
- interface TestFinalizerFilteredArchiver
- extends Archiver, FinalizerEnabled
- {
-
- }
-
public static final class TestArchiverWithConfig
implements Archiver
{
@@ -834,11 +616,6 @@ public class DefaultAssemblyArchiverTest
private boolean ignorePermissions;
- public void setSimpleConfig( final String simpleConfig )
- {
- this.simpleConfig = simpleConfig;
- }
-
public String getSimpleConfig()
{
return simpleConfig;
@@ -858,7 +635,6 @@ public class DefaultAssemblyArchiverTest
throws ArchiverException
{
}
-
public void addArchivedFileSet( final File arg0, final String[] arg1, final String[] arg2 )
throws ArchiverException
{
@@ -909,6 +685,18 @@ public class DefaultAssemblyArchiverTest
{
}
+ public void addSymlink( String s, String s2 )
+ throws ArchiverException
+ {
+
+ }
+
+ public void addSymlink( String s, int i, String s2 )
+ throws ArchiverException
+ {
+
+ }
+
public void addResources( final PlexusIoResourceCollection arg0 )
throws ArchiverException
{
Modified: maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/ManifestCreationFinalizerTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/ManifestCreationFinalizerTest.java?rev=1633948&r1=1633947&r2=1633948&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/ManifestCreationFinalizerTest.java (original)
+++ maven/plugins/branches/MASSEMBLY-704/src/test/java/org/apache/maven/plugin/assembly/archive/ManifestCreationFinalizerTest.java Thu Oct 23 21:01:23 2014
@@ -19,20 +19,9 @@ package org.apache.maven.plugin.assembly
* under the License.
*/
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.util.Collections;
-
import junit.framework.TestCase;
-
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.model.Model;
-import org.apache.maven.plugin.assembly.testutils.MockManager;
import org.apache.maven.plugin.assembly.testutils.TestFileManager;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.archiver.ArchiveFinalizer;
@@ -40,13 +29,22 @@ import org.codehaus.plexus.archiver.Arch
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.util.IOUtil;
-import org.easymock.MockControl;
+import org.easymock.classextension.EasyMockSupport;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.util.Collections;
public class ManifestCreationFinalizerTest
extends TestCase
{
- private TestFileManager fileManager = new TestFileManager( "manifest-finalizer.test.", ".jar" );
+ private final TestFileManager fileManager = new TestFileManager( "manifest-finalizer.test.", ".jar" );
public void tearDown()
throws IOException
@@ -63,7 +61,7 @@ public class ManifestCreationFinalizerTe
public void testShouldDoNothingWhenArchiverIsNotJarArchiver()
throws ArchiverException
{
- MockManager mm = new MockManager();
+ EasyMockSupport mm = new EasyMockSupport();
MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
@@ -158,16 +156,13 @@ public class ManifestCreationFinalizerTe
private final class MockAndControlForArchiver
{
- Archiver archiver;
+ final Archiver archiver;
- MockControl control;
- MockAndControlForArchiver( MockManager mm )
+ MockAndControlForArchiver( EasyMockSupport mm )
{
- control = MockControl.createControl( Archiver.class );
- mm.add( control );
- archiver = (Archiver) control.getMock();
+ archiver = mm.createMock(Archiver.class);
}
}