How to create WAR file using Maven?

Category:


How to create WAR file using Maven?
We use Maven (Ant's big brother) for all our java projects, and it has a very nifty WAR plugin. Tutorials and usage can be found there.
It's a lot easier than Ant, fully compatible with Eclipse (use maven eclipse:eclipse to create Eclipse projects) and easy to configure.
Sample Configuration:
<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-war-pluginartifactId>
    <version>2.1-alpha-2version>
    <configuration>
        <outputDirectory>${project.build.directory}/tmp/outputDirectory>
        <workDirectory>${project.build.directory}/tmp/war/workworkDirectory>
        <webappDirectory>${project.build.webappDirectory}webappDirectory>
        <cacheFile>${project.build.directory}/tmp/war/work/webapp-cache.xmlcacheFile>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>pdfnonFilteredFileExtension>
            <nonFilteredFileExtension>pngnonFilteredFileExtension>
            <nonFilteredFileExtension>gifnonFilteredFileExtension>
            <nonFilteredFileExtension>jspnonFilteredFileExtension>
        nonFilteredFileExtensions>
        <webResources>
            <resource>
                <directory>src/main/webapp/directory>
                <targetPath>WEB-INFtargetPath>
                <filtering>truefiltering>
                <includes>
                    <include>**/*.xml
                
            
        
        Application
    

Comments (0)

Post a Comment