(Re-sent using correct address!)

Hello!

I recently started a discussion thread on the JUnit 5 repos detailing a
problem I'd been running into on a lot of projects:

  https://github.com/junit-team/junit5/discussions/3370

Long story short: In my projects, for various reasons, I put all of the
tests in one module rather than having a src/test/java in each. This
works fine, except for the fact that I have to maintain duplicate module
descriptors in the src/main/java and src/main/test directories of the
*.tests module, and I also have to maintain a shadow package hierarchy
in src/main/java filled with empty classes (one for each exported
package).

I'm about to start experimenting with putting test sources in
src/main/java in the *.tests module, but I'm slightly nervous about
doing this. It's quite an obvious divergence from Maven's conventions
(although arguably putting all tests in a *.tests module might be
considered one too [although the conventions were chosen before
Java platform modules existed!]). I'm not clear on how all of the tools
might misbehave if tests aren't in the source directory they're expected
to be in.

I realized I'm really only doing this because the Maven Compiler plugin
produces the error above if I don't have module descriptors in both
directories:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile
(default-testCompile) on project com.io7m.idstore.tests: Execution
default-testCompile of goal
org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile
failed: Can't compile test sources when main sources are missing a
module descriptor -> [Help 1]

Is there perhaps a better way to get the Compiler plugin to ignore
src/main/java and just compile the tests?

-- 
Mark Raynsford | https://www.io7m.com

Attachment: pgp0cfaNm2HEt.pgp
Description: OpenPGP digital signature

Reply via email to