Package org.eclipse.jetty.maven.plugin
Class AbstractJettyMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.eclipse.jetty.maven.plugin.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.AbstractMojoCommon base class for most jetty mojos.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ThreadconsoleScannerA scanner to check ENTER hits on the consoleprotected ContextHandler[]contextHandlersList of other contexts to set up.protected java.lang.StringcontextXmlLocation of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webApp>.Optional.protected booleandumpOnStartUse the dump() facility of jetty to print out the server configuration to loggingprotected java.lang.String[]excludedGoalsList of goals that are NOT to be usedprotected org.apache.maven.plugin.MojoExecutionexecutionprotected MavenServerConnectorhttpConnectorA ServerConnector to use.protected java.lang.StringjettyXmlComma separated list of a jetty xml configuration files whose contents will be applied before any plugin configuration.protected LoginService[]loginServicesList of security realms to set up.protected booleannonBlockingDetermines whether or not the server blocks when started.protected java.util.List<org.apache.maven.artifact.Artifact>pluginArtifactsThe artifacts for the plugin itself.protected org.apache.maven.project.MavenProjectprojectThe maven project.protected java.util.Set<org.apache.maven.artifact.Artifact>projectArtifactsThe artifacts for the project.protected java.lang.Stringreloadreload 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 RequestLogrequestLogA RequestLog implementation to use for the webapp at runtime.protected intscanIntervalSecondsThe interval in seconds to scan the webapp for changes and restart the context if necessary.protected ScannerscannerA scanner to check for changes to the webappprotected ServerserverA wrapper for the Server objectprotected ServerSupportserverSupportprotected booleanskipSkip this mojo execution.protected java.lang.StringstopKeyKey to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stopprotected intstopPortPort to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stopprotected java.util.List<java.lang.String>supportedPackagingsPer default this goal support onlywarpackaging.protected SystemPropertiessystemPropertiesSystem properties to set before execution.protected java.io.FilesystemPropertiesFileFile 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 booleanuseProvidedScopeWhether 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 JettyWebAppContextwebAppAn instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp.
-
Constructor Summary
Constructors Constructor Description AbstractJettyMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapplyJettyXml()booleancheckPackagingConfiguration()booleancheckPomConfiguration()voidconfigureMonitor()voidconfigurePluginClasspath()abstract voidconfigureScanner()voidconfigureWebApplication()Subclasses should invoke this to setup basic info on the webappvoidexecute()java.io.FilefindJettyWebXmlFile(java.io.File webInfDir)Try and find a jetty-web.xml file, using some historical naming conventions if necessary.voidfinishConfigurationBeforeStart()java.util.List<java.io.File>getJettyXmlFiles()protected java.lang.StringgetSkipMessage(java.lang.String reason)booleanisConfigurationSupported()booleanisExcluded(java.lang.String goal)booleanisPluginArtifact(org.apache.maven.artifact.Artifact artifact)booleanisScanningEnabled()protected voidprintSystemProperties()abstract voidrestartWebApp(boolean reconfigureScanner)voidsetSystemProperties(SystemProperties systemProperties)voidsetSystemPropertiesFile(java.io.File file)protected voidstartConsoleScanner()Run a thread that monitors the console input to detect ENTER hits.voidstartJetty()voidstartScanner()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.voidstopScanner()
-
-
-
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 scanIntervalSecondsThe 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 reloadreload 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 dumpOnStartUse the dump() facility of jetty to print out the server configuration to logging
-
skip
@Parameter(property="jetty.skip", defaultValue="false") protected boolean skipSkip 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 projectThe maven project.
-
projectArtifacts
@Parameter(defaultValue="${project.artifacts}", readonly=true) protected java.util.Set<org.apache.maven.artifact.Artifact> projectArtifactsThe 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> pluginArtifactsThe artifacts for the plugin itself.
-
httpConnector
@Parameter protected MavenServerConnector httpConnector
A ServerConnector to use.
-
server
@Parameter protected Server server
A wrapper for the Server object
-
scanner
protected Scanner 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
-
serverSupport
protected ServerSupport serverSupport
-
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 onlywarpackaging. If your project use an other type please configure it here.
-
-
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.MojoExecutionExceptionorg.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.ExceptionSubclasses 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.ExceptionRun 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.ExceptionRun 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)
-
-