Reputation: 2638
Consider this directory structure:
src/main/resources/
resource1.properties
subdir/
resource2.properties
I need resource2.properties
(and its siblings) to undergo Maven filtering but would rather exclude all other resources from filtering.
This is a safety: other property files may contain ${xxx}
tokens which should not get substituted. I do need to preserve the source directory structure on the target
.
In the end, I found that the only way to achieve this (in a way that doesn't break maven-eclipse-plugin's eclipse:eclipse
) seems to be:
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>subdir/**</exclude>
</excludes>
</resource>
<resource>
<!-- 'subdir' resources need placeholder substitution (ie: "filtering") -->
<directory>src/main/resources/subdir</directory>
<targetPath>${project.build.outputDirectory}/subdir</targetPath>
<filtering>true</filtering>
</resource>
</resources>
You could say this is convoluted and potentially brittle. This is using Maven 2.2.1 with maven-eclipse-plugin v2.8 (latest).
Other, slightly less convoluted versions of the above have triggered issues with maven-eclipse-plugin, which complains with smth similar to:
[INFO] Request to merge when 'filtering' is not identical. Original=resource src/main/resources: output=target/classes, include=[], exclude=[subdir/**|**/*.java], test=false, filtering=false, merging with=resource src/main/resources: output=target/classes, include=[subdir/**], exclude=[**/*.java], test=false, filtering=true
This recalls this old thread: the workaround mentioned there works (downgrading to v2.6 of maven-eclipse-plugin) but this should no longer be required because the related bugs are marked as fixed?
This doesn't look like too far fetched a use case, yet I'm struggling...
Upvotes: 0
Views: 4518
Reputation: 97409
What about this:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources/subdir</directory>
<targetPath>${project.build.OutputDirectory}/subdir</targetPath>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
Upvotes: 1