How do I exclude particular resources from being processed?
Author: Deron Eriksson
Description: This maven tutorial describes how to exclude particular resources from being processed.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


Page:    1 2 >

Suppose that we have the following "aproject" project that contains files in a src/main/resources directory. In the following example, this directory contains two text files and two HTMLW files.

'aproject' in Eclipse Navigator View

We might have a situation where we're interested in allowing some of the files to be added to the build while other files are excluded. We can specify resources that we'd like to include and exclude in our pom.xml file. The following pom.xml file specifies that we'd like to exclude all files with the .htm extension within the resources directory. In this pom.xml file, I also need to explicitly specify the location of the resources directory since I'm overriding the defaults.

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>com.maventest</groupId>
	<artifactId>aproject</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>aproject</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>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<excludes>
					<exclude>**/*.htm</exclude>
				</excludes>
			</resource>
		</resources>
	</build>
</project>

(Continued on page 2)

Page:    1 2 >