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

[MEAR-285] check return value from mkdirs #15

Merged
merged 1 commit into from
Sep 26, 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
10 changes: 7 additions & 3 deletions src/main/java/org/apache/maven/plugins/ear/EarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ private void copyModules( final JavaEEVersion javaEEVersion,
{
getLog().info( "Copying artifact [" + module + "] to [" + module.getUri() + "] (unpacked)" );
// Make sure that the destination is a directory to avoid plexus nasty stuff :)
destinationFile.mkdirs();
if ( !destinationFile.mkdirs() )
Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems to be causing an issue when build is run without "clean".
[INFO] Copying artifact [ejb:com.aaa.bbb:bbb-ejb:1.0.0.0-SNAPSHOT] to [bbb-ejb.jar]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:3.1.0:ear (default-ear) on project bbb-ear: Failed to create directory /Checkout/project/bbb/bbb-ear/target/temp/bbb-ejb.jar -> [Help 1]

Probably it should be wrapped with something like:

if ( !destinationFile.isDirectory() )
{
    if ( !destinationFile.mkdirs() )
    {
        throw new MojoExecutionException( "Error creating " + destinationFile );
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad. That's not the right place.

Copy link
Contributor

Choose a reason for hiding this comment

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

{
throw new MojoExecutionException( "Error creating " + destinationFile );
}
unpack( sourceFile, destinationFile, outdatedResources );

if ( skinnyWars && module.changeManifestClasspath() )
Expand Down Expand Up @@ -695,9 +698,10 @@ private void copyFile( File source, File target )
if ( filtering && !isNonFilteredExtension( source.getName() ) )
{
// Silly that we have to do this ourselves
if ( target.getParentFile() != null && !target.getParentFile().exists() )
File parentDirectory = target.getParentFile();
if ( parentDirectory != null && !parentDirectory.exists() )
{
target.getParentFile().mkdirs();
Files.createDirectories( parentDirectory.toPath() );
}

mavenFileFilter.copyFile( source, target, true, getFilterWrappers(), encoding );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ protected void generateStandardDeploymentDescriptor( JavaEEVersion javaEEVersion
File outputDir = new File( generatedDescriptorLocation );
if ( !outputDir.exists() )
{
outputDir.mkdirs();
if ( !outputDir.mkdirs() )
{
throw new EarPluginException( "Error creating " + outputDir );
}
}

File descriptor = new File( outputDir, "application.xml" );
Expand All @@ -253,7 +256,7 @@ protected void generateStandardDeploymentDescriptor( JavaEEVersion javaEEVersion
}

/**
* Generates the jboss deployment descriptor.
* Generates the JBoss deployment descriptor.
*
* @throws EarPluginException if the configuration is invalid
*/
Expand All @@ -263,7 +266,10 @@ protected void generateJbossDeploymentDescriptor()
File outputDir = new File( generatedDescriptorLocation );
if ( !outputDir.exists() )
{
outputDir.mkdirs();
if ( !outputDir.mkdirs() )
{
throw new EarPluginException( "Error creating " + outputDir );
}
}

File descriptor = new File( outputDir, "jboss-app.xml" );
Expand Down