protected FileSet createFileSet( final FileSet fileSet, final ModuleSources sources,
final MavenProject moduleProject, final AssemblerConfigurationSource configSource )
throws AssemblyFormattingException
{
final FileSet fs = new FileSet();
String sourcePath = fileSet.getDirectory();
final File moduleBasedir = moduleProject.getBasedir();
if ( sourcePath != null )
{
final File sourceDir = new File( sourcePath );
if ( !sourceDir.isAbsolute() )
{
sourcePath = new File( moduleBasedir, sourcePath ).getAbsolutePath();
}
}
else
{
sourcePath = moduleBasedir.getAbsolutePath();
}
fs.setDirectory( sourcePath );
fs.setDirectoryMode( fileSet.getDirectoryMode() );
final List<String> excludes = new ArrayList<String>();
final List<String> originalExcludes = fileSet.getExcludes();
if ( ( originalExcludes != null ) && !originalExcludes.isEmpty() )
{
excludes.addAll( originalExcludes );
}
if ( sources.isExcludeSubModuleDirectories() )
{
@SuppressWarnings( "unchecked" )
final List<String> modules = moduleProject.getModules();
for (final String moduleSubPath : modules) {
excludes.add(moduleSubPath + "/**");
}
}
fs.setExcludes( excludes );
fs.setFiltered( fileSet.isFiltered() );
fs.setFileMode( fileSet.getFileMode() );
fs.setIncludes( fileSet.getIncludes() );
fs.setLineEnding( fileSet.getLineEnding() );
String destPathPrefix = "";
if ( sources.isIncludeModuleDirectory() )
{
destPathPrefix =
AssemblyFormatUtils.evaluateFileNameMapping( sources.getOutputDirectoryMapping(),
moduleProject.getArtifact(), configSource.getProject(),
moduleProject, moduleProject.getArtifact(), moduleProject,
configSource );
if ( !destPathPrefix.endsWith( "/" ) )
{
destPathPrefix += "/";
}
}
String destPath = fileSet.getOutputDirectory();
if ( destPath == null )
{
destPath = destPathPrefix;
}
else
{
destPath = destPathPrefix + destPath;
}
destPath =
AssemblyFormatUtils.getOutputDirectory( destPath, configSource.getProject(), moduleProject, moduleProject,
configSource.getFinalName(), configSource );
fs.setOutputDirectory( destPath );
getLogger().debug( "module source directory is: " + sourcePath );
getLogger().debug( "module dest directory is: " + destPath + " (assembly basedir may be prepended)" );
return fs;