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.
  • Field Details

    • JETTY_HOME_GROUPID

      public static final String JETTY_HOME_GROUPID
      See Also:
    • JETTY_HOME_ARTIFACTID

      public static final String JETTY_HOME_ARTIFACTID
      See Also:
    • FAKE_WEBAPP

      public static final String FAKE_WEBAPP
      See Also:
    • 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 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 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 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 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 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 List<org.apache.maven.project.MavenProject> reactorProjects
    • target

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

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

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

      @Parameter(property="jetty.systemPropertiesFile") protected 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 Map<String,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 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 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.
    • httpConnector

      @Parameter protected MavenServerConnector httpConnector
      A ServerConnector to use.
    • server

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

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

      @Parameter(property="jetty.jvmArgs") protected 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 String stopKey
      Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
    • jettyHome

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

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

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

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

      @Parameter(defaultValue="${project.build.directory}/fork-web.xml") protected 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 List<String> supportedPackagings
      Default supported project type is war packaging.
    • warArtifacts

      protected 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 List<File> providedJars
      List of jars with scope=provided
    • mergedSystemProperties

      protected Map<String,String> 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

      protected JettyEmbedder newJettyEmbedder() throws Exception
      Throws:
      Exception
    • newJettyForker

      protected JettyForker newJettyForker() throws Exception
      Throws:
      Exception
    • newJettyHomeForker

      protected JettyHomeForker newJettyHomeForker() throws Exception
      Throws:
      Exception
    • verifyPomConfiguration

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

      protected Map<String,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 List<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 String getContainerClassPath() throws 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:
      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(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 String getProjectName()
    • configureWebApp

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

      protected File findJettyWebXmlFile(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 File getJettyOutputFile(String name) throws Exception
      Get a file into which to write output from jetty.
      Parameters:
      name - the name of the file
      Returns:
      the created file
      Throws:
      Exception
    • configureScanTargetPatterns

      protected void configureScanTargetPatterns(Scanner scanner) throws 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:
      IOException