View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.maven.plugin;
20  
21  import org.apache.maven.plugin.MojoExecutionException;
22  import org.apache.maven.plugin.MojoFailureException;
23  
24  /**
25   * <p>
26   * This goal is used to run Jetty with a pre-assembled war.
27   * </p>
28   * <p>
29   * It accepts exactly the same options as the <a href="run-war-mojo.html">run-war</a> goal. 
30   * However, it doesn't assume that the current artifact is a
31   * webapp and doesn't try to assemble it into a war before its execution. 
32   * So using it makes sense only when used in conjunction with the 
33   * <a href="run-war-mojo.html#webApp">war</a> configuration parameter pointing to a pre-built WAR.
34   * </p>
35   * <p>
36   * This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested 
37   * HTTP client components.
38   * </p>
39   * 
40   * @goal deploy-war
41   * @requiresDependencyResolution runtime
42   * @execute phase="validate"
43   * @description Deploy a pre-assembled war
44   * 
45   */
46  public class JettyDeployWar extends JettyRunWarMojo
47  {
48  
49      
50      /**
51       * If true, the plugin should continue and not block. Otherwise the
52       * plugin will block further execution and you will need to use
53       * cntrl-c to stop it.
54       * 
55       * 
56       * @parameter  default-value="true"
57       */
58      protected boolean daemon = true;
59      
60      
61      @Override
62      public void execute() throws MojoExecutionException, MojoFailureException
63      {
64          nonblocking = daemon; 
65          super.execute();
66      }
67      
68  
69  
70      @Override
71      public void finishConfigurationBeforeStart() throws Exception
72      {
73          super.finishConfigurationBeforeStart();
74          //only stop the server at shutdown if we are blocking
75          server.setStopAtShutdown(!nonblocking); 
76      }
77  
78  }