public void prepare()

in src/main/java/org/apache/tomee/website/Javadocs.java [84:141]


    public void prepare(final Source source) {
        final File javaSources = mkdirs(new File(String.format("target/javadocs/%s-src", source.getName())));

        copySource(source, source, javaSources);
        for (final Source related : source.getRelated()) {
            copySource(source, related, javaSources);
        }

        // This part will be completed later when the perform stage is executed
        source.addPerform(() -> {
            final File javadocOutput = sources.getGeneratedDestFor(source, "javadoc");
            final ProcessBuilder cmd = new ProcessBuilder(
                    getJavadocCommand().getAbsolutePath(),
                    "-tag", "example.en:a:Examples (en):",
                    "-tag", "example.es:a:Examples (es):",
                    "-tag", "example.pt:a:Examples (pt):",
                    "-sourcepath", javaSources.getAbsolutePath(),
                    "-d", javadocOutput.getAbsolutePath(),
                    "-encoding", "utf-8"
            );

            Stream.of(javaSources.listFiles())
                    .filter(File::isDirectory)
                    .forEach(file -> {
                        cmd.command().add("-subpackages");
                        cmd.command().add(file.getName());
                    });

            try {
                final Process process = cmd.start();
                Pipe.pipe(process);
                process.waitFor();
            } catch (IOException e) {
                throw new IllegalStateException("Command failed");
            } catch (InterruptedException e) {
                Thread.interrupted();
                throw new IllegalStateException("Command failed");
            }

            final String favicon = getFavicon(source);

            // Scrub generated timestamps as it causes 26k needless file updates
            // on the svn commit for every time the generator runs
            try {
                java.nio.file.Files.walk(javadocOutput.toPath())
                        .map(Path::toFile)
                        .filter(File::isFile)
                        .filter(this::isHtml)
                        .map(Content::from)
                        .map(Javadocs::removeGeneratedDate)
                        .map(content -> addFavicon(content, favicon))
                        .forEach(Content::write);
            } catch (IOException e) {
                throw new IllegalStateException("Failed to update generated javadoc html");
            }

        });
    }