Search in sources :

Example 1 with Site

use of org.apache.maven.model.Site 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)

Example 2 with Site

use of org.apache.maven.model.Site in project maven-plugins by apache.

the class SiteStageMojo method determineDeploySite.

@Override
protected Site determineDeploySite() throws MojoExecutionException {
    Site staging = new Site();
    staging.setId("stagingLocal");
    final File outputDirectory = determineStagingDirectory();
    getLog().info("Using this base directory for staging: " + outputDirectory);
    // Safety
    if (!outputDirectory.exists()) {
        outputDirectory.mkdirs();
    }
    staging.setUrl("file://" + outputDirectory.getAbsolutePath());
    return staging;
}
Also used : Site(org.apache.maven.model.Site) File(java.io.File)

Example 3 with Site

use of org.apache.maven.model.Site in project maven-plugins by apache.

the class AbstractDeployMojo method getSite.

/**
     * Extract the distributionManagement site from the given MavenProject.
     *
     * @param project the MavenProject. Not null.
     * @return the project site. Not null.
     *         Also site.getUrl() and site.getId() are guaranteed to be not null.
     * @throws MojoExecutionException if any of the site info is missing.
     */
protected static Site getSite(final MavenProject project) throws MojoExecutionException {
    final DistributionManagement distributionManagement = project.getDistributionManagement();
    if (distributionManagement == null) {
        throw new MojoExecutionException("Missing distribution management in project " + getFullName(project));
    }
    final Site site = distributionManagement.getSite();
    if (site == null) {
        throw new MojoExecutionException("Missing site information in the distribution management of the project " + getFullName(project));
    }
    if (site.getUrl() == null || site.getId() == null) {
        throw new MojoExecutionException("Missing site data: specify url and id for project " + getFullName(project));
    }
    return site;
}
Also used : Site(org.apache.maven.model.Site) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DistributionManagement(org.apache.maven.model.DistributionManagement)

Example 4 with Site

use of org.apache.maven.model.Site in project maven-plugins by apache.

the class SiteStageDeployMojo method determineDeploySite.

@Override
protected Site determineDeploySite() throws MojoExecutionException {
    Site top = new Site();
    top.setId(stagingRepoId());
    getLog().info("Using this server ID for stage deploy: " + top.getId());
    String stagingURL = determineStageDeploySiteURL();
    getLog().info("Using this base URL for stage deploy: " + stagingURL);
    top.setUrl(stagingURL);
    return top;
}
Also used : Site(org.apache.maven.model.Site)

Aggregations

Site (org.apache.maven.model.Site)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 File (java.io.File)1 URIPathDescriptor (org.apache.maven.doxia.site.decoration.inheritance.URIPathDescriptor)1 DistributionManagement (org.apache.maven.model.DistributionManagement)1 MavenProject (org.apache.maven.project.MavenProject)1