I have imported a multi-module Maven project that includes one or more child modules that do not have source code. These modules are either sourceless POMs used as parents, or could simply declare dependency sets referenced by other modules. If any war modules depend on these empty modules, then attempting to build this project results in the following error:
Error: Directory '<path\to\module>\target\classes' not found. Please recompile module '<SourcelessModule>'.
Recompiling the specific module does not resolve the error.
Expected behavior would be one of the following, in order of decreasing desirability:
1) When importing a project, configure sourceless modules to allow compiles to succeed. (Not exactly sure what IDEA is looking for, so I cannot say more specifically what this is.)
2) Have the build for a sourceless project create the expected directory to suppress the error
3) Have the import create the src/main/java folder to prevent the error from happening
Note that, if a plain jar module depends on an empty module, everything works fine. The problem only occurs when the dependency is from a war module.
I have attached a sample project that illustrates this issue. Import the parent POM and attempt to build the project. The error is in the messages window.
Presently, I am working around this by creating empty src/main/java folders in all projects that do not have source, and committing those to Subversion. This works, but ideally the IDE wouldn't require this.
The better way to share dependencies is to use inheritance and set packaging method to 'pom'.
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance
Will that resolve your problem?