You will need to organize the root pump so that the test modules are activated through the profile and instead of -Dmaven.test.skip to enable -P!testProfile to disable them and therefore skip them.
Another thought is that you could just do:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <skip>${maven.test.skip}</skip> </configuration> </plugin> </plugins>
I actually have not tried this ... it should theoretically work. I seem to remember that the <skip> configuration is in all plugins.
source share