if ( isEmpty( resourcesArtifacts ) )
{
return;
}
UnArchiver unArchiver;
try
{
unArchiver = archiverManager.getUnArchiver( "jar" );
}
catch ( NoSuchArchiverException e )
{
throw new MavenReportException(
"Unable to extract resources artifact. " + "No archiver for 'jar' available.", e );
}
for ( ResourcesArtifact item : resourcesArtifacts )
{
Artifact artifact;
try
{
artifact = createAndResolveArtifact( item );
}
catch ( ArtifactResolutionException e )
{
throw new MavenReportException( "Unable to resolve artifact:" + item, e );
}
catch ( ArtifactNotFoundException e )
{
throw new MavenReportException( "Unable to find artifact:" + item, e );
}
catch ( ProjectBuildingException e )
{
throw new MavenReportException( "Unable to build the Maven project for the artifact:" + item, e );
}
unArchiver.setSourceFile( artifact.getFile() );
unArchiver.setDestDirectory( anOutputDirectory );
// remove the META-INF directory from resource artifact
IncludeExcludeFileSelector[] selectors =
new IncludeExcludeFileSelector[]{ new IncludeExcludeFileSelector() };
selectors[0].setExcludes( new String[]{ "META-INF/**" } );
unArchiver.setFileSelectors( selectors );
getLog().info( "Extracting contents of resources artifact: " + artifact.getArtifactId() );
try
{
unArchiver.extract();
}
catch ( ArchiverException e )
{
throw new MavenReportException(
"Extraction of resources failed. Artifact that failed was: " + artifact.getArtifactId(), e );