You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2007/11/16 01:22:51 UTC
svn commit: r595501 - in /maven/shared/trunk/file-management/src:
main/java/org/apache/maven/shared/model/fileset/mappers/
main/java/org/apache/maven/shared/model/fileset/util/
test/java/org/apache/maven/shared/model/fileset/util/
Author: vsiveton
Date: Thu Nov 15 16:22:47 2007
New Revision: 595501
URL: http://svn.apache.org/viewvc?rev=595501&view=rev
Log:
o formatting
o updated javadoc
o no code change
Modified:
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.java
maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java
maven/shared/trunk/file-management/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FileNameMapper.java Thu Nov 15 16:22:47 2007
@@ -29,18 +29,23 @@
* via the setFrom and setTo methods. The exact meaning of these is
* implementation dependent.</p>
*
+ * @version $Id$
*/
-public interface FileNameMapper {
-
+public interface FileNameMapper
+{
/**
* Sets the from part of the transformation rule.
+ *
+ * @param from
*/
- void setFrom(String from);
+ void setFrom( String from );
/**
* Sets the to part of the transformation rule.
+ *
+ * @param to
*/
- void setTo(String to);
+ void setTo( String to );
/**
* Returns the target filename for the
@@ -50,8 +55,8 @@
* implementation must return null. SourceFileScanner will then
* omit the source file in question.</p>
*
- * @param sourceFileName the name of the source file relative to
- * some given basedirectory.
+ * @param sourceFileName the name of the source file relative to some given basedirectory.
+ * @return the target filename for the given source file.
*/
- String mapFileName(String sourceFileName);
+ String mapFileName( String sourceFileName );
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/FlatFileNameMapper.java Thu Nov 15 16:22:47 2007
@@ -26,26 +26,26 @@
* <p>This is the default FileNameMapper for the copy and move
* tasks if the flatten attribute has been set.</p>
*
+ * @version $Id$
*/
-public class FlatFileNameMapper implements FileNameMapper {
-
- /**
- * Ignored.
- */
- public void setFrom(String from) {
+public class FlatFileNameMapper
+ implements FileNameMapper
+{
+ /** {@inheritDoc} */
+ public void setFrom( String from )
+ {
+ // nop
}
- /**
- * Ignored.
- */
- public void setTo(String to) {
+ /** {@inheritDoc} */
+ public void setTo( String to )
+ {
+ // nop
}
- /**
- * Returns an one-element array containing the source file name
- * without any leading directory information.
- */
- public String mapFileName(String sourceFileName) {
- return new String( new java.io.File(sourceFileName).getName() );
+ /** {@inheritDoc} */
+ public String mapFileName( String sourceFileName )
+ {
+ return new String( new java.io.File( sourceFileName ).getName() );
}
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/GlobPatternMapper.java Thu Nov 15 16:22:47 2007
@@ -31,9 +31,11 @@
* <p>This is one of the more useful Mappers, it is used by javac for
* example.</p>
*
+ * @version $Id$
*/
-public class GlobPatternMapper implements FileNameMapper {
-
+public class GlobPatternMapper
+ implements FileNameMapper
+{
/**
* Part of "from" pattern before the *.
*/
@@ -65,15 +67,16 @@
protected String toPostfix = null;
private boolean handleDirSep = false;
+
private boolean caseSensitive = true;
/**
* Attribute specifing whether to ignore the difference
* between / and \ (the two common directory characters).
* @param handleDirSep a boolean, default is false.
- * @since Ant 1.6.3
*/
- public void setHandleDirSep(boolean handleDirSep) {
+ public void setHandleDirSep( boolean handleDirSep )
+ {
this.handleDirSep = handleDirSep;
}
@@ -82,60 +85,55 @@
* in the names.
*
* @param caseSensitive a boolean, default is false.
- * @since Ant 1.6.3
*/
- public void setCaseSensitive(boolean caseSensitive) {
+ public void setCaseSensitive( boolean caseSensitive )
+ {
this.caseSensitive = caseSensitive;
}
- /**
- * Sets the "from" pattern. Required.
- * @param from a string
- */
- public void setFrom(String from) {
- int index = from.lastIndexOf("*");
- if (index == -1) {
+ /** {@inheritDoc} */
+ public void setFrom( String from )
+ {
+ int index = from.lastIndexOf( "*" );
+ if ( index == -1 )
+ {
fromPrefix = from;
fromPostfix = "";
- } else {
- fromPrefix = from.substring(0, index);
- fromPostfix = from.substring(index + 1);
+ }
+ else
+ {
+ fromPrefix = from.substring( 0, index );
+ fromPostfix = from.substring( index + 1 );
}
prefixLength = fromPrefix.length();
postfixLength = fromPostfix.length();
}
- /**
- * Sets the "to" pattern. Required.
- * @param to a string
- */
- public void setTo(String to) {
- int index = to.lastIndexOf("*");
- if (index == -1) {
+ /** {@inheritDoc} */
+ public void setTo( String to )
+ {
+ int index = to.lastIndexOf( "*" );
+ if ( index == -1 )
+ {
toPrefix = to;
toPostfix = "";
- } else {
- toPrefix = to.substring(0, index);
- toPostfix = to.substring(index + 1);
+ }
+ else
+ {
+ toPrefix = to.substring( 0, index );
+ toPostfix = to.substring( index + 1 );
}
}
- /**
- * Returns null if the source file name doesn't match the
- * "from" pattern, an one-element array containing the
- * translated file otherwise.
- * @param sourceFileName the filename to map
- * @return a list of converted filenames
- */
- public String mapFileName(String sourceFileName) {
- if (fromPrefix == null
- || !modifyName(sourceFileName).startsWith(modifyName(fromPrefix))
- || !modifyName(sourceFileName).endsWith(modifyName(fromPostfix))) {
+ /** {@inheritDoc} */
+ public String mapFileName( String sourceFileName )
+ {
+ if ( fromPrefix == null || !modifyName( sourceFileName ).startsWith( modifyName( fromPrefix ) )
+ || !modifyName( sourceFileName ).endsWith( modifyName( fromPostfix ) ) )
+ {
return null;
}
- return new String (toPrefix
- + extractVariablePart(sourceFileName)
- + toPostfix);
+ return new String( toPrefix + extractVariablePart( sourceFileName ) + toPostfix );
}
/**
@@ -144,9 +142,9 @@
* @param name the source file name
* @return the variable part of the name
*/
- protected String extractVariablePart(String name) {
- return name.substring(prefixLength,
- name.length() - postfixLength);
+ protected String extractVariablePart( String name )
+ {
+ return name.substring( prefixLength, name.length() - postfixLength );
}
/**
@@ -154,13 +152,17 @@
* @param name the name to convert
* @return the converted name
*/
- private String modifyName(String name) {
- if (!caseSensitive) {
+ private String modifyName( String name )
+ {
+ if ( !caseSensitive )
+ {
name = name.toLowerCase();
}
- if (handleDirSep) {
- if (name.indexOf('\\') != -1) {
- name = name.replace('\\', '/');
+ if ( handleDirSep )
+ {
+ if ( name.indexOf( '\\' ) != -1 )
+ {
+ name = name.replace( '\\', '/' );
}
}
return name;
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/IdentityMapper.java Thu Nov 15 16:22:47 2007
@@ -25,25 +25,26 @@
* <p>This is the default FileNameMapper for the copy and move
* tasks.</p>
*
+ * @version $Id$
*/
-public class IdentityMapper implements FileNameMapper {
-
- /**
- * Ignored.
- */
- public void setFrom(String from) {
+public class IdentityMapper
+ implements FileNameMapper
+{
+ /** {@inheritDoc} */
+ public void setFrom( String from )
+ {
+ // nop
}
- /**
- * Ignored.
- */
- public void setTo(String to) {
+ /** {@inheritDoc} */
+ public void setTo( String to )
+ {
+ // nop
}
- /**
- * Returns an one-element array containing the source file name.
- */
- public String mapFileName(String sourceFileName) {
+ /** {@inheritDoc} */
+ public String mapFileName( String sourceFileName )
+ {
return sourceFileName;
}
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperException.java Thu Nov 15 16:22:47 2007
@@ -19,18 +19,34 @@
* under the License.
*/
+/**
+ * Mapper Exception
+ *
+ * @version $Id$
+ */
public class MapperException
extends Exception
{
+ static final long serialVersionUID = 20064059145045044L;
+ /**
+ * Constructor
+ *
+ * @param message
+ * @param cause
+ */
public MapperException( String message, Throwable cause )
{
super( message, cause );
}
+ /**
+ * Constructor
+ *
+ * @param message
+ */
public MapperException( String message )
{
super( message );
}
-
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java Thu Nov 15 16:22:47 2007
@@ -28,16 +28,18 @@
/**
* Element to define a FileNameMapper.
+ *
+ * @version $Id$
*/
public final class MapperUtil
{
-
private static final String MAPPER_PROPERTIES = "mapper.properties";
private static Properties implementations;
private MapperUtil()
{
+ // nop
}
/**
@@ -80,6 +82,10 @@
/**
* Returns a fully configured FileNameMapper implementation.
+ *
+ * @param mapper
+ * @return
+ * @throws MapperException
*/
public static FileNameMapper getFileNameMapper( Mapper mapper )
throws MapperException
@@ -130,5 +136,4 @@
throw new MapperException( "Cannot load mapper implementation: " + classname, e );
}
}
-
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/MergingMapper.java Thu Nov 15 16:22:47 2007
@@ -26,28 +26,28 @@
* <p>This is the default FileNameMapper for the archiving tasks and
* uptodate.</p>
*
+ * @version $Id$
*/
-public class MergingMapper implements FileNameMapper {
+public class MergingMapper
+ implements FileNameMapper
+{
protected String mergedFile = null;
- /**
- * Ignored.
- */
- public void setFrom(String from) {
+ /** {@inheritDoc} */
+ public void setFrom( String from )
+ {
+ // nop
}
- /**
- * Sets the name of the merged file.
- */
- public void setTo(String to) {
+ /** {@inheritDoc} */
+ public void setTo( String to )
+ {
mergedFile = to;
}
- /**
- * Returns an one-element array containing the file name set via setTo.
- */
- public String mapFileName(String sourceFileName) {
+ /** {@inheritDoc} */
+ public String mapFileName( String sourceFileName )
+ {
return mergedFile;
}
-
}
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/PackageNameMapper.java Thu Nov 15 16:22:47 2007
@@ -30,19 +30,15 @@
* from="*Test.java" to="${test.data.dir}/TEST-*Test.xml"/>
* </pre>
*
+ * @version $Id$
*/
-public class PackageNameMapper extends GlobPatternMapper {
- /**
- * Returns the part of the given string that matches the * in the
- * "from" pattern replacing file separators with dots
- *
- *@param name Source filename
- *@return Replaced variable part
- */
- protected String extractVariablePart(String name) {
- String var = name.substring(prefixLength,
- name.length() - postfixLength);
- return var.replace(File.separatorChar, '.');
+public class PackageNameMapper
+ extends GlobPatternMapper
+{
+ /** {@inheritDoc} */
+ protected String extractVariablePart( String name )
+ {
+ String var = name.substring( prefixLength, name.length() - postfixLength );
+ return var.replace( File.separatorChar, '.' );
}
}
-
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/mappers/UnPackageNameMapper.java Thu Nov 15 16:22:47 2007
@@ -31,20 +31,15 @@
* from="${test.data.dir}/TEST-*Test.xml" to="*Test.java">
* </pre>
*
- *
+ * @version $Id$
*/
-public class UnPackageNameMapper extends GlobPatternMapper {
- /**
- * Returns the part of the given string that matches the * in the
- * "from" pattern replacing dots with file separators
- *
- *@param name Source filename
- *@return Replaced variable part
- */
- protected String extractVariablePart(String name) {
- String var = name.substring(prefixLength,
- name.length() - postfixLength);
- return var.replace('.', File.separatorChar);
+public class UnPackageNameMapper
+ extends GlobPatternMapper
+{
+ /** {@inheritDoc} */
+ protected String extractVariablePart( String name )
+ {
+ String var = name.substring( prefixLength, name.length() - postfixLength );
+ return var.replace( '.', File.separatorChar );
}
}
-
Modified: maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java (original)
+++ maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java Thu Nov 15 16:22:47 2007
@@ -49,11 +49,10 @@
* matching entries, etc.
*
* @author jdcasey
- *
+ * @version $Id$
*/
public class FileSetManager
{
-
private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -65,22 +64,20 @@
/**
* Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.
*
- * @param log
- * The mojo log instance
- * @param verbose
- * Whether to output verbose messages
+ * @param log The mojo log instance
+ * @param verbose Whether to output verbose messages
*/
public FileSetManager( Log log, boolean verbose )
{
if ( verbose )
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO,
+ new MojoLogSink( log ) );
}
else
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
+ new MojoLogSink( log ) );
}
this.verbose = verbose;
@@ -89,37 +86,32 @@
/**
* Create a new manager instance with the supplied log instance. Verbose flag is set to false.
*
- * @param log
- * The mojo log instance
+ * @param log The mojo log instance
*/
public FileSetManager( Log log )
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
+ new MojoLogSink( log ) );
this.verbose = false;
}
/**
* Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.
*
- * @param log
- * The mojo log instance
- * @param verbose
- * Whether to output verbose messages
+ * @param log The mojo log instance
+ * @param verbose Whether to output verbose messages
*/
public FileSetManager( Logger log, boolean verbose )
{
if ( verbose )
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO,
- new PlexusLoggerSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO,
+ new PlexusLoggerSink( log ) );
}
else
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
- new PlexusLoggerSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
+ new PlexusLoggerSink( log ) );
}
this.verbose = verbose;
@@ -128,21 +120,19 @@
/**
* Create a new manager instance with the supplied log instance. Verbose flag is set to false.
*
- * @param log
- * The mojo log instance
+ * @param log The mojo log instance
*/
public FileSetManager( Logger log )
{
- this.messages =
- new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) );
+ this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
+ new PlexusLoggerSink( log ) );
this.verbose = false;
}
/**
* Create a new manager instance with an empty messages. Verbose flag is set to false.
*
- * @param log
- * The mojo log instance
+ * @param log The mojo log instance
*/
public FileSetManager()
{
@@ -162,7 +152,7 @@
String sourcePath = sourcePaths[i];
String destPath;
- if( fileMapper != null )
+ if ( fileMapper != null )
{
destPath = fileMapper.mapFileName( sourcePath );
}
@@ -276,12 +266,13 @@
if ( messages != null && messages.isDebugEnabled() )
{
- messages.addDebugMessage( "Found deletable paths: " + String.valueOf( deletablePaths ).replace( ',', '\n' ) );
+ messages
+ .addDebugMessage( "Found deletable paths: " + String.valueOf( deletablePaths ).replace( ',', '\n' ) );
}
for ( Iterator it = deletablePaths.iterator(); it.hasNext(); )
{
- String path = ( String ) it.next();
+ String path = (String) it.next();
File file = new File( fileSet.getDirectory(), path );
@@ -321,11 +312,11 @@
if ( messages != null && messages.isDebugEnabled() )
{
messages.addDebugMessage( "Checking for symlink:\nParent file's canonical path: "
- + parent.getCanonicalPath() + "\nMy canonical path: " + canonicalFile.getPath() );
+ + parent.getCanonicalPath() + "\nMy canonical path: " + canonicalFile.getPath() );
}
return parent != null
- && ( !canonicalFile.getName().equals( file.getName() ) || !canonicalFile.getPath().startsWith(
- parent.getCanonicalPath() ) );
+ && ( !canonicalFile.getName().equals( file.getName() ) || !canonicalFile.getPath()
+ .startsWith( parent.getCanonicalPath() ) );
}
private Set findDeletablePaths( FileSet fileSet )
@@ -361,7 +352,8 @@
{
if ( verbose && messages != null )
{
- messages.addInfoMessage( "Adding symbolic link dirs which were previously excluded to the list being deleted." );
+ messages
+ .addInfoMessage( "Adding symbolic link dirs which were previously excluded to the list being deleted." );
}
// we need to see which entries were excluded because they're symlinks...
@@ -400,7 +392,7 @@
if ( messages != null && messages.isDebugEnabled() )
{
messages.addDebugMessage( "Verifying path: " + parentPath
- + " is not present; contains file which is excluded." );
+ + " is not present; contains file which is excluded." );
}
boolean removed = includes.remove( parentPath );
@@ -445,7 +437,8 @@
{
if ( verbose && messages != null )
{
- messages.addInfoMessage( "Adding symbolic link files which were previously excluded to the list being deleted." );
+ messages
+ .addInfoMessage( "Adding symbolic link files which were previously excluded to the list being deleted." );
}
// we need to see which entries were excluded because they're symlinks...
@@ -484,7 +477,7 @@
if ( messages != null && messages.isDebugEnabled() )
{
messages.addDebugMessage( "Verifying path: " + parentPath
- + " is not present; contains file which is excluded." );
+ + " is not present; contains file which is excluded." );
}
boolean removed = includes.remove( parentPath );
Modified: maven/shared/trunk/file-management/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java?rev=595501&r1=595500&r2=595501&view=diff
==============================================================================
--- maven/shared/trunk/file-management/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java (original)
+++ maven/shared/trunk/file-management/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java Thu Nov 15 16:22:47 2007
@@ -22,10 +22,8 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import junit.framework.Assert;
@@ -36,14 +34,21 @@
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.Commandline;
+/**
+ * Test the FileSet
+ *
+ * @version $Id$
+ */
public class FileSetUtilsTest
extends TestCase
{
-
private Set testDirectories = new HashSet();
+
private Set linkFiles = new HashSet();
- public void tearDown() throws IOException
+ /** {@inheritDoc} */
+ public void tearDown()
+ throws IOException
{
for ( Iterator it = linkFiles.iterator(); it.hasNext(); )
{
@@ -60,7 +65,11 @@
}
}
- public void testGetIncludedFiles() throws IOException
+ /**
+ * @throws IOException if any
+ */
+ public void testGetIncludedFiles()
+ throws IOException
{
File directory = setupTestDirectory( "testGetIncludedFiles" );
@@ -75,7 +84,13 @@
Assert.assertEquals( 1, included.length );
}
- public void testIncludesDontFollowSymlinks() throws IOException, InterruptedException, CommandLineException
+ /**
+ * @throws IOException if any
+ * @throws InterruptedException if any
+ * @throws CommandLineException if any
+ */
+ public void testIncludesDontFollowSymlinks()
+ throws IOException, InterruptedException, CommandLineException
{
File directory = setupTestDirectory( "testIncludesDontFollowSymlinks" );
File subdir = new File( directory, "linked-to-self" );
@@ -99,7 +114,13 @@
Assert.assertEquals( 1, included.length );
}
- public void testDeleteDontFollowSymlinks() throws IOException, InterruptedException, CommandLineException
+ /**
+ * @throws IOException if any
+ * @throws InterruptedException if any
+ * @throws CommandLineException if any
+ */
+ public void testDeleteDontFollowSymlinks()
+ throws IOException, InterruptedException, CommandLineException
{
File directory = setupTestDirectory( "testDeleteDontFollowSymlinks" );
File subdir = new File( directory, "linked-to-self" );
@@ -124,7 +145,11 @@
Assert.assertFalse( subdir.exists() );
}
- public void testDelete() throws IOException
+ /**
+ * @throws IOException if any
+ */
+ public void testDelete()
+ throws IOException
{
File directory = setupTestDirectory( "testDelete" );
File subdirFile = new File( directory, "subdir/excluded.txt" );
@@ -141,7 +166,15 @@
Assert.assertFalse( "file in marked subdirectory still exists.", subdirFile.exists() );
}
- private boolean createSymlink( File from, File to ) throws InterruptedException, CommandLineException
+ /**
+ * @param from
+ * @param to
+ * @return
+ * @throws InterruptedException
+ * @throws CommandLineException
+ */
+ private boolean createSymlink( File from, File to )
+ throws InterruptedException, CommandLineException
{
if ( to.exists() )
{
@@ -161,7 +194,13 @@
return result == 0;
}
- private File setupTestDirectory( String directoryName ) throws IOException
+ /**
+ * @param directoryName
+ * @return
+ * @throws IOException
+ */
+ private File setupTestDirectory( String directoryName )
+ throws IOException
{
System.out.println( "Setting up directory for test: " + directoryName );
@@ -186,5 +225,4 @@
return testDir;
}
-
}