maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Sch├Ątz <FScha...@assona.net>
Subject Where to keep test only files that are needed in multiple projects?
Date Thu, 22 Dec 2016 14:33:28 GMT
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
Mime
View raw message