Attached is a file, which I do suggest as a replacement for the MavenEmbedder. When using this embedder, submodules are called fine.
I have decided against fixing the MavenEmbedder, because it is, IMO, a real mess. Not so much, because the code is bad or something similar, but because it is basically a replacement of the DefaultMaven class. However, both classes are really difficult and are doing basically the same things. IMO, they cannot, and should not, be maintained separately. A more sensible approach seems to me to use the DefaultMaven for both the usual Maven, and for embedded Mavens.
My suggestion does not resolve the problem of duplicate code. Rather it introduces new duplicates, this time between the MavenCli class and the suggested MavenEmbedder2. To resolve this, I propose the following:
- Introduce a new class, or interface, MavenCliOptions, or whatever it may be called.
- Move the methods isDebug(), getAlternatePomFile(), ... from MavenEmbedder2
to the new class.
- Change the method MavenEmbedder2.execute(String[], File) to
execute(String[], File, MavenCliOptions)
- Remove most code from MavenCli. The class should basically create an instance
of MavenCliOptions and call MavenEmbedder2.
Sample project demonstrating the problem. Run "mvn package" in the top level directory.