I am trying to make the Eclipse to IntelliJ X switch and running into problems with certain automated functional tests that rely on relative file paths to work.
My project is a multi-module maven project and was imported into IntelliJ X as such.
As a straw man the maven project consists of modules A, B and C. Module A is the parent and is located on the root of the file system ("/A"). The project has the following structure:
A few of functional tests for projects B & C stand up a jetty container with /src/test/webapp as the root of application context. That dir contains the web.xml, /WEB-INF dir etc. The location of the root app context has always been defined as a relative file path (new File("src/test/webapp")). This works perfectly in eclipse and maven because the JVM executing the tests has a "user.dir" property that points to the modules root dir. For instance, when running an integration test in project "C" the value of "user.dir" is "/A/C". This is consistent with eclipse ... largely because eclipse needs to treat each separate module as a separate Eclipse project.
The entire project was imported into IntelliJ as an existing Maven module using a file based project file format. That generated a project with modules for "A", "B" and "C". For every integration test in either the "B" or "C" modules the value of "user.dir" is always "/A". This throws off the relative paths pointing to the root application context.
In order to work around this I added a "marker" file to the webapp dirs -- i called it "webapp.root" ("/A/B/src/test/webapp/webapp.root"). After adding the webapp dir as a test resource dir I can derive the absolute path to the webapp dir by looking for the URL to "webapp.root" classpath. Although that solved my immediate inability to start the jetty container used for some functional tests it is pretty tedious. I suspect that there will be other tests that rely on these relative paths for other things as well (e.g. to save error or diagnostic info in the modules target dir) that i have yet to run into.
Is there any way to specify a modules user.dir so that I can keep it simple, centralized and maven friendly?