1 package org.apache.tomcat.maven.plugin.tomcat7;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Parameter;
24
25 /**
26 * Abstract goal that provides common configuration for Catalina-based goals.
27 *
28 * @author Mark Hobson <markhobson@gmail.com>
29 */
30 public abstract class AbstractWarCatalinaMojo
31 extends AbstractCatalinaMojo
32 {
33 // ----------------------------------------------------------------------
34 // Mojo Parameters
35 // ----------------------------------------------------------------------
36
37 /**
38 * The packaging of the Maven project that this goal operates upon.
39 */
40 @Parameter( defaultValue = "${project.packaging}", required = true, readonly = true )
41 private String packaging;
42
43 /**
44 * If set to true ignore if packaging of project is not 'war'.
45 *
46 * @since 1.1
47 */
48 @Parameter( property = "tomcat.ignorePackaging", defaultValue = "false" )
49 private boolean ignorePackaging;
50
51 // ----------------------------------------------------------------------
52 // Mojo Implementation
53 // ----------------------------------------------------------------------
54
55 /**
56 * {@inheritDoc}
57 */
58 @Override
59 public void execute()
60 throws MojoExecutionException
61 {
62 if ( !isWar() )
63 {
64 getLog().info( messagesProvider.getMessage( "AbstractWarCatalinaMojo.nonWar" ) );
65 return;
66 }
67
68 super.execute();
69 }
70
71 // ----------------------------------------------------------------------
72 // Protected Methods
73 // ----------------------------------------------------------------------
74
75 /**
76 * Gets whether this project uses WAR packaging.
77 *
78 * @return whether this project uses WAR packaging
79 */
80 protected boolean isWar()
81 {
82 return "war".equals( packaging ) || ignorePackaging;
83 }
84 }