Search in sources :

Example 1 with URIPathDescriptor

use of org.apache.maven.doxia.site.decoration.inheritance.URIPathDescriptor in project maven-plugins by apache.

the class AbstractDeployMojo method getTopLevelProject.

/**
     * Extract the distributionManagement site of the top level parent of the given MavenProject.
     * This climbs up the project hierarchy and returns the site of the last project
     * for which {@link #getSite(org.apache.maven.project.MavenProject)} returns a site that resides in the
     * same site. Notice that it doesn't take into account if the parent is in the reactor or not.
     *
     * @param project the MavenProject. Not <code>null</code>.
     * @return the top level site. Not <code>null</code>.
     *         Also site.getUrl() and site.getId() are guaranteed to be not <code>null</code>.
     * @throws MojoExecutionException if no site info is found in the tree.
     * @see URIPathDescriptor#sameSite(java.net.URI)
     */
protected MavenProject getTopLevelProject(MavenProject project) throws MojoExecutionException {
    Site site = getSite(project);
    MavenProject parent = project;
    while (parent.getParent() != null) {
        MavenProject oldProject = parent;
        // MSITE-585, MNG-1943
        parent = siteTool.getParentProject(parent, reactorProjects, localRepository);
        Site oldSite = site;
        try {
            site = getSite(parent);
        } catch (MojoExecutionException e) {
            return oldProject;
        }
        // MSITE-600
        URIPathDescriptor siteURI = new URIPathDescriptor(URIEncoder.encodeURI(site.getUrl()), "");
        URIPathDescriptor oldSiteURI = new URIPathDescriptor(URIEncoder.encodeURI(oldSite.getUrl()), "");
        if (!siteURI.sameSite(oldSiteURI.getBaseURI())) {
            return oldProject;
        }
    }
    return parent;
}
Also used : Site(org.apache.maven.model.Site) URIPathDescriptor(org.apache.maven.doxia.site.decoration.inheritance.URIPathDescriptor) MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Aggregations

URIPathDescriptor (org.apache.maven.doxia.site.decoration.inheritance.URIPathDescriptor)1 Site (org.apache.maven.model.Site)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MavenProject (org.apache.maven.project.MavenProject)1