This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new d2a13b7 replace deprecated method no longer needed in Java 7+ (#26)
d2a13b7 is described below
commit d2a13b7d8515f38ba564e57759efc93e3cc2be14
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Thu Dec 10 13:19:50 2020 +0000
replace deprecated method no longer needed in Java 7+ (#26)
* replace deprecated method no longer needed in Java 7+
---
.../java/org/apache/maven/plugins/ear/EarMojo.java | 31 ++++++++++++++--------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
index 258a1cc..611e5a5 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -27,9 +27,11 @@ import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
+import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
@@ -480,9 +482,10 @@ public class EarMojo
if ( sourceFile.lastModified() >
destinationFile.lastModified() )
{
getLog().info( "Copying artifact [" + module + "] to
[" + module.getUri() + "]" );
- FileUtils.copyFile( sourceFile, destinationFile );
-
- if ( module.changeManifestClasspath() )
+ createParentIfNecessary( destinationFile );
+ Files.copy( sourceFile.toPath(),
destinationFile.toPath(),
+ LinkOption.NOFOLLOW_LINKS,
StandardCopyOption.REPLACE_EXISTING );
+ if ( module.changeManifestClasspath() && ( skinnyWars
|| module.getLibDir() == null ) )
{
changeManifestClasspath( module, destinationFile,
javaEEVersion );
}
@@ -707,20 +710,26 @@ public class EarMojo
private void copyFile( File source, File target )
throws MavenFilteringException, IOException, MojoExecutionException
{
+ createParentIfNecessary( target );
if ( filtering && !isNonFilteredExtension( source.getName() ) )
{
- // Silly that we have to do this ourselves
- File parentDirectory = target.getParentFile();
- if ( parentDirectory != null && !parentDirectory.exists() )
- {
- Files.createDirectories( parentDirectory.toPath() );
- }
-
mavenFileFilter.copyFile( source, target, true,
getFilterWrappers(), encoding );
}
else
{
- FileUtils.copyFile( source, target );
+ Files.copy( source.toPath(), target.toPath(),
LinkOption.NOFOLLOW_LINKS,
+ StandardCopyOption.REPLACE_EXISTING );
+ }
+ }
+
+ private void createParentIfNecessary( File target )
+ throws IOException
+ {
+ // Silly that we have to do this ourselves
+ File parentDirectory = target.getParentFile();
+ if ( parentDirectory != null && !parentDirectory.exists() )
+ {
+ Files.createDirectories( parentDirectory.toPath() );
}
}