I have a multi-module maven project like this :
project
project-core
project-webapp
project-core
is a dependency of project-webapp
. When building project-core
, I exclude some elements from the final jar. When I build and deploy the whole project with maven (through m2eclipse), everything is fine.
However, if I build and deploy with WTP, the resource filtering is skipped.
The only work around I have found so far is to disable workspace resolution from m2eclipse. This way, WTP builds the final war with the jar built by maven. The major drawback with this workaround is that I must install, update project each time I modify the project-core
source code.
How can I force WTP to filter out resources from project-core
?
project/project-core/pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>project</artifactId>
<groupId>com.company.project</groupId>
<version>1.0.0</version>
</parent>
<artifactId>project-core</artifactId>
<name>project-core</name>
<version>${version.project}</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
// (huge) dependencies list ...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<excludes>
<exclude>file.properties</exclude>
<exclude>DIR/file.xml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
// repositories ...
</repositories>
</project>
EDIT:
However, if I build and deploy with WTP, the resource filtering is skipped.
Actually I was not doing the filtering at the right phase. The resources were filtered only during the jar building. Thanks to @Samuel EUSTACHI, I filter now the resources when they are copied to the target
folder. Here how I did it :
project/project-core/pom.xml
<build>
<!--
I removed completely the plugins node and
replace it with the resources node
-->
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>file.properties</exclude>
<exclude>DIR/file.xml</exclude>
</excludes>
</resource>
</resources>
</build>