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