Change Maven WAR directory Path

Change Maven WAR directory Path

By default when you install project maven creates WAR file inside target directly and if you want to change this defualt location of WAR creation directory path you could do below:

<build>
	<finalName>ChangeWARLocation</finalName>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-war-plugin</artifactId>
			<version>2.5</version>
			<configuration>
				<warName>ChangeWARLocationModified</warName>
				<outputDirectory>C:\JavaHonk\MavenWAR</outputDirectory>
			</configuration>
		</plugin>
	</plugins>
</build>
  • Sample maven project:

Change Maven WAR directory Path

  • pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>ChangeWARLocation</groupId>
	<artifactId>ChangeWARLocation</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>ChangeWARLocation Maven Webapp</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<finalName>ChangeWARLocation</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.5</version>
				<configuration>
					<warName>ChangeWARLocationModified</warName>
					<outputDirectory>C:\JavaHonk\MavenWAR</outputDirectory>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
  • For information about maven build please refer Apache link here 

Leave a Reply

Your email address will not be published. Required fields are marked *