Where is your resource file located in your source code tree?
It should be under src/main/resources. I will assume it is under
src/main/java -- that's your problem.
Wayne
On 5/13/07, Rossmanith, Philipp <[EMAIL PROTECTED]> wrote:
Hi,
I have a component that is loading resources/files from the classpath and for
which I have written a JUnit test. However, when I run the tests with Maven
from the command line, they fail - obviously due to some classpath problems.*)
My assumption was that target/test-classes would form part of the classpath,
which a test output with maven -X confirmed. **) The idea I got was that once
the resource file (here: a properties file) would be found if it was contained
in this folder. However, if I write out the classpath programmatically from
within the JUnit test, it doesn't contain the folder.***)
Please note that running the same test in Eclipse is working if I add the
test/resources folder as a source folder (with output in target/test-classes).
Now my question is: How can I make add these non-Java resources to the a Maven
classpath? Is there a way to configure the classpath that Maven is looking at
via the POM?
Any help on this would be highly appreciated, as I already blew 2 days on this.
I'm using Maven 2.0.6 and JUnit 3.8.1 unit tests.
Thanks in advance,
Ciao, Philipp
*) I get a NPE for an input stream i create via
ClassLoader.getSystemResourceAsStream(this.filePath1).
**) From a file dump:
>>
[DEBUG] Adding to surefire test classpath: C:\Documents and
Settings\9prossma\.m2\repository\org\codehaus\plexus\plexus-utils\1.1\plexus-utils-1.1.jar
[DEBUG] Test Classpath :
[DEBUG] C:\Manchester\utilities\target\classes
[DEBUG] C:\Manchester\utilities\target\test-classes
<<
***) System.out.println("Class path: " + System.getProperty("java.class.path")):
>>
Class path: C:\Documents and
Settings\9prossma\.m2\repository\org\apache\maven\surefire\surefire-api\2.0\surefire-api-2.0.jar;C:\Documents
and
Settings\9prossma\.m2\repository\org\codehaus\plexus\plexus-utils\1.1\plexus-utils-1.1.jar;C:\Doc
uments and
Settings\9prossma\.m2\repository\org\apache\maven\surefire\surefire-booter\2.0\surefire-booter-2.0.jar
<<
This e-mail may contain confidential or privileged information. Any unauthorised
copying, use or distribution of this information is strictly prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]