I\'m looking for a general technique here, but let\'s give a specific example. I have a multi-module project and I\'d like to run the exec:java
goal from the co
A somewhat general technique that I've used in this circumstance is to define a profile in the submodule POM in question that binds exec:java to the test phase. For example:
test-java
org.codehaus.mojo
exec-maven-plugin
1.1.1
test
java
com.foo.bar.MyClass
Then from the top of your project, run:
mvn test -Ptest-java
This will set up the inter-module classpath as usual, and attempt to run the test-java profile in all of your subprojects. But since only the one you care about has the profile defined, it's the only one that will do anything.
It does take a wee bit of extra time for Maven to grind through your other subprojects NOOPing, but it's not so bad.
One thing to note is that the subproject is run with the top-level directory as the current working directory (not the subproject directory). There's not much you can do to work around that, but hopefully that won't cause you trouble.