FileSet createFileSet()

in src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java [427:513]


    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 (!AssemblyFileUtils.isAbsolutePath(sourceDir)) {
                sourcePath = new File(moduleBasedir, sourcePath).getAbsolutePath();
            }
        } else {
            sourcePath = moduleBasedir.getAbsolutePath();
        }

        fs.setDirectory(sourcePath);
        fs.setDirectoryMode(fileSet.getDirectoryMode());

        final List<String> excludes = new ArrayList<>();

        final List<String> originalExcludes = fileSet.getExcludes();
        if ((originalExcludes != null) && !originalExcludes.isEmpty()) {
            excludes.addAll(originalExcludes);
        }

        if (sources.isExcludeSubModuleDirectories()) {
            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());

        FixedStringSearchInterpolator moduleProjectInterpolator =
                AssemblyFormatUtils.moduleProjectInterpolator(moduleProject);
        FixedStringSearchInterpolator artifactProjectInterpolator =
                AssemblyFormatUtils.artifactProjectInterpolator(moduleProject);
        String destPathPrefix = "";
        if (sources.isIncludeModuleDirectory()) {
            destPathPrefix = AssemblyFormatUtils.evaluateFileNameMapping(
                    sources.getOutputDirectoryMapping(),
                    moduleProject.getArtifact(),
                    configSource.getProject(),
                    moduleProject.getArtifact(),
                    configSource,
                    moduleProjectInterpolator,
                    artifactProjectInterpolator);

            if (!destPathPrefix.endsWith("/")) {
                destPathPrefix += "/";
            }
        }

        String destPath = fileSet.getOutputDirectory();

        if (destPath == null) {
            destPath = destPathPrefix;
        } else {
            destPath = destPathPrefix + destPath;
        }

        destPath = AssemblyFormatUtils.getOutputDirectory(
                destPath,
                configSource.getFinalName(),
                configSource,
                moduleProjectInterpolator,
                artifactProjectInterpolator);

        fs.setOutputDirectory(destPath);

        LOGGER.debug("module source directory is: " + sourcePath);
        LOGGER.debug("module dest directory is: " + destPath + " (assembly basedir may be prepended)");

        return fs;
    }