title: Recompiling sources with a test specific jar
body: <p>I have a multimodule project that is dependent on a rather large thirdparty library/apis.  It is not possible to run automated junit tests with the actual library, since the apis interact with a system external to the management of the dev environment.  As a workaround, we created classes that mocked the interfaces/apis so that we could do junits.  We use eclipse as our IDE for development, so to run junits, we simply move the jar up higher in the classpath, recompile, run our junits, and everything works great.</p>
  
  <p>Looking for a similar solution now that we are moving to Maven.  Basically, after building our code, need to rebuild all of it again using the mock jar to run junit tests.  This goes across all modules of the application.  I tried adding the jar in the test scope, but that is only used for compiling the test classes; the sources classes are still compiled with the real jar.  However, it fails at runtime since our mock jar does not match all signatures of the real jar (so a hot swap of the jar doesn't work; making all signatures match would be large undertaking).  So the source needs to be recompiled with the jar.</p>
  
  <p>So it appears there are two options:
  1) Make a standalone test module that somehow pulls in all the source modules code and recompiles it using the mock jar and runs the tests or
  2) Each module creates a testjar in addition to its installable jar that compiled with the mock jar, is then used by the dependent modules during the test phase.</p>
  
  <p>Please advise.  Any examples of how to do either of the above would be greatly appreciated.</p>