Class AbstractDeployMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.site.AbstractSiteMojo
org.apache.maven.plugins.site.deploy.AbstractDeployMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Whether to run the "chmod" command on the remote site after the deploy.
    private String
    The mode used by the "chmod" command.
    private String
    The options used by the "chmod" command.
    private org.codehaus.plexus.PlexusContainer
     
    private org.apache.maven.model.Site
     
    private File
    Directory containing the generated project sites and report distributions.
    protected org.apache.maven.execution.MavenSession
     
    private org.apache.maven.settings.Settings
    The current user system settings for use in Maven.
    private boolean
    Set this to 'true' to skip site deployment.
    private String
     
    private org.apache.maven.artifact.manager.WagonManager
     

    Fields inherited from class org.apache.maven.plugins.site.AbstractSiteMojo

    i18n, localRepository, project, reactorProjects, siteTool, skip

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static String
    Make sure the given url ends with a slash.
    private static void
    chmod(org.apache.maven.wagon.Wagon wagon, org.apache.maven.wagon.repository.Repository repository, String chmodOptions, String chmodMode)
     
    private static void
    configureWagon(org.apache.maven.wagon.Wagon wagon, String repositoryId, org.apache.maven.settings.Settings settings, org.codehaus.plexus.PlexusContainer container, org.apache.maven.plugin.logging.Log log)
    Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
    private static void
    configureWagonWithMaven2(org.codehaus.plexus.component.configurator.ComponentConfigurator componentConfigurator, org.apache.maven.wagon.Wagon wagon, org.codehaus.plexus.configuration.PlexusConfiguration plexusConf, org.codehaus.plexus.PlexusContainer container)
     
    void
    contextualize(org.codehaus.plexus.context.Context context)
    private void
    deploy(File directory, org.apache.maven.wagon.repository.Repository repository)
     
    private void
    deployTo(org.apache.maven.wagon.repository.Repository repository)
    Use wagon to deploy the generated site to a given repository.
    protected abstract org.apache.maven.model.Site
     
    protected abstract String
     
    void
    protected String
    Find the relative path between the distribution URLs of the top site and the current project.
    protected org.apache.maven.model.Site
    Get the site used for deployment, with its id to look up credential settings and the target URL for the deploy.
    private static String
    getFullName(org.apache.maven.project.MavenProject project)
     
    private org.apache.maven.wagon.proxy.ProxyInfo
    getProxy(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter)
    Get proxy information for Maven 3.
    static org.apache.maven.wagon.proxy.ProxyInfo
    getProxyInfo(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.artifact.manager.WagonManager wagonManager)
    Get the ProxyInfo of the proxy associated with the host and the protocol of the given repository.
    protected static org.apache.maven.model.Site
    getSite(org.apache.maven.project.MavenProject project)
    Extract the distributionManagement site from the given MavenProject.
    private String
     
    protected String
    Get the top distribution management site url, used for module relative path calculations.
    protected org.apache.maven.project.MavenProject
    getTopLevelProject(org.apache.maven.project.MavenProject project)
    Extract the distributionManagement site of the top level parent of the given MavenProject.
    private org.apache.maven.wagon.Wagon
    getWagon(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.artifact.manager.WagonManager manager)
     
    protected abstract boolean
    Detect if the mojo is staging or deploying.
    private void
    push(File inputDirectory, org.apache.maven.wagon.repository.Repository repository, org.apache.maven.wagon.Wagon wagon, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo, List<Locale> localesList, String relativeDir)
     

    Methods inherited from class org.apache.maven.plugins.site.AbstractSiteMojo

    getLocales, getMavenVersion, 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 Details

    • inputDirectory

      @Parameter(alias="outputDirectory", defaultValue="${project.reporting.outputDirectory}", required=true) private File inputDirectory
      Directory containing the generated project sites and report distributions.
      Since:
      2.3
    • chmod

      @Parameter(property="maven.site.chmod", defaultValue="true") private boolean chmod
      Whether to run the "chmod" command on the remote site after the deploy. Defaults to "true".
      Since:
      2.1
    • chmodMode

      @Parameter(property="maven.site.chmod.mode", defaultValue="g+w,a+rX") private String chmodMode
      The mode used by the "chmod" command. Only used if chmod = true. Defaults to "g+w,a+rX".
      Since:
      2.1
    • chmodOptions

      @Parameter(property="maven.site.chmod.options", defaultValue="-Rf") private String chmodOptions
      The options used by the "chmod" command. Only used if chmod = true. Defaults to "-Rf".
      Since:
      2.1
    • skipDeploy

      @Parameter(property="maven.site.deploy.skip", defaultValue="false") private boolean skipDeploy
      Set this to 'true' to skip site deployment.
      Since:
      3.0
    • wagonManager

      @Component private org.apache.maven.artifact.manager.WagonManager wagonManager
    • settings

      @Parameter(defaultValue="${settings}", readonly=true) private org.apache.maven.settings.Settings settings
      The current user system settings for use in Maven.
    • mavenSession

      @Parameter(defaultValue="${session}", readonly=true) protected org.apache.maven.execution.MavenSession mavenSession
      Since:
      3.0-beta-2
    • topDistributionManagementSiteUrl

      private String topDistributionManagementSiteUrl
    • deploySite

      private org.apache.maven.model.Site deploySite
    • container

      private org.codehaus.plexus.PlexusContainer container
  • Constructor Details

    • AbstractDeployMojo

      public AbstractDeployMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.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 org.apache.maven.plugin.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:
      org.apache.maven.plugin.MojoExecutionException
      See Also:
    • determineTopDistributionManagementSiteUrl

      protected abstract String determineTopDistributionManagementSiteUrl() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getDeploySite

      protected org.apache.maven.model.Site getDeploySite() throws org.apache.maven.plugin.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:
      org.apache.maven.plugin.MojoExecutionException
      See Also:
    • determineDeploySite

      protected abstract org.apache.maven.model.Site determineDeploySite() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getDeployModuleDirectory

      protected String getDeployModuleDirectory() throws org.apache.maven.plugin.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:
      org.apache.maven.plugin.MojoExecutionException
    • deployTo

      private void deployTo(org.apache.maven.wagon.repository.Repository repository) throws org.apache.maven.plugin.MojoExecutionException
      Use wagon to deploy the generated site to a given repository.
      Parameters:
      repository - the repository to deploy to. This needs to contain a valid, non-null id to look up credentials for the deploy, and a valid, non-null scm url to deploy to.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the deploy fails.
    • deploy

      private void deploy(File directory, org.apache.maven.wagon.repository.Repository repository) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getWagon

      private org.apache.maven.wagon.Wagon getWagon(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.artifact.manager.WagonManager manager) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getSupportedProtocols

      private String getSupportedProtocols()
    • push

      private void push(File inputDirectory, org.apache.maven.wagon.repository.Repository repository, org.apache.maven.wagon.Wagon wagon, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo, List<Locale> localesList, String relativeDir) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • chmod

      private static void chmod(org.apache.maven.wagon.Wagon wagon, org.apache.maven.wagon.repository.Repository repository, String chmodOptions, String chmodMode) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getProxyInfo

      public static org.apache.maven.wagon.proxy.ProxyInfo getProxyInfo(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.artifact.manager.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
    • getProxy

      private org.apache.maven.wagon.proxy.ProxyInfo getProxy(org.apache.maven.wagon.repository.Repository repository, org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter)
      Get proxy information for Maven 3.
      Parameters:
      repository -
      settingsDecrypter -
      Returns:
    • configureWagon

      private static void configureWagon(org.apache.maven.wagon.Wagon wagon, String repositoryId, org.apache.maven.settings.Settings settings, org.codehaus.plexus.PlexusContainer container, org.apache.maven.plugin.logging.Log log) throws org.apache.maven.wagon.TransferFailedException
      Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
      Parameters:
      wagon -
      repositoryId -
      settings -
      container -
      log -
      Throws:
      org.apache.maven.wagon.TransferFailedException
    • configureWagonWithMaven2

      private static void configureWagonWithMaven2(org.codehaus.plexus.component.configurator.ComponentConfigurator componentConfigurator, org.apache.maven.wagon.Wagon wagon, org.codehaus.plexus.configuration.PlexusConfiguration plexusConf, org.codehaus.plexus.PlexusContainer container) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException
      Throws:
      org.codehaus.plexus.component.configurator.ComponentConfigurationException
    • 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 org.apache.maven.model.Site getSite(org.apache.maven.project.MavenProject project) throws org.apache.maven.plugin.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:
      org.apache.maven.plugin.MojoExecutionException - if any of the site info is missing.
    • getFullName

      private static String getFullName(org.apache.maven.project.MavenProject project)
    • getTopLevelProject

      protected org.apache.maven.project.MavenProject getTopLevelProject(org.apache.maven.project.MavenProject project) throws org.apache.maven.plugin.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:
      org.apache.maven.plugin.MojoExecutionException - if no site info is found in the tree.
      See Also:
      • URIPathDescriptor.sameSite(java.net.URI)