Skip to content

Commit

Permalink
Merge pull request #15 from apache/ear-285
Browse files Browse the repository at this point in the history
[MEAR-285] check return value from mkdirs
  • Loading branch information
elharo authored Sep 26, 2020
2 parents 7f666e1 + 6908415 commit 95a50c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
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 @@ -473,7 +473,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() )
{
throw new MojoExecutionException( "Error creating " + destinationFile );
}
unpack( sourceFile, destinationFile, outdatedResources );

if ( skinnyWars && module.changeManifestClasspath() )
Expand Down Expand Up @@ -715,9 +718,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

0 comments on commit 95a50c7

Please sign in to comment.