private void postProcessSourcesDirectory()

in src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java [1147:1183]


    private void postProcessSourcesDirectory(
            final ApisJarContext ctx,
            final ArtifactInfo info,
            final Set<String> foundPackages,
            final File dir,
            final String readEncoding,
            final String pck)
            throws MojoExecutionException {
        boolean hasSourceFile = false;
        for (final File child : dir.listFiles()) {
            if (child.isDirectory()) {
                postProcessSourcesDirectory(
                        ctx,
                        info,
                        foundPackages,
                        child,
                        readEncoding,
                        pck.isEmpty() ? child.getName() : pck.concat(".").concat(child.getName()));
            } else if (child.getName().endsWith(ArtifactType.SOURCES.getContentExtension())) {
                hasSourceFile = true;
                if (readEncoding != null) {
                    try {
                        final String javaSource = FileUtils.fileRead(child, readEncoding);
                        FileUtils.fileWrite(child, StandardCharsets.UTF_8.name(), javaSource);
                    } catch (final IOException ioe) {
                        throw new MojoExecutionException("Unable to clean up java source " + child, ioe);
                    }
                }
            }
        }
        if (dir.listFiles().length == 0 && !pck.isEmpty()) {
            // empty dir -> remove
            dir.delete();
        } else if (hasSourceFile) {
            foundPackages.add(pck);
        }
    }