protected void archiveProjectContent()

in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java [381:424]


    protected void archiveProjectContent(Project project, Archiver archiver) throws MojoException {
        if (includePom) {
            try {
                File pom = project.getPomPath().toFile();
                archiver.addFile(pom, pom.getName());
            } catch (ArchiverException e) {
                throw new MojoException("Error adding POM file to target jar file.", e);
            }
        }

        for (Path sourceDirectory : getSources(project)) {
            if (Files.exists(sourceDirectory)) {
                addDirectory(archiver, sourceDirectory, getCombinedIncludes(null), getCombinedExcludes(null));
            }
        }

        // MAPI: this should be taken from the resources plugin
        for (Resource resource : getResources(project)) {

            Path sourceDirectory = Paths.get(resource.getDirectory());

            if (!Files.exists(sourceDirectory)) {
                continue;
            }

            List<String> resourceIncludes = resource.getIncludes();

            String[] combinedIncludes = getCombinedIncludes(resourceIncludes);

            List<String> resourceExcludes = resource.getExcludes();

            String[] combinedExcludes = getCombinedExcludes(resourceExcludes);

            String targetPath = resource.getTargetPath();
            if (targetPath != null) {
                if (!targetPath.trim().endsWith("/")) {
                    targetPath += "/";
                }
                addDirectory(archiver, sourceDirectory, targetPath, combinedIncludes, combinedExcludes);
            } else {
                addDirectory(archiver, sourceDirectory, combinedIncludes, combinedExcludes);
            }
        }
    }