I've got a Java project in Maven with the following (simplified) structure:
module-alpha
src
main
test
java
TestUtils.java <-----------------------
module-beta
src
main
test
java
TestUtils.java <-----------------------
...
module-yotta
src
main
test
java
TestUtils.java <-----------------------
There is a class TestUtils.java
repeating itself along the project. (It's a simple class I wrote as a library for needed stuff in every unit test.)
How can I avoid this code redundancy?
You need to create a different maven project that include
TestUtils.java
and build it as a jar e.g. test.jar.Then use test.jar as a local dependency of relevant projects.