Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/main/java/org/apache/maven/plugins/ear/EarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
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;
Expand Down Expand Up @@ -480,9 +482,10 @@ private void copyModules( final JavaEEVersion javaEEVersion,
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 ) )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks to be modified by mistake. It should remain:

if ( module.changeManifestClasspath() )

Copy link
Copy Markdown
Contributor

@mabrarov mabrarov Dec 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened MEAR-293 bug for this issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to pull request #30 for the fix of this bug.

{
changeManifestClasspath( module, destinationFile, javaEEVersion );
}
Expand Down Expand Up @@ -707,20 +710,26 @@ public String getMappedFileName( String pName )
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() );
}
}

Expand Down