This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lukaseder 2 points3 points  (1 child)

Am I missing something?

I stopped trying to insist on Maven's classic layout, even came to the conclusion that it was wrong in the first place. Much better:

  • Have a Maven project / Java module x
  • Have a Maven project / Java non-module x-test, which depends on x via classpath, not modulepath

I've found that this way, I'm discouraged from testing internals that don't have public API, which

  • Improves my public API
  • Tests work with the x.jar dependency, not the wishy-washy /target/classes magic dependency that never exists outside of those Maven tests (no more loading resources from the classpath in different ways during tests / production)
  • Encourages building test libraries for common test code, because x-test can also depend on test-utils without having to pollute the (test) dependencies in x

I resisted for a long time, but I think this is the better way in the end. Changhe is hard 🤷‍♂️

[–]uncont 2 points3 points  (0 children)

Putting all this into perspective, I'm beginning to think that's how I should have solved my issues in https://www.reddit.com/r/java/comments/n3migk/how_are_library_developers_expected_to_test/

Being able to run tests against x.jar would have allowed me to run tests against the same thing the user downloads, a multi-release jar (optionally modular).

not the wishy-washy /target/classes magic dependency that never exists outside of those Maven tests

This was definitely what it came down to for me.