in one of our projects we are using maven to build our web
application. part of our build process involves maven resource
filtering, in particular, we need to insert
path names into resources controlling the build process. since our
team uses both linux and windows, we need to be able to generate file:
URLs that work irrespective of the underlying platform.
using a construct like
file://${project.build.directory}/path/to/stuff
didn’t really work: on linux the resulting file: URL was usable, on
windows it was not: there was a / missing plus all \ occurences
had been escaped.
after trying a couple of variations, i came across the available
variables section of the maven documentation which
listed project.baseUri — which seemed just the ticket!
alas, it turns out that maven’s resource plugin currently does not
know about ${project.baseUri} — doh. yet, not
all hope is lost: by adding the following property definition to the
project’s pom.xml file did the trick:
[xml] <properties> … <projectBaseUri>${project.baseUri}</projectBaseUri> … </properties> [/xml]
instead of ${project.baseUri} we use ${projectBaseUri} in the
resource file, which gets translated to the desired file:
URL. bingo.
