Maven WAR Plugin
개요
The WAR Plugin is responsible for collecting all artifact dependencies, classes and resources of the web application and packaging them into a web application archive.
Goals Overview
- war:war is the default goal invoked during the package phase for projects with a packaging type of war. It builds a WAR file.
- war:exploded is generally used to speed up testing during the developement phase by creating an exploded webapp in a specified directory.
- war:inplace another variation of war:explode where the webapp is instead generated in the web application source directory, which is src/main/webapp by default.
- war:manifest generates a manifest for this webapp. The manifest file is created in the web application source directory.
사용
생성된 WAR 는 target 폴더안에 ${finalName} 으로 저장된다. finalName 에 변수는 ${project.artifactId}-${project.version}.war 로 대치되며 된다. war 가 저장되는 디렉터리는 webappDirectory parameter 를 수정하여 target 폴더 대신 임의의 폴더를 지정할 수 있다.
pom.xml
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory> <webResources> <resource> <directory>src/main/filters/${env}</directory> <includes> <include>*.properties</include> <include>*.xml</include> </includes> <targetPath>WEB-INF/config</targetPath> <filtering>true</filtering> </resource> </webResources> <outputDirectory>C:\devel\apache-tomcat-7.0.42\webapps</outputDirectory> </configuration> </plugin> </plugins> </build> ... </project>