I am trying to convert a multi-module project that we have
traditionally used Ant to build and run tests into Maven2.

I've already done this successfully for some other internal projects
and been very happy with it.

However, I'm running into a new problem with this particular project.
Several of our unit tests read from external resources, and it seems
like I'm not accessing the resources in a Maven-compatible way. And
YES I already moved my resources to module/src/main/resources/...
rather than keeping them in /src/main/java, and when I look in
target/test-classes, I can see they have been copied there, and are
available for the unit tests to use as needed.

So the modules consist of:
root (pom.xml, type pom)
- common (pom.xml, type jar)
- ejb (pom.xml, type jar, dependency on common)
and some others.

When I run "mvn clean package" while in the common subdirectory, all
my tests pass fine.

When I run "mvn clean package" while in the root directory, to have it
build the common and ejb packages as modules etc, the tests fail.

Here's the code for accessing the resource:
old ant style
File file = new File("src/com/mypackage/test/util/test.txt");

new maven style, works sometimes
File file = new File("target/test-classes/com/myproject/util/test.txt");

I could probably change that line to:
File file = new File("common/target/test-classes/com/myproject/util/test.txt");
and it would work in the root directory, but then it would fail again
when calling from common subdir.

I know there are ways to use getResourceAsStream() etc that would
probably solve all my problems. I just don't know the right code to
make it happen!

Thanks for any help.
Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to