atom feed6 messages in org.apache.maven.usersWhere to keep test only files that ar...
FromSent OnAttachments
Florian SchätzDec 22, 2016 6:33 am 
João CabritaDec 22, 2016 6:43 am 
Dirk OlmesDec 23, 2016 12:39 am 
Christian SchulteDec 23, 2016 12:48 am 
Florian SchätzDec 23, 2016 7:50 am 
Christian SchulteDec 23, 2016 1:08 pm 
Subject:Where to keep test only files that are needed in multiple projects?
From:Florian Schätz (FSch@assona.net)
Date:Dec 22, 2016 6:33:28 am
List:org.apache.maven.users

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