January 12, 2010
filed around lunchtime by dr_who in: hacking
average time to read 0:54 minutes

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


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:

instead of ${project.baseUri} we use ${projectBaseUri} in the resource file, which gets translated to the desired file: URL. bingo.

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.