Package org.apache.maven.plugins.war
Class AbstractWarMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.war.AbstractWarMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
WarExplodedMojo
,WarInPlaceMojo
,WarMojo
public abstract class AbstractWarMojo
extends org.apache.maven.plugin.AbstractMojo
Contains common jobs for WAR mojos.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
WarPackagingContext default implementation -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.maven.archiver.MavenArchiveConfiguration
The archive configuration to use.private boolean
Whether a JAR file will be created for the classes in the webapp.private org.codehaus.plexus.archiver.manager.ArchiverManager
To look up Archiver/UnArchiver implementations.private org.apache.maven.artifact.factory.ArtifactFactory
private File
The directory containing compiled classes.private File
The path to a configuration file for the servlet container.private final Overlay
private LinkedHashSet
<String> Set of delimiters for expressions to filter within the resources.private String
The comma separated list of tokens to exclude when doing a WAR overlay.private String
The comma separated list of tokens to include when doing a WAR overlay.private boolean
To escape interpolated values with Windows pathc:\foo\bar
will be replaced withc:\\foo\\bar
.protected String
Expression preceded with this String won't be interpolated.protected Boolean
Whether or not to fail the build if theweb.xml
file is missing.private boolean
To filter deployment descriptors.Filters (property files) to include during the interpolation of the pom.xml.private boolean
private org.codehaus.plexus.archiver.jar.JarArchiver
The JAR archiver needed for archiving the classes directory into a JAR file under WEB-INF/lib.private org.apache.maven.shared.filtering.MavenFileFilter
private org.apache.maven.shared.filtering.MavenResourcesFiltering
private static final String
A list of file extensions that should not be filtered.private String
Path prefix for resources that will be checked against outdated content.private String
The file name mapping to use when copying libraries and TLDs.protected String
Timestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXX
or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).The overlays to apply.private org.apache.maven.project.MavenProject
The Maven project.protected String
The character encoding to use when reading and writing filtered properties files.private boolean
Indicates if zip archives (jar,zip etc) being added to the war should be compressed again.private String
The encoding to use when copying filtered web resources.private org.apache.maven.execution.MavenSession
private boolean
Stop searching endToken at the end of lineprivate boolean
Use default delimiters in addition to custom delimiters, if any.private boolean
use jvmChmod rather that cli chmod and forking processprivate File
Single directory for extra files to include in the WAR.private String
The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.private String
The comma separated list of tokens to include when copying the content of the warSourceDirectory.private static final String
private File
The directory where the webapp is built.private org.apache.maven.model.Resource[]
The list of webResources we want to transfer.private File
The path to the web.xml file to use.private File
Directory to unpack dependent WARs into if needed.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOverlay
(Overlay overlay) void
buildExplodedWebapp
(File webapplicationDirectory) void
buildWebapp
(org.apache.maven.project.MavenProject mavenProject, File webapplicationDirectory) Builds the webapp for the specified project with the new packaging task thingy.org.apache.maven.archiver.MavenArchiveConfiguration
org.apache.maven.artifact.factory.ArtifactFactory
protected String[]
Returns a string array of the excludes to be used when adding dependent WAR as an overlay onto this WAR.protected String[]
Returns a string array of the includes to be used when adding dependent WARs as an overlay onto this WAR.protected String[]
Returns a string array of the excludes to be used when copying the content of the WAR source directory.protected String[]
Returns a string array of the includes to be used when assembling/copying the WAR.org.codehaus.plexus.archiver.jar.JarArchiver
private List
<WarPackagingTask> getPackagingTasks
(OverlayManager overlayManager) Returns aList
of theWarPackagingTask
instances to invoke to perform the packaging.org.apache.maven.project.MavenProject
protected org.apache.maven.execution.MavenSession
org.apache.maven.model.Resource[]
boolean
protected boolean
protected boolean
void
setArchiveClasses
(boolean archiveClasses) void
setArtifactFactory
(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory) void
setClassesDirectory
(File classesDirectory) void
setContainerConfigXML
(File containerConfigXML) void
setFilters
(List<String> filters) void
setJarArchiver
(org.codehaus.plexus.archiver.jar.JarArchiver jarArchiver) void
setNonFilteredFileExtensions
(List<String> nonFilteredFileExtensions) void
setOutputFileNameMapping
(String outputFileNameMapping) void
setOverlays
(List<Overlay> overlays) void
setProject
(org.apache.maven.project.MavenProject project) void
setWarSourceDirectory
(File warSourceDirectory) void
setWarSourceExcludes
(String warSourceExcludes) void
setWarSourceIncludes
(String warSourceIncludes) void
setWebappDirectory
(File webappDirectory) void
setWebResources
(org.apache.maven.model.Resource[] webResources) void
void
setWorkDirectory
(File workDirectory) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
META_INF
- See Also:
-
WEB_INF
- See Also:
-
failOnMissingWebXml
Whether or not to fail the build if theweb.xml
file is missing. Set tofalse
if you want your WAR built without aweb.xml
file. This may be useful if you are building an overlay that has no web.xml file.Starting with 3.1.0, this property defaults to
false
if the project depends on the Servlet 3.0 API or newer.- Since:
- 2.1-alpha-2
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe Maven project. -
classesDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true, readonly=true) private File classesDirectoryThe directory containing compiled classes. -
archiveClasses
@Parameter(defaultValue="false") private boolean archiveClassesWhether a JAR file will be created for the classes in the webapp. Using this optional configuration parameter will make the compiled classes to be archived into a JAR file in/WEB-INF/lib/
and the classes directory will then be excluded from the webapp/WEB-INF/classes/
.- Since:
- 2.0.1
-
resourceEncoding
The encoding to use when copying filtered web resources.- Since:
- 2.3
-
propertiesEncoding
The character encoding to use when reading and writing filtered properties files. If not specified, it will default to the value of the "resourceEncoding" parameter.- Since:
- 3.4.0
-
jarArchiver
@Component(role=org.codehaus.plexus.archiver.Archiver.class, hint="jar") private org.codehaus.plexus.archiver.jar.JarArchiver jarArchiverThe JAR archiver needed for archiving the classes directory into a JAR file under WEB-INF/lib. -
webappDirectory
@Parameter(defaultValue="${project.build.directory}/${project.build.finalName}", required=true) private File webappDirectoryThe directory where the webapp is built. -
warSourceDirectory
@Parameter(defaultValue="${basedir}/src/main/webapp", required=true) private File warSourceDirectorySingle directory for extra files to include in the WAR. This is where you place your JSP files. -
webResources
@Parameter private org.apache.maven.model.Resource[] webResourcesThe list of webResources we want to transfer. -
filters
Filters (property files) to include during the interpolation of the pom.xml. -
delimiters
Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.
So, the default filtering delimiters might be specified as:
<delimiters> <delimiter>${*}</delimiter> <delimiter>@</delimiter> </delimiters>
Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).
- Since:
- 3.0.0
-
useDefaultDelimiters
@Parameter(defaultValue="true") private boolean useDefaultDelimitersUse default delimiters in addition to custom delimiters, if any.- Since:
- 3.0.0
-
webXml
The path to the web.xml file to use. -
containerConfigXML
The path to a configuration file for the servlet container. Note that the file name may be different for different servlet containers. Apache Tomcat uses a configuration file named context.xml. The file will be copied to the META-INF directory. -
workDirectory
@Parameter(defaultValue="${project.build.directory}/war/work", required=true) private File workDirectoryDirectory to unpack dependent WARs into if needed. -
outputFileNameMapping
The file name mapping to use when copying libraries and TLDs. If no file mapping is set (default) the files are copied with their standard names.- Since:
- 2.1-alpha-1
-
artifactFactory
@Component(role=org.apache.maven.artifact.factory.ArtifactFactory.class) private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory -
archiverManager
@Component(role=org.codehaus.plexus.archiver.manager.ArchiverManager.class) private org.codehaus.plexus.archiver.manager.ArchiverManager archiverManagerTo look up Archiver/UnArchiver implementations. -
mavenFileFilter
@Component(role=org.apache.maven.shared.filtering.MavenFileFilter.class, hint="default") private org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilter -
mavenResourcesFiltering
@Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class, hint="default") private org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering -
warSourceIncludes
The comma separated list of tokens to include when copying the content of the warSourceDirectory. -
warSourceExcludes
The comma separated list of tokens to exclude when copying the content of the warSourceDirectory. -
dependentWarIncludes
The comma separated list of tokens to include when doing a WAR overlay. Default isOverlay.DEFAULT_INCLUDES
-
dependentWarExcludes
The comma separated list of tokens to exclude when doing a WAR overlay. Default isOverlay.DEFAULT_EXCLUDES
-
overlays
The overlays to apply. Each <overlay> element may contain:- id (defaults to
currentBuild
) - groupId (if this and artifactId are null, then the current project is treated as its own overlay)
- artifactId (see above)
- classifier
- type
- includes (a list of string patterns)
- excludes (a list of string patterns)
- filtered (defaults to false)
- skip (defaults to false)
- targetPath (defaults to root of webapp structure)
- Since:
- 2.1-alpha-1
- id (defaults to
-
nonFilteredFileExtensions
A list of file extensions that should not be filtered. Will be used when filtering webResources and overlays.- Since:
- 2.1-alpha-2
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session- Since:
- 2.1-alpha-2
-
filteringDeploymentDescriptors
@Parameter(defaultValue="false") private boolean filteringDeploymentDescriptorsTo filter deployment descriptors. Disabled by default.- Since:
- 2.1-alpha-2
-
escapedBackslashesInFilePath
@Parameter(defaultValue="false") private boolean escapedBackslashesInFilePathTo escape interpolated values with Windows pathc:\foo\bar
will be replaced withc:\\foo\\bar
.- Since:
- 2.1-alpha-2
-
escapeString
Expression preceded with this String won't be interpolated.\${foo}
will be replaced with${foo}
.- Since:
- 2.1-beta-1
-
recompressZippedFiles
@Parameter(defaultValue="true") private boolean recompressZippedFilesIndicates if zip archives (jar,zip etc) being added to the war should be compressed again. Compressing again can result in smaller archive size, but gives noticeably longer execution time.- Since:
- 2.3
-
includeEmptyDirectories
@Parameter(defaultValue="false") private boolean includeEmptyDirectories- Since:
- 2.4
-
supportMultiLineFiltering
@Parameter(defaultValue="false") private boolean supportMultiLineFilteringStop searching endToken at the end of line- Since:
- 2.4
-
useJvmChmod
@Parameter(defaultValue="true") private boolean useJvmChmoduse jvmChmod rather that cli chmod and forking process- Since:
- 2.4
-
archive
@Parameter private org.apache.maven.archiver.MavenArchiveConfiguration archiveThe archive configuration to use. See Maven Archiver Reference. -
outputTimestamp
Timestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXX
or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Since:
- 3.3.0
-
outdatedCheckPath
Path prefix for resources that will be checked against outdated content. Starting with 3.3.2, if a value of "/" is specified the entire webappDirectory will be checked, i.e. the "/" signifies "root".- Since:
- 3.3.1
-
currentProjectOverlay
-
-
Constructor Details
-
AbstractWarMojo
public AbstractWarMojo()
-
-
Method Details
-
getCurrentProjectOverlay
- Returns:
- The current overlay.
-
getExcludes
Returns a string array of the excludes to be used when copying the content of the WAR source directory.- Returns:
- an array of tokens to exclude
-
getIncludes
Returns a string array of the includes to be used when assembling/copying the WAR.- Returns:
- an array of tokens to include
-
getDependentWarExcludes
Returns a string array of the excludes to be used when adding dependent WAR as an overlay onto this WAR.- Returns:
- an array of tokens to exclude
-
getDependentWarIncludes
Returns a string array of the includes to be used when adding dependent WARs as an overlay onto this WAR.- Returns:
- an array of tokens to include
-
buildExplodedWebapp
public void buildExplodedWebapp(File webapplicationDirectory) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException - Parameters:
webapplicationDirectory
- The web application directory.- Throws:
org.apache.maven.plugin.MojoExecutionException
- In case of failure.org.apache.maven.plugin.MojoFailureException
- In case of failure.
-
buildWebapp
public void buildWebapp(org.apache.maven.project.MavenProject mavenProject, File webapplicationDirectory) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException Builds the webapp for the specified project with the new packaging task thingy. Classes, libraries and tld files are copied to thewebappDirectory
during this phase.- Parameters:
mavenProject
- the maven projectwebapplicationDirectory
- the target directory- Throws:
org.apache.maven.plugin.MojoExecutionException
- if an error occurred while packaging the webapporg.apache.maven.plugin.MojoFailureException
- if an unexpected error occurred while packaging the webappIOException
- if an error occurred while copying the files
-
getPackagingTasks
private List<WarPackagingTask> getPackagingTasks(OverlayManager overlayManager) throws org.apache.maven.plugin.MojoExecutionException Returns aList
of theWarPackagingTask
instances to invoke to perform the packaging.- Parameters:
overlayManager
- the overlay manager- Returns:
- the list of packaging tasks
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the packaging tasks could not be built
-
getProject
public org.apache.maven.project.MavenProject getProject()- Returns:
- The Maven Project.
-
setProject
public void setProject(org.apache.maven.project.MavenProject project) - Parameters:
project
- The project to be set.
-
getClassesDirectory
- Returns:
- the classes directory.
-
setClassesDirectory
- Parameters:
classesDirectory
- The classes directory to be set.
-
getWebappDirectory
- Returns:
webappDirectory
-
setWebappDirectory
- Parameters:
webappDirectory
- The web application directory.
-
getWarSourceDirectory
- Returns:
warSourceDirectory
-
setWarSourceDirectory
- Parameters:
warSourceDirectory
-warSourceDirectory
-
getWebXml
- Returns:
- The
webXml
-
setWebXml
- Parameters:
webXml
- ThewebXml
-
getContainerConfigXML
- Returns:
containerConfigXML
-
setContainerConfigXML
- Parameters:
containerConfigXML
-containerConfigXML
-
getOutputFileNameMapping
- Returns:
outputFileNameMapping
-
setOutputFileNameMapping
- Parameters:
outputFileNameMapping
-outputFileNameMapping
-
getOverlays
- Returns:
overlays
-
setOverlays
- Parameters:
overlays
-overlays
-
addOverlay
- Parameters:
overlay
- addoverlays
.
-
isArchiveClasses
public boolean isArchiveClasses()- Returns:
archiveClasses
-
setArchiveClasses
public void setArchiveClasses(boolean archiveClasses) - Parameters:
archiveClasses
-archiveClasses
-
getJarArchiver
public org.codehaus.plexus.archiver.jar.JarArchiver getJarArchiver()- Returns:
JarArchiver
-
setJarArchiver
public void setJarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver jarArchiver) - Parameters:
jarArchiver
-JarArchiver
-
getWebResources
public org.apache.maven.model.Resource[] getWebResources()- Returns:
webResources
.
-
setWebResources
public void setWebResources(org.apache.maven.model.Resource[] webResources) - Parameters:
webResources
-webResources
.
-
getFilters
- Returns:
filters
-
setFilters
- Parameters:
filters
-filters
-
getWorkDirectory
- Returns:
workDirectory
-
setWorkDirectory
- Parameters:
workDirectory
-workDirectory
-
getWarSourceIncludes
- Returns:
warSourceIncludes
-
setWarSourceIncludes
- Parameters:
warSourceIncludes
-warSourceIncludes
-
getWarSourceExcludes
- Returns:
warSourceExcludes
-
setWarSourceExcludes
- Parameters:
warSourceExcludes
-warSourceExcludes
-
getArchive
public org.apache.maven.archiver.MavenArchiveConfiguration getArchive()- Returns:
archive
-
getNonFilteredFileExtensions
- Returns:
nonFilteredFileExtensions
-
setNonFilteredFileExtensions
- Parameters:
nonFilteredFileExtensions
-nonFilteredFileExtensions
-
getArtifactFactory
public org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()- Returns:
artifactFactory
-
setArtifactFactory
public void setArtifactFactory(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory) - Parameters:
artifactFactory
-artifactFactory
-
getSession
protected org.apache.maven.execution.MavenSession getSession()- Returns:
session
-
isRecompressZippedFiles
protected boolean isRecompressZippedFiles()- Returns:
recompressZippedFiles
-
isIncludeEmptyDirectories
protected boolean isIncludeEmptyDirectories()- Returns:
includeEmptyDirectories
-