Tag Archives: wtp

Java

Adding WTP Facet to project via maven

Sometimes when I add new project to my workspace I want to make it available for quick deploy to application container (in my case Tomcat). To do this I have to add WTP project facets. It can be easily done by using Maven plugins.

Check this example from pom.xml:

<profiles>
	<profile>
		<id>war</id>
		<activation>
			<activeByDefault>true</activeByDefault>
		</activation>
		<properties>
			<packaging-type>war</packaging-type>
		</properties>
		<build>
			<finalName>projectName</finalName>
			<plugins>
				<plugin>
					<artifactId>maven-eclipse-plugin</artifactId>
					<configuration>
						<wtpversion>2.0</wtpversion>
					</configuration>
				</plugin>
				<plugin>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>1.6</source>
						<target>1.6</target>
					</configuration>
				</plugin>
			</plugins>
			<resources>
				<resource>
					<directory>src/main/resources</directory>
				</resource>
			</resources>
			<testResources>
				<testResource>
					<directory>src/test/resources</directory>
				</testResource>
			</testResources>
		</build>
	</profile>
</profiles>

I added here maven-compiler-plugin because without this you can get following error message:

Dynamic Web Module 2.5 requires Java 1.5 or newer.