File workspaceProjectBaseDir, boolean test, final String output )
throws MojoExecutionException
{
for ( Iterator it = resources.iterator(); it.hasNext(); )
{
Resource resource = (Resource) it.next();
getLog().debug( "Processing resource dir: " + resource.getDirectory() );
String includePattern = null;
String excludePattern = null;
if ( resource.getIncludes().size() != 0 )
{
includePattern = StringUtils.join( resource.getIncludes().iterator(), "|" );
}
if ( resource.getExcludes().size() != 0 )
{
excludePattern = StringUtils.join( resource.getExcludes().iterator(), "|" );
}
// TODO: figure out how to merge if the same dir is specified twice
// with different in/exclude patterns.
File resourceDirectory = new File( /* basedir, */resource.getDirectory() );
if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() )
{
getLog().debug( "Resource dir: " + resourceDirectory + " either missing or not a directory." );
continue;
}
String resourceDir =
IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, resourceDirectory,
!workspaceProjectBaseDir.equals( basedir ) );
String thisOutput = output;
if ( thisOutput != null )
{
// sometimes thisOutput is already an absolute path
File outputFile = new File( thisOutput );
if ( !outputFile.isAbsolute() )
{
outputFile = new File( workspaceProjectBaseDir, thisOutput );
}
// create output dir if it doesn't exist
outputFile.mkdirs();
if ( !StringUtils.isEmpty( resource.getTargetPath() ) )
{
outputFile = new File( outputFile, resource.getTargetPath() );
// create output dir if it doesn't exist
outputFile.mkdirs();
}
getLog().debug(
"Making relative and fixing separator: { " + workspaceProjectBaseDir + ", " +
outputFile + ", false }." );
thisOutput = IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, outputFile, false );
}
getLog().debug(
"Adding eclipse source dir: { " + resourceDir + ", " + thisOutput + ", true, " + test +
", " + includePattern + ", " + excludePattern + " }." );
directories.add( new EclipseSourceDir( resourceDir, thisOutput, true, test, includePattern, excludePattern,
resource.isFiltering() ) );
}
}