Question

The case where I would like to generate a second artefact is this. We have builder-classes in the test Code that i would like to reuse in another project. I found this guide-attached-tests and it works fine. After some discussion with my coworkers I read this article How to Create Two JARs from One Project (…and why you shouldn't) from Tim O'Brien. He writes that doing this violates a core convention of maven.

"It violates one of the most important core concepts of Maven: modularity. Once you go down this path, you will likely be tempted to start creating more and more “uber” projects that create multiple JARs."

I don´t see that risk with the test-jar.

The sole statement that "this it is not recommended" or "it breaks the core convention, but it works" doesn´t satisfy me. At least maven offers classifiers which serve exactly the purpose to produce different artifacts from the same pom.

My Question: Is creating a test-jar an exception from the convention or are there more serious problems with this aproach?

Besides. Making the builder classes part of the productive code is another option we are discussing. But that´s not the main point here.

Was it helpful?

Solution

I've written a blog about the downside of the test-jar. The main issue is that you won't get all the (transitive) dependencies you probably would expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top