View Javadoc
1   package org.apache.maven.plugins.war.packaging;
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 java.io.File;
23  import java.util.List;
24  
25  import org.apache.maven.archiver.MavenArchiveConfiguration;
26  import org.apache.maven.artifact.factory.ArtifactFactory;
27  import org.apache.maven.execution.MavenSession;
28  import org.apache.maven.plugin.logging.Log;
29  import org.apache.maven.plugins.war.util.WebappStructure;
30  import org.apache.maven.project.MavenProject;
31  import org.apache.maven.shared.filtering.MavenFileFilter;
32  import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
33  import org.codehaus.plexus.archiver.jar.JarArchiver;
34  import org.codehaus.plexus.archiver.manager.ArchiverManager;
35  
36  /**
37   * The packaging context.
38   *
39   * @author Stephane Nicoll
40   */
41  public interface WarPackagingContext
42  {
43      /**
44       * Returns the maven project.
45       *
46       * @return the project
47       */
48      MavenProject getProject();
49  
50      /**
51       * Returns the webapp directory. Packaging tasks should use this directory to generate the webapp.
52       *
53       * @return the webapp directory
54       */
55      File getWebappDirectory();
56  
57      /**
58       * Returns the main webapp source directory.
59       *
60       * @return the webapp source directory
61       */
62      File getWebappSourceDirectory();
63  
64      /**
65       * Returns the webapp source includes.
66       *
67       * @return the webapp source includes
68       */
69      String[] getWebappSourceIncludes();
70  
71      /**
72       * Returns {@code true} if empty directories should be includes, otherwise {@code false}
73       *
74       * @return {@code true} if empty directories should be includes, otherwise {@code false}
75       */
76      boolean isWebappSourceIncludeEmptyDirectories();
77  
78      /**
79       * Returns the webapp source excludes.
80       *
81       * @return the webapp source excludes
82       */
83      String[] getWebappSourceExcludes();
84  
85      /**
86       * Returns the directory holding generated classes.
87       *
88       * @return the classes directory
89       */
90      File getClassesDirectory();
91  
92      /**
93       * Specify whether the classes resources should be archived in the <tt>WEB-INF/lib</tt> of the generated web app.
94       *
95       * @return true if the classes should be archived, false otherwise
96       */
97      boolean archiveClasses();
98  
99      /**
100      * Returns the logger to use to output logging event.
101      *
102      * @return the logger
103      */
104     Log getLog();
105 
106     /**
107      * Returns the directory to unpack dependent WARs into if needed.
108      *
109      * @return the overlays work directory
110      */
111     File getOverlaysWorkDirectory();
112 
113     /**
114      * Returns the archiver manager to use.
115      *
116      * @return the archiver manager
117      */
118     ArchiverManager getArchiverManager();
119 
120     /**
121      * The maven archive configuration to use.
122      *
123      * @return the maven archive configuration
124      */
125     MavenArchiveConfiguration getArchive();
126 
127     /**
128      * Returns the Jar archiver needed for archiving classes directory into jar file under WEB-INF/lib.
129      *
130      * @return the jar archiver to user
131      */
132     JarArchiver getJarArchiver();
133 
134     /**
135      * Returns the output file name mapping to use, if any. Returns <tt>null</tt> if no file name mapping is set.
136      *
137      * @return the output file name mapping or <tt>null</tt>
138      */
139     String getOutputFileNameMapping();
140 
141     /**
142      * Returns the list of filter files to use.
143      *
144      * @return a list of filter files
145      */
146     List<String> getFilters();
147 
148     /**
149      * Returns the {@link WebappStructure}.
150      *
151      * @return the webapp structure
152      */
153     WebappStructure getWebappStructure();
154 
155     /**
156      * Returns the list of registered overlays for this session.
157      *
158      * @return the list of registered overlays, including the current project
159      */
160     List<String> getOwnerIds();
161 
162     /**
163      * Returns the {@link MavenFileFilter} instance to use.
164      *
165      * @return the maven file filter to use
166      * @since 2.1-alpha-2
167      */
168     MavenFileFilter getMavenFileFilter();
169 
170     /**
171      * @return {@link List} of {@link FilterWrapper}
172      * @since 2.1-alpha-2
173      */
174     List<FilterWrapper> getFilterWrappers();
175 
176     /**
177      * Specify if the given <tt>fileName</tt> belongs to the list of extensions that must not be filtered
178      *
179      * @param fileName the name of file
180      * @return <tt>true</tt> if it should not be filtered, <tt>false</tt> otherwise
181      * @since 2.1-alpha-2
182      */
183     boolean isNonFilteredExtension( String fileName );
184 
185     /**
186      * @return filtering deployment descriptor.
187      */
188     boolean isFilteringDeploymentDescriptors();
189 
190     /**
191      * @return {@link ArtifactFactory}
192      */
193     ArtifactFactory getArtifactFactory();
194 
195     /**
196      * Returns the Maven session.
197      *
198      * @return the Maven session
199      * @since 2.2
200      */
201     MavenSession getSession();
202 
203     /**
204      * Returns the encoding to use for resources.
205      *
206      * @return the resource encoding
207      * @since 2.3
208      */
209     String getResourceEncoding();
210 
211     /**
212      * @return to use jvmChmod rather than forking chmod cli
213      * @since 2.4
214      */
215     boolean isUseJvmChmod();
216 
217     /**
218      * Returns the flag that switch on/off the missing web.xml validation
219      *
220      * @return failOnMissingWebXml
221      */
222     Boolean isFailOnMissingWebXml();
223 
224     /**
225      * Add a live resource to the war.
226      * Used to keep track of existing resources and all copied files.
227      * All others are outdated and will be removed.
228      * This prevent calling <code>mvn clean</code> when resources are removed. 
229      * 
230      * @param resource the resource that is to me marked as not outdated
231      * @since 3.3.0
232      * @see #deleteOutdatedResources()
233      */
234     void addResource( String resource );
235 
236     /**
237      * Delete outdated resources, ie resources that are found in the war but that were not added by the current
238      * packaging process, then are supposed to be content from a previous run.
239      * This prevent calling <code>mvn clean</code> when resources are removed.
240      * 
241      * @since 3.3.0
242      * @see #addResource
243      */
244     void deleteOutdatedResources();
245 
246     /**
247      * Output timestamp for reproducible archive creation.
248      * 
249      * @return the output timestamp (may be null)
250      * @since 3.3.0
251      */
252     String getOutputTimestamp();
253 }