1 //======================================================================== 2 //$Id: JettyStopMojo.java 2261 2007-12-22 23:53:55Z gregw $ 3 //Copyright 2000-2004 Mort Bay Consulting Pty. Ltd. 4 //------------------------------------------------------------------------ 5 //Licensed under the Apache License, Version 2.0 (the "License"); 6 //you may not use this file except in compliance with the License. 7 //You may obtain a copy of the License at 8 //http://www.apache.org/licenses/LICENSE-2.0 9 //Unless required by applicable law or agreed to in writing, software 10 //distributed under the License is distributed on an "AS IS" BASIS, 11 //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 //See the License for the specific language governing permissions and 13 //limitations under the License. 14 //======================================================================== 15 16 package org.mortbay.jetty.plugin; 17 18 import org.apache.maven.plugin.AbstractMojo; 19 import org.apache.maven.plugin.MojoExecutionException; 20 import org.apache.maven.plugin.MojoFailureException; 21 22 /** 23 * 24 * @author David Yu 25 * 26 * @goal stop 27 * @requiresDependencyResolution runtime 28 * @execute phase="process-sources" 29 * @description Stops jetty6 that is configured with <stopKey> and <stopPort>. 30 */ 31 32 public class JettyStopMojo extends AbstractMojo 33 { 34 35 /** 36 * Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> 37 * -DSTOP.KEY=<stopKey> -jar start.jar --stop 38 * @parameter 39 * @required 40 */ 41 protected int stopPort; 42 43 /** 44 * Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> 45 * -DSTOP.PORT=<stopPort> -jar start.jar --stop 46 * @parameter 47 * @required 48 */ 49 protected String stopKey; 50 51 public void execute() throws MojoExecutionException, MojoFailureException 52 { 53 if(stopPort<1) 54 throw new MojoExecutionException("Please specify a valid port"); 55 System.setProperty("STOP.PORT", String.valueOf(stopPort)); 56 System.setProperty("STOP.KEY", stopKey); 57 new org.mortbay.start.Main().stop(); 58 } 59 60 }