You can use the maven-jar-plugin's test-jar goal: https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html
That creates a second jar with the same coordinates but a 'test' classifier that you can add as a test scoped dependency on myproject-application. João Cabrita On 22 December 2016 at 14:33, Florian Schätz <[email protected]> wrote: > Hello, > > let's assume a simple maven project consisting of two modules: > > - myproject-basicstuff > - myproject-application > > ...in which myproject-application has the myproject-basicstuff as a > dependency. > > Now let's say we have an arbitrary class in myproject-basicstuff: > > public class Data { > > ...has some data content... > > } > > Since I am using AssertJ, I want to create a custom Assert for that... > > public class DataAssert extends AbstractObjectAssert<DataAssert, > Data> { > > ...etc... > > } > > (If you don't know assertions, simply assume a Hamcrest matcher or > similar.) > > All of this is pretty straight-forward, but now there's one problem: > Where to put the custom assertion? > > If I put DataAssert into myproject-basicstuff/src/main/java, then I need > to include AssertJ as a runtime dependency, "polluting" my classpath > with it - because I only actually need AssertJ during test time. > > If I put DataAssert into myproject-basicstuff/src/test/java, then I > cannot use it in myproject-application, since the test classpath doesn't > get inherited. > > If I create an additional module myproject-basicstuff-test, then I > cannot use it in myproject-basicstuff, since that would be a circular > dependency... > > So, is there a chance to somehow keep the whole shebang in the test > scope? > > Regards, > > Flo >
