View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2014 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 java.io.File;
22  
23  import org.apache.maven.plugin.MojoExecutionException;
24  import org.apache.maven.plugin.MojoFailureException;
25  
26  /**
27   * <p>
28   * This goal is used to run Jetty with a pre-assembled war.
29   * </p>
30   * <p>
31   * It accepts exactly the same options as the <a href="run-war-mojo.html">run-war</a> goal. 
32   * However, it doesn't assume that the current artifact is a
33   * webapp and doesn't try to assemble it into a war before its execution. 
34   * So using it makes sense only when used in conjunction with the 
35   * <a href="run-war-mojo.html#webApp">war</a> configuration parameter pointing to a pre-built WAR.
36   * </p>
37   * <p>
38   * This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested 
39   * HTTP client components.
40   * </p>
41   * 
42   * @goal deploy-war
43   * @requiresDependencyResolution runtime
44   * @execute phase="validate"
45   * @description Deploy a pre-assembled war
46   * 
47   */
48  public class JettyDeployWar extends JettyRunWarMojo
49  {
50  
51      
52      /**
53       * If true, the plugin should continue and not block. Otherwise the
54       * plugin will block further execution and you will need to use
55       * cntrl-c to stop it.
56       * 
57       * 
58       * @parameter  default-value="true"
59       */
60      protected boolean daemon = true;
61      
62      
63      @Override
64      public void execute() throws MojoExecutionException, MojoFailureException
65      {
66          nonblocking = daemon; 
67          super.execute();
68      }
69      
70  
71  
72      @Override
73      public void finishConfigurationBeforeStart() throws Exception
74      {
75          super.finishConfigurationBeforeStart();
76          //only stop the server at shutdown if we are blocking
77          server.setStopAtShutdown(!nonblocking);
78         
79      }
80  
81  }