Class AbstractJettyMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    JettyRunMojo, JettyRunWarExplodedMojo, JettyRunWarMojo

    public abstract class AbstractJettyMojo
    extends org.apache.maven.plugin.AbstractMojo
    Common base class for most jetty mojos.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Thread consoleScanner
      A scanner to check ENTER hits on the console
      protected 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 boolean dumpOnStart
      Use the dump() facility of jetty to print out the server configuration to logging
      protected java.lang.String[] excludedGoals
      List of goals that are NOT to be used
      protected org.apache.maven.plugin.MojoExecution execution  
      protected MavenServerConnector httpConnector
      A ServerConnector to use.
      protected java.lang.String jettyXml
      Comma separated list of a jetty xml configuration files whose contents will be applied before any plugin configuration.
      protected LoginService[] loginServices
      List of security realms to set up.
      protected boolean nonBlocking
      Determines whether or not the server blocks when started.
      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.lang.String reload
      reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.
      protected RequestLog requestLog
      A RequestLog implementation to use for the webapp at runtime.
      protected int scanIntervalSeconds
      The interval in seconds to scan the webapp for changes and restart the context if necessary.
      protected PathWatcher scanner
      A scanner to check for changes to the webapp
      protected Server server
      A wrapper for the Server object
      protected ServerSupport serverSupport  
      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
      Per default this goal support only war packaging.
      protected SystemProperties 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 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 JettyWebAppContext webApp
      An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Field Detail

      • 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
      • contextHandlers

        @Parameter
        protected 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 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.
      • webApp

        @Parameter(alias="webAppConfig")
        protected JettyWebAppContext 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.
      • scanIntervalSeconds

        @Parameter(property="jetty.scanIntervalSeconds",
                   defaultValue="0",
                   required=true)
        protected int scanIntervalSeconds
        The interval in seconds to scan the webapp for changes and restart the context if necessary. Ignored if reload is enabled. Disabled by default.
      • reload

        @Parameter(property="jetty.reload",
                   defaultValue="automatic")
        protected java.lang.String reload
        reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.
      • 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 SystemProperties 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.
      • jettyXml

        @Parameter(alias="jettyConfig")
        protected java.lang.String jettyXml
        Comma separated list of a jetty xml configuration files whose contents will be applied before any plugin configuration. Optional.
      • 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
      • dumpOnStart

        @Parameter(property="dumponStart",
                   defaultValue="false")
        protected boolean dumpOnStart
        Use the dump() facility of jetty to print out the server configuration to logging
      • skip

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

        @Parameter(alias="webAppXml")
        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
      • pluginArtifacts

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

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

        protected PathWatcher scanner
        A scanner to check for changes to the webapp
      • consoleScanner

        protected java.lang.Thread consoleScanner
        A scanner to check ENTER hits on the console
      • nonBlocking

        @Parameter(defaultValue="false")
        protected boolean nonBlocking

        Determines whether or not the server blocks when started. The default behavior (false) will cause the server to pause other processes while it continues to handle web requests. This is useful when starting the server with the intent to work with it interactively. This is the behaviour of the jetty:run, jetty:run-war, jetty:run-war-exploded goals.

        If true, the server will not block the execution of subsequent code. This is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.

      • supportedPackagings

        @Parameter
        protected java.util.List<java.lang.String> supportedPackagings
        Per default this goal support only war packaging. If your project use an other type please configure it here.
    • Constructor Detail

      • AbstractJettyMojo

        public AbstractJettyMojo()
    • Method Detail

      • restartWebApp

        public abstract void restartWebApp​(boolean reconfigureScanner)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • checkPomConfiguration

        public boolean checkPomConfiguration()
                                      throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configureScanner

        public abstract void configureScanner()
                                       throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getSkipMessage

        protected java.lang.String getSkipMessage​(java.lang.String reason)
      • checkPackagingConfiguration

        public boolean checkPackagingConfiguration()
      • 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
        See Also:
        Mojo.execute()
      • isConfigurationSupported

        public boolean isConfigurationSupported()
                                         throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configurePluginClasspath

        public void configurePluginClasspath()
                                      throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • isPluginArtifact

        public boolean isPluginArtifact​(org.apache.maven.artifact.Artifact artifact)
      • finishConfigurationBeforeStart

        public void finishConfigurationBeforeStart()
                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • applyJettyXml

        public void applyJettyXml()
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • startJetty

        public void startJetty()
                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configureMonitor

        public void configureMonitor()
      • configureWebApplication

        public void configureWebApplication()
                                     throws java.lang.Exception
        Subclasses should invoke this to setup basic info on the webapp
        Throws:
        java.lang.Exception - if unable to configure web application
      • startScanner

        public void startScanner()
                          throws java.lang.Exception
        Run a scanner thread on the given list of files and directories, calling stop/start on the given list of LifeCycle objects if any of the watched files change.
        Throws:
        java.lang.Exception - if unable to start scanner
      • isScanningEnabled

        public boolean isScanningEnabled()
      • stopScanner

        public void stopScanner()
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • startConsoleScanner

        protected void startConsoleScanner()
                                    throws java.lang.Exception
        Run a thread that monitors the console input to detect ENTER hits.
        Throws:
        java.lang.Exception - if unable to start the console
      • printSystemProperties

        protected void printSystemProperties()
      • findJettyWebXmlFile

        public 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
      • setSystemPropertiesFile

        public void setSystemPropertiesFile​(java.io.File file)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setSystemProperties

        public void setSystemProperties​(SystemProperties systemProperties)
      • getJettyXmlFiles

        public java.util.List<java.io.File> getJettyXmlFiles()
      • isExcluded

        public boolean isExcluded​(java.lang.String goal)