use basedir system property avaiable in any maven build new File( basedir + "/src/webapp", web.xml)
-D On 4/14/06, Gordon Henriksen <[EMAIL PROTECTED]> wrote: > > We're using Eclipse and Maven. I've got some unit tests for a web > application (war packaging), and I'd like to pull in web.xml for an > in-memory servlet container (servletunit). I was being really deeply > and exceedingly lazy and using: > > new File("./src/webapp/web.xml"); > > This smacks of 'the wrong way to do it' to me, but it was sufficient > for the task at hand. > > And it worked fine under Eclipse, but then I went to mvn test before > committing; to my disappointment, Maven runs the unit tests relative > to the parent pom, more often than not, so I can't use a relative > path. After some research I tried this instead: > > Thread.getContextClassLoader().getResourceAsStream("/WEB-INF/ > web.xml"); > > That gets me no love, though. Am I using the wrong path? I've tried > several different methods of getting class loaders, and several > different path names, but to no avail. Is anyone else doing this? And > please forgive any naiveté regarding Java resource handling. :) > > In the meantime, I'm hardcoding the servlet mappings. > > — G > > >