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.handler.manager.ArtifactHandlerManager;
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 * Returns the artifact handler manager.
190 *
191 * @return the artifact handler manager
192 */
193 ArtifactHandlerManager getArtifactHandlerManager();
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 * Returns the encoding to use for resources that are properties files.
213 *
214 * @return the encoding for properties files
215 * @since 3.4.0
216 */
217 String getPropertiesEncoding();
218
219 /**
220 * Returns the flag that switch on/off the missing web.xml validation.
221 *
222 * @return failOnMissingWebXml
223 */
224 Boolean isFailOnMissingWebXml();
225
226 /**
227 * Add a live resource to the war.
228 * Used to keep track of existing resources and all copied files.
229 * All others are outdated and will be removed.
230 * This prevent calling <code>mvn clean</code> when resources are removed.
231 *
232 * @param resource the resource that is to me marked as not outdated
233 * @see #deleteOutdatedResources()
234 * @since 3.3.0
235 */
236 void addResource(String resource);
237
238 /**
239 * Delete outdated resources, ie resources that are found in the war but that were not added by the current
240 * packaging process, then are supposed to be content from a previous run.
241 * This prevent calling <code>mvn clean</code> when resources are removed.
242 *
243 * @see #addResource
244 * @since 3.3.0
245 */
246 void deleteOutdatedResources();
247
248 /**
249 * Output timestamp for reproducible archive creation.
250 *
251 * @return the output timestamp (may be null)
252 * @since 3.3.0
253 */
254 String getOutputTimestamp();
255
256 /**
257 * @return list of packaging excludes
258 * @since 3.4.1
259 */
260 List<String> getPackagingExcludes();
261
262 /**
263 * @return list of packaging includes
264 * @since 3.4.1
265 */
266 List<String> getPackagingIncludes();
267 }