org.apache.maven.plugins.site
Class AbstractDeployMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.maven.plugins.site.AbstractSiteMojo
          extended by org.apache.maven.plugins.site.AbstractDeployMojo
All Implemented Interfaces:
ContextEnabled, Mojo, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Direct Known Subclasses:
AbstractStagingMojo, SiteDeployMojo

public abstract class AbstractDeployMojo
extends AbstractSiteMojo
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

Abstract base class for deploy mojos. Since 2.3 this includes SiteStageMojo and SiteStageDeployMojo.

Since:
2.3
Author:
ltheussl

Field Summary
protected  MavenSession mavenSession
           
 
Fields inherited from class org.apache.maven.plugins.site.AbstractSiteMojo
i18n, locales, localRepository, project, reactorProjects, siteDirectory, siteTool
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractDeployMojo()
           
 
Method Summary
protected static String appendSlash(String url)
          Make sure the given url ends with a slash.
 void contextualize(org.codehaus.plexus.context.Context context)
          
protected abstract  Site determineDeploySite()
           
protected abstract  String determineTopDistributionManagementSiteUrl()
           
 void execute()
          
protected  String getDeployModuleDirectory()
          Find the relative path between the distribution URLs of the top site and the current project.
protected  Site getDeploySite()
          Get the site used for deployment, with its id to look up credential settings and the target URL for the deploy.
static ProxyInfo getProxyInfo(Repository repository, WagonManager wagonManager)
           Get the ProxyInfo of the proxy associated with the host and the protocol of the given repository.
protected static Site getSite(MavenProject project)
          Extract the distributionManagement site from the given MavenProject.
protected  String getTopDistributionManagementSiteUrl()
          Get the top distribution management site url, used for module relative path calculations.
protected  MavenProject getTopLevelProject(MavenProject project)
          Extract the distributionManagement site of the top level parent of the given MavenProject.
protected abstract  boolean isDeploy()
          Detect if the mojo is staging or deploying.
 
Methods inherited from class org.apache.maven.plugins.site.AbstractSiteMojo
getInputEncoding, getMavenVersion, getOutputEncoding, isMaven3OrMore
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mavenSession

@Component
protected MavenSession mavenSession
Since:
3.0-beta-2
Constructor Detail

AbstractDeployMojo

public AbstractDeployMojo()
Method Detail

execute

public void execute()
             throws MojoExecutionException

Specified by:
execute in interface Mojo
Throws:
MojoExecutionException

appendSlash

protected static String appendSlash(String url)
Make sure the given url ends with a slash.

Parameters:
url - a String.
Returns:
if url already ends with '/' it is returned unchanged, otherwise a '/' character is appended.

isDeploy

protected abstract boolean isDeploy()
Detect if the mojo is staging or deploying.

Returns:
true if the mojo is for deploy and not staging (local or deploy)

getTopDistributionManagementSiteUrl

protected String getTopDistributionManagementSiteUrl()
                                              throws MojoExecutionException
Get the top distribution management site url, used for module relative path calculations. This should be a top-level URL, ie above modules and locale sub-directories. Each deploy mojo can tweak algorithm to determine this top site by implementing determineTopDistributionManagementSiteUrl().

Returns:
the site for deployment
Throws:
MojoExecutionException
See Also:
determineTopDistributionManagementSiteUrl()

determineTopDistributionManagementSiteUrl

protected abstract String determineTopDistributionManagementSiteUrl()
                                                             throws MojoExecutionException
Throws:
MojoExecutionException

getDeploySite

protected Site getDeploySite()
                      throws MojoExecutionException
Get the site used for deployment, with its id to look up credential settings and the target URL for the deploy. This should be a top-level URL, ie above modules and locale sub-directories. Each deploy mojo can tweak algorithm to determine this deploy site by implementing determineDeploySite().

Returns:
the site for deployment
Throws:
MojoExecutionException
See Also:
determineDeploySite()

determineDeploySite

protected abstract Site determineDeploySite()
                                     throws MojoExecutionException
Throws:
MojoExecutionException

getDeployModuleDirectory

protected String getDeployModuleDirectory()
                                   throws MojoExecutionException
Find the relative path between the distribution URLs of the top site and the current project.

Returns:
the relative path or "./" if the two URLs are the same.
Throws:
MojoExecutionException

getProxyInfo

public static ProxyInfo getProxyInfo(Repository repository,
                                     WagonManager wagonManager)

Get the ProxyInfo of the proxy associated with the host and the protocol of the given repository.

Extract from J2SE Doc : Networking Properties - nonProxyHosts : "The value can be a list of hosts, each separated by a |, and in addition a wildcard character (*) can be used for matching"

Defensively support for comma (",") and semi colon (";") in addition to pipe ("|") as separator.

Parameters:
repository - the Repository to extract the ProxyInfo from.
wagonManager - the WagonManager used to connect to the Repository.
Returns:
a ProxyInfo object instantiated or null if no matching proxy is found

contextualize

public void contextualize(org.codehaus.plexus.context.Context context)
                   throws org.codehaus.plexus.context.ContextException

Specified by:
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Throws:
org.codehaus.plexus.context.ContextException

getSite

protected static Site getSite(MavenProject project)
                       throws MojoExecutionException
Extract the distributionManagement site from the given MavenProject.

Parameters:
project - the MavenProject. Not null.
Returns:
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.

getTopLevelProject

protected MavenProject getTopLevelProject(MavenProject project)
                                   throws MojoExecutionException
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 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.

Parameters:
project - the MavenProject. Not null.
Returns:
the top level site. Not null. Also site.getUrl() and site.getId() are guaranteed to be not null.
Throws:
MojoExecutionException - if no site info is found in the tree.
See Also:
URIPathDescriptor.sameSite(java.net.URI)


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.