private Path constructJavadocLocation()

in maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java [471:523]


    private Path constructJavadocLocation() throws IOException {
        Path location = null;
        if (linkJavadoc) {
            // We don't need to do the whole translation thing like normal, because JXR does it internally.
            // It probably shouldn't.
            if (getJavadocLocation().exists()) {
                // XRef was already generated by manual execution of a lifecycle binding
                location = getJavadocLocation().toPath().toAbsolutePath();
            } else {
                // Not yet generated - check if the report is on its way

                // Special case: using the site:stage goal
                String stagingDirectory = System.getProperty("stagingDirectory");

                if (stagingDirectory != null && !stagingDirectory.isEmpty()) {
                    String javadocOutputDir = getJavadocLocation().getName();
                    boolean javadocAggregate = JxrReportUtil.isJavadocAggregated(project);
                    String structureProject = JxrReportUtil.getStructure(project, false);

                    if (isAggregate() && javadocAggregate) {
                        location = Paths.get(stagingDirectory, structureProject, javadocOutputDir);
                    }
                    if (!isAggregate() && javadocAggregate) {
                        location = Paths.get(stagingDirectory, javadocOutputDir);

                        String hierarchy = project.getName();

                        MavenProject parent = project.getParent();
                        while (parent != null) {
                            hierarchy = parent.getName();
                            parent = parent.getParent();
                        }
                        location = Paths.get(stagingDirectory, hierarchy, javadocOutputDir);
                    }
                    if (isAggregate() && !javadocAggregate) {
                        getLog().warn("The JXR plugin is configured to build an aggregated report at the root, "
                                + "not the Javadoc plugin.");
                    }
                    if (!isAggregate() && !javadocAggregate) {
                        location = Paths.get(stagingDirectory, structureProject, javadocOutputDir);
                    }
                } else {
                    location = getJavadocLocation().toPath();
                }
            }

            if (location == null) {
                getLog().warn("Unable to locate Javadoc to link to - DISABLED");
            }
        }

        return location;
    }