Java sources not in classpath into multi-module project (maven)

Hi,
I have this scenario:
I have a project (maven) that has it's own dependencies.
From project structure, I added two projects (maven) as modules, I deleted old maven dependencies  and moved up the modules in the dependencies list.
It correctly compiles and works, but I have a problem when I make a unit test with gwt test. Running the test it gives this error:

2014-05-15 01:00:23 ERROR GwtTreeLogger:58 - Unable to find type 'my.package.MyClass'
2014-05-15 01:00:23 ERROR GwtTreeLogger:58 - Hint: Check that the type name 'my.package.MyClass' is really what you meant
2014-05-15 01:00:23 ERROR GwtTreeLogger:58 - Hint: Check that your classpath includes all required source roots

Looking at the classpath it doesn't seem to include src path, and gwt test needs the sources.
I added the dir to classpath manually copying the classpath from junit output, in run configuration for the test, and it works, but it's not so confortable.
Is there a way so IDEA includes sources in classpath by itself?

Thanks for help

3 comments

I've got a somewhat similar problem, but given the date of the original post, I guess I shouldn't be too optimistic about getting an answer.

I have an IDEA project with multiple packages and a pom that formerly produced a single JAR as artifact. I now need multiple submodules with their own JARs, so I followed directions to get IDEA to create one child module (as a PoC) and made the parent pom artifact "pom" instead of "jar".  Maven now builds my submodule JAR just the way it's supposed to.  

The problem is with the Junit tests. The tests are in the test source folder in packages that correspond to the main source packages their targets reside in: before I converted the project to multi-module they were therefore able to import the target classes without explicit import statements. Now they can't see the targets at all and of course refuse to compile.

I realize that I could bring the test sources into the main source folder, but that would require pom tweaks to exclude them from the JAR.

Is there any way to configure the classpaths so the tests will compile where they are?

Here's a screenshot of the problem - sorry, don't seem to be able to resize it.  Note same package (if you can read the text), and target refs in red:


IDEA-Maven-Multimodule problem.png

0

if your project is set up as a standard maven project, the test sources are automatically excluded from the jar.
so have in your jar module a src/main/java and a src/test/java directory.

Capture.PNG

that way your tests will be executed for each (sub) module as it is built, also allowing the modules to be built independently from the main project and still have the tests executed.

0

Jeroen,

Your project structure looks exactly like mine, but you're obviously not having my problem: my tests don't compile because they can't see their targets in the source folder.  The Maven build does exclude the tests and create the JAR just the way it's supposed to.  It doesn't run the tests most likely because they don't compile:


IDEA-Maven-Multimodule problem2.png

0

Please sign in to leave a comment.