JavaScript is disabled on your browser.
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
@Mojo(name="war",
defaultPhase=PACKAGE,
threadSafe=true,
requiresDependencyResolution=COMPILE_PLUS_RUNTIME)
public class WarMojo
extends AbstractWarMojo
Build a WAR file.
Field Summary
Fields
private boolean
Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the project as an
additional artifact.
The classifier to use for the attached classes artifact.
Classifier to add to the generated WAR.
The directory for the generated WAR.
private boolean
Whether this is the main artifact being built.
private final org.apache.maven.project.MavenProjectHelper
private boolean
You can skip the execution of the plugin if you need to.
The name of the generated WAR.
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
Constructor Summary
Constructors
WarMojo (org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager,
org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager,
org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilter,
org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering,
org.apache.maven.project.MavenProjectHelper projectHelper,
org.apache.maven.execution.MavenSession session)
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
void
Executes the WarMojo on the current project.
org.apache.maven.project.MavenProjectHelper
org.codehaus.plexus.archiver.war.WarArchiver
private static boolean
private static boolean
boolean
boolean
boolean
private boolean
Determines if the current Maven project being built uses the Servlet 3.0 API (JSR 315)
or Jakarta Servlet API.
boolean
private void
Generates the webapp according to the mode attribute.
void
void
void
void
void
void
void
Methods inherited from class org.apache.maven.plugins.war.AbstractWarMojo
addOverlay , buildExplodedWebapp , buildWebapp , getArchive , getArchiverManager , getClassesDirectory , getContainerConfigXML , getCurrentProjectOverlay , getDependentWarExcludes , getDependentWarIncludes , getExcludes , getFilters , getIncludes , getJarArchiver , getNonFilteredFileExtensions , getOutputFileNameMapping , getOverlays , getPackagingExcludes , getPackagingIncludes , getProject , getSession , getWarSourceDirectory , getWarSourceExcludes , getWarSourceIncludes , getWebappDirectory , getWebResources , getWebXml , getWorkDirectory , isArchiveClasses , isIncludeEmptyDirectories , isRecompressZippedFiles , setClassesDirectory , setContainerConfigXML , setOutputFileNameMapping , setOverlays , setPackagingExcludes , setPackagingIncludes , setProject , setWarSourceDirectory , setWebappDirectory , setWebResources , setWebXml
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
Field Details
outputDirectory
@Parameter(defaultValue="${project.build.directory}",
required=true)
private String outputDirectory
The directory for the generated WAR.
warName
@Parameter(defaultValue="${project.build.finalName}",
required=true,
readonly=true)
private String warName
The name of the generated WAR.
classifier
@Parameter
private String classifier
Classifier to add to the generated WAR. If given, the artifact will be an attachment instead. The classifier will
not be applied to the JAR file of the project - only to the WAR file.
primaryArtifact
@Parameter(defaultValue="true")
private boolean primaryArtifact
Whether this is the main artifact being built. Set to false if you don't want to install or deploy
it to the local repository instead of the default one in an execution.
attachClasses
@Parameter(defaultValue="false")
private boolean attachClasses
Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the project as an
additional artifact.
By default the classifier for the additional artifact is 'classes'. You can change it with the
someclassifier]]> parameter.
If this parameter true, another project can depend on the classes by writing something like:
myGroup
myArtifact
myVersion
classes
]]>
Since:
2.1-alpha-2
classesClassifier
@Parameter(defaultValue="classes")
private String classesClassifier
The classifier to use for the attached classes artifact.
Since:
2.1-alpha-2
skip
@Parameter(property="maven.war.skip",
defaultValue="false")
private boolean skip
You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on
occasion.
Since:
3.0.0
projectHelper
private final org.apache.maven.project.MavenProjectHelper projectHelper
Constructor Details
WarMojo
@Inject
public WarMojo (org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager,
org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager,
org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilter,
org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering,
org.apache.maven.project.MavenProjectHelper projectHelper,
org.apache.maven.execution.MavenSession session)
Method Details
execute
public void execute ()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
Executes the WarMojo on the current project.
Throws:
org.apache.maven.plugin.MojoExecutionException - if an error occurred while building the webapp
org.apache.maven.plugin.MojoFailureException - if an error
isProjectUsingAtLeastServlet30
private boolean isProjectUsingAtLeastServlet30 ()
throws
org.apache.maven.artifact.DependencyResolutionRequiredException,
MalformedURLException
Determines if the current Maven project being built uses the Servlet 3.0 API (JSR 315)
or Jakarta Servlet API.
If it does then the
web.xml file can be omitted.
This is done by checking if the interface javax.servlet.annotation.WebServlet
or jakarta.servlet.annotation.WebServlet is in the compile-time
dependencies (which includes provided dependencies) of the Maven project.
Returns:
true if the project being built depends on Servlet 3.0 API or Jakarta Servlet API,
false otherwise
Throws:
org.apache.maven.artifact.DependencyResolutionRequiredException - if the compile elements can't be resolved
MalformedURLException - if the path to a dependency file can't be transformed to a URL
hasWebServletAnnotationClassInClasspath
private static boolean hasWebServletAnnotationClassInClasspath (ClassLoader loader)
getTargetFile
Parameters:
basedir - the basedir
finalName - the finalName
classifier - the classifier
type - the type
Returns:
File
getTargetWarFile
protected File getTargetWarFile ()
Returns:
the war File
getTargetClassesFile
protected File getTargetClassesFile ()
Returns:
the target class File
setClassifier
public void setClassifier (String classifier)
Parameters:
classifier - classifier
setOutputDirectory
public void setOutputDirectory (String outputDirectory)
Parameters:
outputDirectory - outputDirectory
setWarName
public void setWarName (String warName)
Parameters:
warName - warName
getWarArchiver
public org.codehaus.plexus.archiver.war.WarArchiver getWarArchiver ()
getProjectHelper
public org.apache.maven.project.MavenProjectHelper getProjectHelper ()
Returns:
projectHelper
isPrimaryArtifact
public boolean isPrimaryArtifact ()
Returns:
primaryArtifact
setPrimaryArtifact
public void setPrimaryArtifact (boolean primaryArtifact)
Parameters:
primaryArtifact - primaryArtifact
isAttachClasses
public boolean isAttachClasses ()
Returns:
attachClasses
setAttachClasses
public void setAttachClasses (boolean attachClasses)
Parameters:
attachClasses - attachClasses
setClassesClassifier
public void setClassesClassifier (String classesClassifier)
Parameters:
classesClassifier - classesClassifier
isSkip
public boolean isSkip ()
Skip the mojo run.
Returns:
skip