I\'m trying to build a jar that has an xml file as a resource. I\'d like to apply a filter to that xml to insert the name of a dependency into the xml. The filtering is wo
Damn, you're right, this property doesn't get replaced during the filtering of resources. That's weird and it sounds like a bug in the Maven Resources Plugin because this property is correctly interpolated during the process-resources phase as I'll demonstrate in the workaround I'm suggesting below (based on the maven-antrun-plugin and the replace task).
First, add the following to your POM:
maven-antrun-plugin
process-resources
${project.dependencies[0].artifactId}
run
Then, update your XML file into:
@@@
With these changes, running mvn process-resources would produce the following result:
$ cat target/classes/myxmlfile.xml
OtherLibrary
Which proves the property is interpolated (but not set during maven filtering of resources)1. And if you need to filter more than one file, the replace task can take a fileset. Adapt it to suit your needs.
1 Actually, it would be nice to create a new Jira for this bug in the Maven 2.x Resources Plugin. I've created MRESOURCES-118.