Package org.eclipse.jetty.maven.plugin
Class AbstractWebAppMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.eclipse.jetty.maven.plugin.AbstractWebAppMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractUnassembledWebAppMojo
,JettyRunWarMojo
,JettyStartWarMojo
,JettyStopMojo
public abstract class AbstractWebAppMojo
extends org.apache.maven.plugin.AbstractMojo
AbstractWebAppMojo
Base class for common behaviour of jetty mojos.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected List<ContextHandler>
List of other contexts to set up.protected String
Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webApp>.Optional.protected AbstractWebAppMojo.DeploymentMode
Controls how to run jetty.Extra environment variables to be passed to the forked processprotected String[]
List of goals that are NOT to be usedprotected org.apache.maven.plugin.MojoExecution
The maven build executing.static final String
protected File
The file into which to generate the quickstart web xml for the forked process to useprotected MavenServerConnector
A ServerConnector to use.static final String
static final String
protected File
Location of jetty base directoryprotected File
Location of jetty home directoryprotected String
Extra options that can be passed to the jetty command lineOptional jetty properties to put on the command lineList of jetty xml configuration files whose contents will be applied (in order declared) before any plugin configuration.protected String
Arbitrary jvm args to pass to the forked processprotected List<LoginService>
List of security realms to set up.protected MavenProjectHelper
Helper for interacting with the maven project spaceprotected long
How long to wait in msec between checks to see if jetty has started correctly when running in FORK or EXTERNAL mode.protected int
Max number of times to check to see if jetty has started correctly when running in FORK or EXTERNAL mode.System properties from both systemPropertyFile and systemProperties.protected String[]
Optional list of other modules to activate.protected Resource
Webapp base before applying overlays etcprotected org.apache.maven.plugin.descriptor.PluginDescriptor
This pluginprotected List<org.apache.maven.artifact.Artifact>
The artifacts for the plugin itself.protected org.apache.maven.project.MavenProject
The maven project.protected Set<org.apache.maven.artifact.Artifact>
The artifacts for the project.List of jars with scope=providedprotected List<org.apache.maven.project.MavenProject>
protected RequestLog
A RequestLog implementation to use for the webapp at runtime.protected List<ScanTargetPattern>
List of directories with ant-style <include> and <exclude> patterns for extra targets to periodically scan for changes.Optional.protected Server
A wrapper for the Server objectprotected boolean
Skip this mojo execution.protected String
Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stopprotected int
Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stopDefault supported project type iswar
packaging.System properties to set before execution.protected File
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 File
The target directoryprotected boolean
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
If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.protected List<org.apache.maven.artifact.Artifact>
List of deps that are warsprotected MavenWebAppContext
An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
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
protected void
Ensure there is a webapp, and that some basic defaults are applied if the user has not supplied them.void
execute()
protected File
findJettyWebXmlFile
(File webInfDir) Try and find a jetty-web.xml file, using some historical naming conventions if necessary.protected String
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 File
getJettyOutputFile
(String name) Get a file into which to write output from jetty.protected String
Get any dependencies that are scope "provided" if useProvidedScope == true.protected boolean
isExcludedGoal
(String goal) Check if the goal that we're executing as is excluded or not.protected boolean
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.Unite system properties set via systemPropertiesFile element and the systemProperties element.protected JettyEmbedder
protected JettyForker
protected JettyHomeForker
protected void
protected abstract void
protected abstract void
protected abstract void
protected void
Used by subclasses.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
JETTY_HOME_GROUPID
- See Also:
-
JETTY_HOME_ARTIFACTID
- See Also:
-
FAKE_WEBAPP
- See Also:
-
maxChildStartChecks
@Parameter(defaultValue="10") protected int maxChildStartChecksMax 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 maxChildStartCheckMsHow 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 useProvidedScopeWhether 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
List of goals that are NOT to be used- Since:
- jetty-7.5.2
-
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 skipSkip this mojo execution. -
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 Set<org.apache.maven.artifact.Artifact> projectArtifactsThe artifacts for the project. -
execution
@Parameter(defaultValue="${mojoExecution}", readonly=true) protected org.apache.maven.plugin.MojoExecution executionThe maven build executing. -
pluginArtifacts
@Parameter(defaultValue="${plugin.artifacts}", readonly=true) protected List<org.apache.maven.artifact.Artifact> pluginArtifactsThe artifacts for the plugin itself. -
useTestScope
@Parameter(defaultValue="false") protected boolean useTestScopeIf true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath. -
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 List<org.apache.maven.project.MavenProject> reactorProjects -
target
@Parameter(defaultValue="${project.build.directory}", required=true, readonly=true) protected File targetThe target directory -
jettyXmls
List of jetty xml configuration files whose contents will be applied (in order declared) before any plugin configuration. Optional. -
jettyProperties
Optional jetty properties to put on the command line -
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
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 deployModeControls how to run jetty. Valid values are EMBED,FORK,EXTERNAL. -
contextHandlers
List of other contexts to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional. -
loginServices
List of security realms to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional. -
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. -
httpConnector
A ServerConnector to use. -
server
A wrapper for the Server object -
env
Extra environment variables to be passed to the forked process -
jvmArgs
Arbitrary jvm args to pass to the forked process -
stopPort
@Parameter protected int stopPortPort to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop -
stopKey
Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop -
jettyHome
Location of jetty home directory -
jettyBase
Location of jetty base directory -
modules
Optional list of other modules to activate. -
jettyOptions
Extra options that can be passed to the jetty command line -
forkWebXml
The file into which to generate the quickstart web xml for the forked process to use -
mavenProjectHelper
Helper for interacting with the maven project space -
plugin
@Parameter(defaultValue="${plugin}", readonly=true, required=true) protected org.apache.maven.plugin.descriptor.PluginDescriptor pluginThis plugin -
supportedPackagings
Default supported project type iswar
packaging. -
warArtifacts
List of deps that are wars -
originalBaseResource
Webapp base before applying overlays etc -
providedJars
List of jars with scope=provided -
mergedSystemProperties
System properties from both systemPropertyFile and systemProperties.
-
-
Constructor Details
-
AbstractWebAppMojo
public AbstractWebAppMojo()
-
-
Method Details
-
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
- Throws:
Exception
-
newJettyForker
- Throws:
Exception
-
newJettyHomeForker
- Throws:
Exception
-
verifyPomConfiguration
protected void verifyPomConfiguration() throws org.apache.maven.plugin.MojoExecutionExceptionUsed by subclasses.- Throws:
org.apache.maven.plugin.MojoExecutionException
-
mergeSystemProperties
protected Map<String,String> mergeSystemProperties() throws org.apache.maven.plugin.MojoExecutionExceptionUnite 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.MojoExecutionExceptionAugment jetty's classpath with dependencies marked as scope=provided if useProvidedScope==true.- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getProvidedJars
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
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:
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
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
-
configureWebApp
Ensure there is a webapp, and that some basic defaults are applied if the user has not supplied them.- Throws:
Exception
-
findJettyWebXmlFile
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
Get a file into which to write output from jetty.- Parameters:
name
- the name of the file- Returns:
- the created file
- Throws:
Exception
-
configureScanTargetPatterns
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:
IOException
-