in src/main/java/org/apache/maven/plugins/ear/EarMojo.java [412:490]
private void copyModules( final JavaEEVersion javaEEVersion,
List<String> unpackTypesList,
Collection<String> outdatedResources )
throws MojoExecutionException, MojoFailureException
{
try
{
for ( EarModule module : getModules() )
{
final File sourceFile = module.getArtifact().getFile();
final File destinationFile = buildDestinationFile( getWorkDirectory(), module.getUri() );
if ( !sourceFile.isFile() )
{
throw new MojoExecutionException( "Cannot copy a directory: " + sourceFile.getAbsolutePath()
+ "; Did you package/install " + module.getArtifact() + "?" );
}
if ( destinationFile.getCanonicalPath().equals( sourceFile.getCanonicalPath() ) )
{
getLog().info( "Skipping artifact [" + module + "], as it already exists at [" + module.getUri()
+ "]" );
// FIXME: Shouldn't that result in a build failure!?
continue;
}
// If the module is within the unpack list, make sure that no unpack wasn't forced (null or true)
// If the module is not in the unpack list, it should be true
if ( ( unpackTypesList.contains( module.getType() )
&& ( module.shouldUnpack() == null || module.shouldUnpack() ) )
|| ( module.shouldUnpack() != null && module.shouldUnpack() ) )
{
getLog().info( "Copying artifact [" + module + "] to [" + module.getUri() + "] (unpacked)" );
// Make sure that the destination is a directory to avoid plexus nasty stuff :)
if ( !destinationFile.isDirectory() && !destinationFile.mkdirs() )
{
throw new MojoExecutionException( "Error creating " + destinationFile );
}
unpack( sourceFile, destinationFile, outdatedResources );
if ( module.changeManifestClasspath() )
{
changeManifestClasspath( module, destinationFile, javaEEVersion, outdatedResources );
}
}
else
{
if ( sourceFile.lastModified() > destinationFile.lastModified() )
{
getLog().info( "Copying artifact [" + module + "] to [" + module.getUri() + "]" );
createParentIfNecessary( destinationFile );
Files.copy( sourceFile.toPath(), destinationFile.toPath(),
LinkOption.NOFOLLOW_LINKS, StandardCopyOption.REPLACE_EXISTING );
if ( module.changeManifestClasspath() )
{
changeManifestClasspath( module, destinationFile, javaEEVersion, outdatedResources );
}
}
else
{
getLog().debug( "Skipping artifact [" + module + "], as it is already up to date at ["
+ module.getUri() + "]" );
}
removeFromOutdatedResources( destinationFile.toPath(), outdatedResources );
}
}
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error copying EAR modules", e );
}
catch ( ArchiverException e )
{
throw new MojoExecutionException( "Error unpacking EAR modules", e );
}
catch ( NoSuchArchiverException e )
{
throw new MojoExecutionException( "No Archiver found for EAR modules", e );
}
}