Class WarProjectPackagingTask

  • All Implemented Interfaces:
    WarPackagingTask

    public class WarProjectPackagingTask
    extends AbstractWarPackagingTask
    Handles the project own resources, that is:
    • The list of web resources, if any
    • The content of the webapp directory if it exists
    • The custom deployment descriptor(s), if any
    • The content of the classes directory if it exists
    • The dependencies of the project
    • Field Detail

      • webResources

        private final org.apache.maven.model.Resource[] webResources
      • webXml

        private final java.io.File webXml
      • containerConfigXML

        private final java.io.File containerConfigXML
      • id

        private final java.lang.String id
      • currentProjectOverlay

        private Overlay currentProjectOverlay
    • Constructor Detail

      • WarProjectPackagingTask

        public WarProjectPackagingTask​(org.apache.maven.model.Resource[] webResources,
                                       java.io.File webXml,
                                       java.io.File containerConfigXml,
                                       Overlay currentProjectOverlay)
        Parameters:
        webResources - webResources
        webXml - webXml
        containerConfigXml - containerConfigXML
        currentProjectOverlay - currentProjectOverlay
    • Method Detail

      • performPackaging

        public void performPackaging​(WarPackagingContext context)
                              throws org.apache.maven.plugin.MojoExecutionException,
                                     org.apache.maven.plugin.MojoFailureException
        Description copied from interface: WarPackagingTask
        Performs the packaging for the specified task. The task is responsible to update the packaging context, namely with the files that have been copied.
        Parameters:
        context - the packaging context
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an error occurred
        org.apache.maven.plugin.MojoFailureException - if the project configuration is invalid
      • handleWebResources

        protected void handleWebResources​(WarPackagingContext context)
                                   throws org.apache.maven.plugin.MojoExecutionException
        Handles the web resources.
        Parameters:
        context - the packaging context
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if a resource could not be copied
      • handleWebAppSourceDirectory

        protected void handleWebAppSourceDirectory​(WarPackagingContext context)
                                            throws org.apache.maven.plugin.MojoExecutionException
        Handles the webapp sources.
        Parameters:
        context - the packaging context
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if the sources could not be copied
      • handleArtifacts

        protected void handleArtifacts​(WarPackagingContext context)
                                throws org.apache.maven.plugin.MojoExecutionException
        Handles the webapp artifacts.
        Parameters:
        context - the packaging context
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if the artifacts could not be packaged
      • handleClassesDirectory

        protected void handleClassesDirectory​(WarPackagingContext context)
                                       throws org.apache.maven.plugin.MojoExecutionException
        Handles the webapp classes.
        Parameters:
        context - the packaging context
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if the classes could not be packaged
      • handleDeploymentDescriptors

        protected void handleDeploymentDescriptors​(WarPackagingContext context,
                                                   java.io.File webinfDir,
                                                   java.io.File metainfDir,
                                                   java.lang.Boolean failOnMissingWebXml)
                                            throws org.apache.maven.plugin.MojoFailureException,
                                                   org.apache.maven.plugin.MojoExecutionException
        Handles the deployment descriptors, if specified. Note that the behavior here is slightly different since the customized entry always win, even if an overlay has already packaged a web.xml previously.
        Parameters:
        context - the packaging context
        webinfDir - the web-inf directory
        metainfDir - the meta-inf directory
        failOnMissingWebXml - if build should fail if web.xml is not found
        Throws:
        org.apache.maven.plugin.MojoFailureException - if the web.xml is specified but does not exist and failOnMissingWebXml is true
        org.apache.maven.plugin.MojoExecutionException - if an error occurred while copying the descriptors
      • copyResources

        public void copyResources​(WarPackagingContext context,
                                  org.apache.maven.model.Resource resource)
                           throws java.io.IOException,
                                  org.apache.maven.plugin.MojoExecutionException
        Copies webapp webResources from the specified directory.
        Parameters:
        context - the WAR packaging context to use
        resource - the resource to copy
        Throws:
        java.io.IOException - if an error occurred while copying the resources
        org.apache.maven.plugin.MojoExecutionException - if an error occurred while retrieving the filter properties
      • getFilesToCopy

        private java.lang.String[] getFilesToCopy​(org.apache.maven.model.Resource resource)
        Returns a list of filenames that should be copied over to the destination directory.
        Parameters:
        resource - the resource to be scanned
        Returns:
        the array of filenames, relative to the sourceDir