Class JettyRunDistro

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="run-distro",
          requiresDependencyResolution=TEST)
    @Execute(phase=TEST_COMPILE)
    public class JettyRunDistro
    extends JettyRunMojo
    This goal is used to deploy the unassembled webapp into a jetty distribution. If the location of an existing unpacked distribution is not supplied as the configuration param jettyHome, this goal will download and unpack the jetty distro matching the version of this plugin before deploying the webapp. The webapp will execute in the distro in a forked process. The stopKey, stopPort configuration elements can be used to control the stopping of the forked process. By default, this plugin will launch the forked jetty instance and wait for it to complete (in which case it acts much like the jetty:run goal, and you will need to Cntrl-C to stop). By setting the configuration element waitForChild to false, the plugin will terminate after having forked the jetty process. In this case you can use the jetty:stop goal to terminate the process. This goal does NOT support the scanIntervalSeconds parameter: the webapp will be deployed only once. See https://jetty.org/docs/ for more information on this and other jetty plugins. Runs unassembled webapp in a locally installed jetty distro
    • 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
      • plugin

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

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

      • JettyRunDistro

        public JettyRunDistro()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Overrides:
        execute in class JettyRunMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
        See Also:
        JettyRunMojo.execute()
      • configureJettyHome

        public void configureJettyHome()
                                throws java.lang.Exception
        If jetty home does not exist, download it and unpack to build dir.
        Throws:
        java.lang.Exception - if jetty distribution cannot be found neither downloaded
      • resolveArtifact

        public org.apache.maven.artifact.Artifact resolveArtifact​(java.lang.String groupId,
                                                                  java.lang.String artifactId,
                                                                  java.lang.String version,
                                                                  java.lang.String extension)
                                                           throws org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException
        Resolve an Artifact from remote repo if necessary.
        Parameters:
        groupId - the groupid of the artifact
        artifactId - the artifactId of the artifact
        version - the version of the artifact
        extension - the extension type of the artifact eg "zip", "jar"
        Returns:
        the artifact from the local or remote repo
        Throws:
        org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException - in case of an error while resolving the artifact
      • configureJettyBase

        public void configureJettyBase()
                                throws java.lang.Exception
        Create or configure a jetty base.
        Throws:
        java.lang.Exception - if any error occurred while copying files
      • createPropertiesFile

        public void createPropertiesFile​(java.io.File file)
                                  throws java.lang.Exception
        Convert webapp config to properties
        Parameters:
        file - the file to place the properties into
        Throws:
        java.lang.Exception - if any I/O exception during generating the properties file
      • configureCommand

        public java.lang.ProcessBuilder configureCommand()
        Make the command to spawn a process to run jetty from a distro.
        Returns:
        the command configured
      • startScanner

        public void startScanner()
                          throws java.lang.Exception
        Description copied from class: AbstractJettyMojo
        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.
        Overrides:
        startScanner in class AbstractJettyMojo
        Throws:
        java.lang.Exception - if unable to start scanner
        See Also:
        AbstractJettyMojo.startScanner()