Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-898] prefer JDK classes to DirectoryScanner #45

Merged
merged 2 commits into from May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,7 +23,10 @@
/**
* Scan for files in a directory at a given time and reports removed and added files
* between captures.
*
* @deprecated use {@code java.nio.file.DirectoryStream} and related classes
*/
@Deprecated
public class DirectoryScanResult
{
private final String[] filesAdded;
Expand Down
Expand Up @@ -108,7 +108,9 @@
* @author Magesh Umasankar
* @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a>
* @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a>
* @deprecated use {@code java.nio.file.DirectoryStream} and related classes
*/
@Deprecated
public class DirectoryScanner
{
/**
Expand Down Expand Up @@ -452,9 +454,9 @@ public DirectoryScanResult diffIncludedFiles( String... oldFiles )
}

/**
* @param oldFiles array of old files.
* @param newFiles array of new files.
* @return calculated differerence.
* @param oldFiles array of old files
* @param newFiles array of new files
* @return calculated difference
*/
public static DirectoryScanResult diffFiles( @Nullable String[] oldFiles, @Nullable String[] newFiles )
{
Expand Down
Expand Up @@ -22,24 +22,25 @@
import java.io.File;

/**
* DirectoryWalkListener
*
*
* DirectoryWalkListener.
*
* @deprecated use {@code java.nio.file.FileVisitor} and related classes
*/
@Deprecated
public interface DirectoryWalkListener
{
/**
* The directory walking has begun.
*
* @param basedir the basedir that walk started in.
* @param basedir the basedir that walk started in
*/
void directoryWalkStarting( File basedir );

/**
* The included entry that was encountered.
*
* @param percentage rough percentage of the walk completed. (inaccurate)
* @param file the file that was included.
* @param file the file that was included
*/
void directoryWalkStep( int percentage, File file );

Expand All @@ -49,7 +50,7 @@ public interface DirectoryWalkListener
void directoryWalkFinished();

/**
* @param message The message for the debugging output.
* @param message the message for the debugging output
*/
void debug( String message );
}
Expand Up @@ -33,7 +33,9 @@
* Significantly more efficient than using strings, since re-evaluation and re-tokenizing is avoided.
*
* @author Kristian Rosenvold
* @deprecated use {@code java.nio.filejava.nio.file.DirectoryStream.Filter<T>} and related classes
*/
@Deprecated
public class MatchPattern
{
private final String source;
Expand Down Expand Up @@ -98,7 +100,7 @@ public boolean matchPatternStart( @Nonnull String str, boolean isCaseSensitive )
{
if ( regexPattern != null )
{
// FIXME: ICK! But we can't do partial matches for regex, so we have to reserve judgement until we have
// FIXME: ICK! But we can't do partial matches for regex, so we have to reserve judgment until we have
// a file to deal with, or we can definitely say this is an exclusion...
return true;
}
Expand Down
Expand Up @@ -27,7 +27,9 @@
* A list of patterns to be matched
*
* @author Kristian Rosenvold
* @deprecated use {@code java.nio.filejava.nio.file.DirectoryStream.Filter<T>} and related classes
*/
@Deprecated
public class MatchPatterns
{
private final MatchPattern[] patterns;
Expand Down
Expand Up @@ -33,7 +33,10 @@
* cleaned between two scan() invocations.</p>
*
* @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
*
* @deprecated use {@code java.nio.file.Files.walkFileTree()} and related classes
*/
@Deprecated
public interface ScanConductor
{
/**
Expand Down
Expand Up @@ -39,7 +39,9 @@
* @author Magesh Umasankar
* @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a>
*
* @deprecated use {@code java.nio.file.Files.walkFileTree()} and related classes
*/
@Deprecated
public final class SelectorUtils
{

Expand Down
Expand Up @@ -23,9 +23,10 @@
import java.util.ArrayList;
import java.util.List;

/**
*
/**
* @deprecated use {@code java.nio.file.FileVisitor} and related classes
*/
@Deprecated
public class WalkCollector
implements DirectoryWalkListener
{
Expand Down
Expand Up @@ -37,6 +37,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;

@SuppressWarnings( "deprecation" )
public class DirectoryScannerTest
{
private static final String[] NONE = new String[0];
Expand Down Expand Up @@ -214,7 +215,6 @@ public void followSymlinks()
/*
Creates a standard directory layout with symlinks and files.
*/

@Test
public void testSimpleExcludes()
throws Exception
Expand Down Expand Up @@ -243,7 +243,7 @@ public void testSimpleExcludes()
/* expExclDirs */ NONE );
}

public void testIsSymLin()
public void testIsSymbolicLink()
throws IOException
{
File file = new File( "." );
Expand Down
Expand Up @@ -20,7 +20,6 @@
*/

import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.IOUtil;
import org.junit.rules.TemporaryFolder;

import java.io.*;
Expand Down Expand Up @@ -71,20 +70,12 @@ public static void createLineBasedFile( File file, String[] data )
throw new IOException( "Cannot create file " + file + " as the parent directory does not exist" );
}

PrintWriter out = null;
try
try ( PrintWriter out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) ) )
{
out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
for ( String aData : data )
{
out.println( aData );
}
out.close();
out = null;
}
finally
{
IOUtil.close( out );
}
}

Expand Down