Re: Several Compilations in one POM.xml
The funny thing about maven is: all people starting with maven (and coming from ant) but don't want to do it the maven way are complaining about the non flexibility. Yeah maven does things completely different. maven uses a lifecycle which meets about 99,9% of the standard projects. If your project does not fit into maven than maven is the wrong way because of maven is convention over configuration, if you cannot stand the conventions you'll end up with a lot configuration.
It sounds like you missing a lot of the maven basics and this is because of you won't do it the maven way, you want to "port" a ant build to maven and that cannot work for your given points.
Maven - Introduction to the Build Lifecycle
Back to the problem:
Sure you can do more compilations than one, either by using multiple executions (that's what you already mentioned) but that only adds multiple compilationsteps in the same phase (compile) or you can extend your goal plugin from the compile plugin, generate source and compile it afterwards. The third possibility is to not create source but bytecode (for example using ASM). Both last possibilities would run in the "process-classes" phase.
For the compile-plugin extending see an example I did:
http://svn.apache.org/repos/asf/dire...ratorMojo.java
Re: Several Compilations in one POM.xml
Forget about ant or whatever I could mention. Here is a simple (yes, may be not typical but not something extreme either) task of three steps: compile java from directory A, do something else (let it be Hello World Mojo from Maven site), compile more java from directory B. This task is tooooo complex (at least so far) for Maven. That is it. Convention over configuration has nothing to do here. In particular I am ready to agree to ANY convention you suggest. Are you able to provide pom for this task?
I will look into the references you've provided, thank you.
Re: Several Compilations in one POM.xml
Not sure what your plugin really want's to provide, I guess the Lightning maven plugin should be a good start but as I said, no idea if that meets your requirements.
Re: Several Compilations in one POM.xml
May plugin by itself works ok. Basically it is a variation of Hello World Sample plugin (and we may consider it as that one). The problem is in using it. So some plugin is wanted to be executed between (in time) two some compilations. If you kindly provide me a skeleton pom for this three-step task that should solve all.
Re: Several Compilations in one POM.xml
Finally I was able to do that. A project with three modules. The main reason it did not work was that at my second step I hooked an old Java code that ended with System.exit(0) on Success. This worked in ant but apparently Maven runs all in one JVM.
To make two compilations work I have defined all three phases/goals as compile/compile.
Re: Several Compilations in one POM.xml
The question is: Why does anyone uses System.exit to exit his program? The need of System.exit 99% of the time shows that the programmer was not able to cleanly shutdown his stuff which directly means he did not understand what he did.
Re: Several Compilations in one POM.xml
The answer is: Using System.exit is the only known to me way to communicate that the program did not do OK to a long DOS batch file that it was called from. I have removed System.exit(0) and all works as expected. When run from Maven none-zero exit code stops Maven which is also desired.
Re: Several Compilations in one POM.xml
Yeah you can use it to return different exitcodes, that's the 1% but as you saw there can always be problems in Java using System.exit.