Class AbstractWebAppMojo

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<ContextHandler> contextHandlers
      List of other contexts to set up.
      protected java.lang.String contextXml
      Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webApp>.Optional.
      protected AbstractWebAppMojo.DeploymentMode deployMode
      Controls how to run jetty.
      protected java.util.Map<java.lang.String,​java.lang.String> env
      Extra environment variables to be passed to the forked process
      protected java.lang.String[] excludedGoals
      List of goals that are NOT to be used
      protected org.apache.maven.plugin.MojoExecution execution
      The maven build executing.
      static java.lang.String FAKE_WEBAPP  
      protected java.io.File forkWebXml
      The file into which to generate the quickstart web xml for the forked process to use
      protected MavenServerConnector httpConnector
      A ServerConnector to use.
      static java.lang.String JETTY_HOME_ARTIFACTID  
      static java.lang.String JETTY_HOME_GROUPID  
      protected java.io.File jettyBase
      Location of jetty base directory
      protected java.io.File jettyHome
      Location of jetty home directory
      protected java.lang.String jettyOptions
      Extra options that can be passed to the jetty command line
      protected java.util.Map<java.lang.String,​java.lang.String> jettyProperties
      Optional jetty properties to put on the command line
      protected java.util.List<java.io.File> jettyXmls
      List of jetty xml configuration files whose contents will be applied (in order declared) before any plugin configuration.
      protected java.lang.String jvmArgs
      Arbitrary jvm args to pass to the forked process
      protected java.util.List<LoginService> loginServices
      List of security realms to set up.
      protected MavenProjectHelper mavenProjectHelper
      Helper for interacting with the maven project space
      protected long maxChildStartCheckMs
      How long to wait in msec between checks to see if jetty has started correctly when running in FORK or EXTERNAL mode.
      protected int maxChildStartChecks
      Max number of times to check to see if jetty has started correctly when running in FORK or EXTERNAL mode.
      protected java.util.Map<java.lang.String,​java.lang.String> mergedSystemProperties
      System properties from both systemPropertyFile and systemProperties.
      protected java.lang.String[] modules
      Optional list of other modules to activate.
      protected Resource originalBaseResource
      Webapp base before applying overlays etc
      protected org.apache.maven.plugin.descriptor.PluginDescriptor plugin
      This plugin
      protected java.util.List<org.apache.maven.artifact.Artifact> pluginArtifacts
      The artifacts for the plugin itself.
      protected org.apache.maven.project.MavenProject project
      The maven project.
      protected java.util.Set<org.apache.maven.artifact.Artifact> projectArtifacts
      The artifacts for the project.
      protected java.util.List<java.io.File> providedJars
      List of jars with scope=provided
      protected java.util.List<org.apache.maven.project.MavenProject> reactorProjects  
      protected RequestLog requestLog
      A RequestLog implementation to use for the webapp at runtime.
      protected java.util.List<ScanTargetPattern> scanTargetPatterns
      List of directories with ant-style <include> and <exclude> patterns for extra targets to periodically scan for changes.Optional.
      protected Server server
      A wrapper for the Server object
      protected boolean skip
      Skip this mojo execution.
      protected java.lang.String stopKey
      Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
      protected int stopPort
      Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop
      protected java.util.List<java.lang.String> supportedPackagings
      Default supported project type is war packaging.
      protected java.util.Map<java.lang.String,​java.lang.String> systemProperties
      System properties to set before execution.
      protected java.io.File systemPropertiesFile
      File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties.
      protected java.io.File target
      The target directory
      protected boolean useProvidedScope
      Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate jars/classes.
      protected boolean useTestScope
      If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.
      protected java.util.List<org.apache.maven.artifact.Artifact> warArtifacts
      List of deps that are wars
      protected MavenWebAppContext webApp
      An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void augmentPluginClasspath()
      Augment jetty's classpath with dependencies marked as scope=provided if useProvidedScope==true.
      protected void configureScanTargetPatterns​(Scanner scanner)
      Configure any extra files, directories or patterns thereof for the scanner to watch for changes.
      protected void configureSystemProperties()  
      protected void configureWebApp()
      Ensure there is a webapp, and that some basic defaults are applied if the user has not supplied them.
      void execute()  
      protected java.io.File findJettyWebXmlFile​(java.io.File webInfDir)
      Try and find a jetty-web.xml file, using some historical naming conventions if necessary.
      protected java.lang.String getContainerClassPath()
      Synthesize a classpath appropriate for a forked jetty based off the artifacts associated with the jetty plugin, plus any dependencies that are marked as provided and useProvidedScope is true.
      protected java.io.File getJettyOutputFile​(java.lang.String name)
      Get a file into which to write output from jetty.
      protected java.lang.String getProjectName()  
      protected java.util.List<java.io.File> getProvidedJars()
      Get any dependencies that are scope "provided" if useProvidedScope == true.
      protected boolean isExcludedGoal​(java.lang.String goal)
      Check if the goal that we're executing as is excluded or not.
      protected boolean isPackagingSupported()  
      protected boolean isPluginArtifact​(org.apache.maven.artifact.Artifact artifact)
      Check to see if the given artifact is one of the dependency artifacts for this plugin.
      protected java.util.Map<java.lang.String,​java.lang.String> mergeSystemProperties()
      Unite system properties set via systemPropertiesFile element and the systemProperties element.
      protected JettyEmbedder newJettyEmbedder()  
      protected JettyForker newJettyForker()  
      protected JettyHomeForker newJettyHomeForker()  
      protected void startJetty()  
      protected abstract void startJettyEmbedded()  
      protected abstract void startJettyForked()  
      protected abstract void startJettyHome()  
      protected void verifyPomConfiguration()
      Used by subclasses.
      • 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

      • JETTY_HOME_GROUPID

        public static final java.lang.String JETTY_HOME_GROUPID
        See Also:
        Constant Field Values
      • JETTY_HOME_ARTIFACTID

        public static final java.lang.String JETTY_HOME_ARTIFACTID
        See Also:
        Constant Field Values
      • maxChildStartChecks

        @Parameter(defaultValue="10")
        protected int maxChildStartChecks
        Max number of times to check to see if jetty has started correctly when running in FORK or EXTERNAL mode.
      • maxChildStartCheckMs

        @Parameter(defaultValue="200")
        protected long maxChildStartCheckMs
        How long to wait in msec between checks to see if jetty has started correctly when running in FORK or EXTERNAL mode.
      • useProvidedScope

        @Parameter(defaultValue="false")
        protected boolean useProvidedScope
        Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate jars/classes.
        Since:
        jetty-7.5.2
      • excludedGoals

        @Parameter
        protected java.lang.String[] excludedGoals
        List of goals that are NOT to be used
        Since:
        jetty-7.5.2
      • webApp

        @Parameter
        protected MavenWebAppContext webApp
        An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp. Use any of its setters to configure the webapp. This is the preferred and most flexible method of configuration, rather than using the (deprecated) individual parameters like "tmpDirectory", "contextPath" etc.
      • skip

        @Parameter(property="jetty.skip",
                   defaultValue="false")
        protected boolean skip
        Skip this mojo execution.
      • contextXml

        @Parameter
        protected java.lang.String contextXml
        Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webApp>.Optional.
      • project

        @Parameter(defaultValue="${project}",
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        The maven project.
      • projectArtifacts

        @Parameter(defaultValue="${project.artifacts}",
                   readonly=true)
        protected java.util.Set<org.apache.maven.artifact.Artifact> projectArtifacts
        The artifacts for the project.
      • execution

        @Parameter(defaultValue="${mojoExecution}",
                   readonly=true)
        protected org.apache.maven.plugin.MojoExecution execution
        The maven build executing.
      • pluginArtifacts

        @Parameter(defaultValue="${plugin.artifacts}",
                   readonly=true)
        protected java.util.List<org.apache.maven.artifact.Artifact> pluginArtifacts
        The artifacts for the plugin itself.
      • useTestScope

        @Parameter(defaultValue="false")
        protected boolean useTestScope
        If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.
      • scanTargetPatterns

        @Parameter
        protected java.util.List<ScanTargetPattern> scanTargetPatterns
        List of directories with ant-style <include> and <exclude> patterns for extra targets to periodically scan for changes.Optional.
      • reactorProjects

        @Parameter(defaultValue="${reactorProjects}",
                   readonly=true,
                   required=true)
        protected java.util.List<org.apache.maven.project.MavenProject> reactorProjects
      • target

        @Parameter(defaultValue="${project.build.directory}",
                   required=true,
                   readonly=true)
        protected java.io.File target
        The target directory
      • jettyXmls

        @Parameter
        protected java.util.List<java.io.File> jettyXmls
        List of jetty xml configuration files whose contents will be applied (in order declared) before any plugin configuration. Optional.
      • jettyProperties

        @Parameter
        protected java.util.Map<java.lang.String,​java.lang.String> jettyProperties
        Optional jetty properties to put on the command line
      • systemPropertiesFile

        @Parameter(property="jetty.systemPropertiesFile")
        protected java.io.File systemPropertiesFile
        File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties. Optional.
      • systemProperties

        @Parameter
        protected java.util.Map<java.lang.String,​java.lang.String> systemProperties
        System properties to set before execution. Note that these properties will NOT override System properties that have been set on the command line or by the JVM. They WILL override System properties that have been set via systemPropertiesFile. Optional.
      • deployMode

        @Parameter(property="jetty.deployMode",
                   defaultValue="EMBED")
        protected AbstractWebAppMojo.DeploymentMode deployMode
        Controls how to run jetty. Valid values are EMBED,FORK,EXTERNAL.
      • contextHandlers

        @Parameter
        protected java.util.List<ContextHandler> contextHandlers
        List of other contexts to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.
      • loginServices

        @Parameter
        protected java.util.List<LoginService> loginServices
        List of security realms to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.
      • requestLog

        @Parameter
        protected RequestLog requestLog
        A RequestLog implementation to use for the webapp at runtime. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.
      • server

        @Parameter
        protected Server server
        A wrapper for the Server object
      • env

        @Parameter
        protected java.util.Map<java.lang.String,​java.lang.String> env
        Extra environment variables to be passed to the forked process
      • jvmArgs

        @Parameter(property="jetty.jvmArgs")
        protected java.lang.String jvmArgs
        Arbitrary jvm args to pass to the forked process
      • stopPort

        @Parameter
        protected int stopPort
        Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop
      • stopKey

        @Parameter
        protected java.lang.String stopKey
        Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
      • jettyHome

        @Parameter
        protected java.io.File jettyHome
        Location of jetty home directory
      • jettyBase

        @Parameter
        protected java.io.File jettyBase
        Location of jetty base directory
      • modules

        @Parameter
        protected java.lang.String[] modules
        Optional list of other modules to activate.
      • jettyOptions

        @Parameter(property="jetty.options")
        protected java.lang.String jettyOptions
        Extra options that can be passed to the jetty command line
      • forkWebXml

        @Parameter(defaultValue="${project.build.directory}/fork-web.xml")
        protected java.io.File forkWebXml
        The file into which to generate the quickstart web xml for the forked process to use
      • mavenProjectHelper

        protected MavenProjectHelper mavenProjectHelper
        Helper for interacting with the maven project space
      • plugin

        @Parameter(defaultValue="${plugin}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.plugin.descriptor.PluginDescriptor plugin
        This plugin
      • supportedPackagings

        @Parameter
        protected java.util.List<java.lang.String> supportedPackagings
        Default supported project type is war packaging.
      • warArtifacts

        protected java.util.List<org.apache.maven.artifact.Artifact> warArtifacts
        List of deps that are wars
      • originalBaseResource

        protected Resource originalBaseResource
        Webapp base before applying overlays etc
      • providedJars

        protected java.util.List<java.io.File> providedJars
        List of jars with scope=provided
      • mergedSystemProperties

        protected java.util.Map<java.lang.String,​java.lang.String> mergedSystemProperties
        System properties from both systemPropertyFile and systemProperties.
    • Constructor Detail

      • AbstractWebAppMojo

        public AbstractWebAppMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • startJetty

        protected void startJetty()
                           throws org.apache.maven.plugin.MojoExecutionException,
                                  org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • startJettyEmbedded

        protected abstract void startJettyEmbedded()
                                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • startJettyForked

        protected abstract void startJettyForked()
                                          throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • startJettyHome

        protected abstract void startJettyHome()
                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • newJettyEmbedder

        protected JettyEmbedder newJettyEmbedder()
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • newJettyForker

        protected JettyForker newJettyForker()
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • newJettyHomeForker

        protected JettyHomeForker newJettyHomeForker()
                                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • verifyPomConfiguration

        protected void verifyPomConfiguration()
                                       throws org.apache.maven.plugin.MojoExecutionException
        Used by subclasses.
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • mergeSystemProperties

        protected java.util.Map<java.lang.String,​java.lang.String> mergeSystemProperties()
                                                                                        throws org.apache.maven.plugin.MojoExecutionException
        Unite system properties set via systemPropertiesFile element and the systemProperties element. Properties from the pom override properties from the file.
        Returns:
        united properties map
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configureSystemProperties

        protected void configureSystemProperties()
                                          throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • augmentPluginClasspath

        protected void augmentPluginClasspath()
                                       throws org.apache.maven.plugin.MojoExecutionException
        Augment jetty's classpath with dependencies marked as scope=provided if useProvidedScope==true.
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getProvidedJars

        protected java.util.List<java.io.File> getProvidedJars()
                                                        throws org.apache.maven.plugin.MojoExecutionException
        Get any dependencies that are scope "provided" if useProvidedScope == true. Ensure that only those dependencies that are not already present via the plugin are included.
        Returns:
        provided scope dependencies that are not also plugin dependencies.
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getContainerClassPath

        protected java.lang.String getContainerClassPath()
                                                  throws java.lang.Exception
        Synthesize a classpath appropriate for a forked jetty based off the artifacts associated with the jetty plugin, plus any dependencies that are marked as provided and useProvidedScope is true.
        Returns:
        jetty classpath
        Throws:
        java.lang.Exception
      • isPluginArtifact

        protected boolean isPluginArtifact​(org.apache.maven.artifact.Artifact artifact)
        Check to see if the given artifact is one of the dependency artifacts for this plugin.
        Parameters:
        artifact - to check
        Returns:
        true if it is a plugin dependency, false otherwise
      • isExcludedGoal

        protected boolean isExcludedGoal​(java.lang.String goal)
        Check if the goal that we're executing as is excluded or not.
        Parameters:
        goal - the goal to check
        Returns:
        true if the goal is excluded, false otherwise
      • isPackagingSupported

        protected boolean isPackagingSupported()
      • getProjectName

        protected java.lang.String getProjectName()
      • configureWebApp

        protected void configureWebApp()
                                throws java.lang.Exception
        Ensure there is a webapp, and that some basic defaults are applied if the user has not supplied them.
        Throws:
        java.lang.Exception
      • findJettyWebXmlFile

        protected java.io.File findJettyWebXmlFile​(java.io.File webInfDir)
        Try and find a jetty-web.xml file, using some historical naming conventions if necessary.
        Parameters:
        webInfDir - the web inf directory
        Returns:
        the jetty web xml file
      • getJettyOutputFile

        protected java.io.File getJettyOutputFile​(java.lang.String name)
                                           throws java.lang.Exception
        Get a file into which to write output from jetty.
        Parameters:
        name - the name of the file
        Returns:
        the created file
        Throws:
        java.lang.Exception
      • configureScanTargetPatterns

        protected void configureScanTargetPatterns​(Scanner scanner)
                                            throws java.io.IOException
        Configure any extra files, directories or patterns thereof for the scanner to watch for changes.
        Parameters:
        scanner - Scanner that notices changes in files and dirs.
        Throws:
        java.io.IOException