Hi Mark,
I ran into a similar problem today, July 12th. In the logback project in order to test support for jigsaw/jpms in maven-module 'x', we create a maven-module called x-blackbox. The x-blackbox module contains junit5 tests under src/test/java and without a src/main folder. This works nicely. I have tried to do the same for the jul-to-slf4j module in slf4j. Thus, I have created jul-to-slf4j-bloackbox module following the same recipe as in the logback project. To my astonishment this resulted in the following error: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile failed: Can't compile test sources when main sources are missing a module descriptor I have tried fixing the problem by tweaking plugin and jdk versions to no avail. However, as far as I can tell, the only significant difference between slf4j and logback is that slf4j uses junit4 and logback uses junit5. Moving jul-to-slf4j-bloackbox module into a distinct project and using junit 5 fixed the issue. It seems to me that moving to Junit 5 is the critical element. WARNING: The assertion above is speculative as I have not tried to debunk said assertion. Best regards, ps. I did not have time to read https://github.com/junit-team/junit5/discussions/3370 -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 6/29/2023 7:02 PM, Mark Raynsford wrote: > (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? > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org