I have a large multi-project application that uses Maven2 for building and Spring for configuration. When I run some of the Spring based unit tests they pass in Maven2 but fail when run from Intellij. Our Spring expert feels that the problem has its roots in the primary difference in the classpath between Maven2 and Intellij.
When the tests are run from Maven2, the tests see a module's source and test class directories and the jars of all its dependent modules.
When the tests are run from Intellij, the tests see not only the current module's source and test class directories but also the source and test class directories of all the dependent modules. This apparently causes problems with Spring because some dependent modules have Spring configuration files in their test class directories that interfere with the current module's configuration.
What I need is a way to exclude the test class directories of the dependent modules from the current module's classpath when running the tests. Is this possible?
Alternatively, I could use an option during the Maven 2 project import that says depend on the dependent modules jar files and not their classes directories. Apparently Eclipse has such an option.