Skip to content

Commit

Permalink
Revert "[MSHARED-966] Use NIO to copy files instead of deprecated met…
Browse files Browse the repository at this point in the history
…hod from m-shared-utils"

This reverts commit 7e0adf5
  • Loading branch information
slachiewicz committed Dec 22, 2021
1 parent 680717c commit a6c95ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
*/

import java.io.File;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.util.List;

import org.apache.maven.execution.MavenSession;
Expand Down Expand Up @@ -105,20 +103,12 @@ public void copyFile( File from, File to, boolean filtering, List<FileUtils.Filt
{
getLogger().debug( "copy " + from.getPath() + " to " + to.getPath() );
}
if ( overwrite )
{
Files.copy( from.toPath(), to.toPath(), LinkOption.NOFOLLOW_LINKS,
StandardCopyOption.REPLACE_EXISTING );
}
else
{
Files.copy( from.toPath(), to.toPath(), LinkOption.NOFOLLOW_LINKS );
}
FileUtils.copyFile( from, to, encoding, new FileUtils.FilterWrapper[0], overwrite );
}

buildContext.refresh( to );
}
catch ( Exception e )
catch ( IOException e )
{
throw new MavenFilteringException( ( filtering ? "filtering " : "copying " ) + from.getPath() + " to "
+ to.getPath() + " failed with " + e.getClass().getSimpleName() + ": " + e.getMessage(), e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.File;
import java.io.Reader;
import java.io.StringReader;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -70,18 +69,7 @@ public void testNotOverwriteFile()

to.setLastModified( System.currentTimeMillis() );

try
{
mavenFileFilter.copyFile( from, to, false, null, null );
}
catch ( MavenFilteringException mfe )
{
// dest file already exist - overwrite by default false
if ( !( mfe.getCause() instanceof FileAlreadyExistsException ) )
{
fail( mfe.getMessage() );
}
}
mavenFileFilter.copyFile( from, to, false, null, null );

Properties properties = PropertyUtils.loadPropertyFile( to, null );
assertEquals( "${pom.version}", properties.getProperty( "version" ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,6 @@ public void testShouldReturnGitIgnoreFiles()

File outputDirectory = new File( getBasedir(), "/target/testGitIgnoreFile" );

if ( outputDirectory.exists() )
{
FileUtils.forceDelete( outputDirectory );
}
List<Resource> resources = new ArrayList<>();
resources.add( new Resource()
{
Expand Down

0 comments on commit a6c95ef

Please sign in to comment.