{
if ( additionalConfig != null )
{
for ( int j = 0; j < additionalConfig.length; j++ )
{
EclipseConfigFile file = additionalConfig[j];
File projectRelativeFile = new File( eclipseProjectDir, file.getName() );
if ( projectRelativeFile.isDirectory() )
{
// just ignore?
getLog().warn( Messages.getString( "EclipsePlugin.foundadir", //$NON-NLS-1$
projectRelativeFile.getAbsolutePath() ) );
}
try
{
projectRelativeFile.getParentFile().mkdirs();
if ( file.getContent() == null )
{
InputStream inStream;
if ( file.getLocation() != null )
{
inStream = locator.getResourceAsInputStream( file.getLocation() );
}
else
{
inStream = file.getURL().openConnection().getInputStream();
}
OutputStream outStream = new FileOutputStream( projectRelativeFile );
try
{
IOUtil.copy( inStream, outStream );
}
finally
{
inStream.close();
outStream.close();
}
}
else
{
FileUtils.fileWrite( projectRelativeFile.getAbsolutePath(), file.getContent() );
}
}
catch ( IOException e )
{
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantwritetofile", //$NON-NLS-1$
projectRelativeFile.getAbsolutePath() ) );
}
catch ( ResourceNotFoundException e )
{
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantfindresource", //$NON-NLS-1$
file.getLocation() ) );
}
}
}
}