Rob Elliot
07/21/2021, 9:39 AMkotlin-maven-plugin
, is there a way to exclude a dependency from the test compile classpath?
Context - I’m migrating a project from JUnit 4 to JUnit 5. But it uses testcontainers, which has a transitive dependency on JUnit 4. It’s really easy to accidentally use JUnit 4 annotations, and then find your tests aren’t running… I’d like to exclude JUnit 4 from the test compile classpath so that if you do so you find out fast.
Maven doesn’t distinguish between compile & runtime for test scope (why not?!) so I can’t just drop it down to be a runtime scoped dependency.
I could exclude it as a dependency of testcontainers, but:
a) that would exclude it from the runtime classpath, and testcontainers probably needs it
b) the odds are some other dependency will bring it in, now or later… playing whack-a-mole like that is zero fun
(Yes it would be easy in Gradle. No I’m not up for having that fight now.)hho
07/21/2021, 10:06 AMRob Elliot
07/21/2021, 10:08 AMGenericContainer
implements org.junit.rules.TestRule
. I’m fairly sure the JVM will fail trying to load a class where some of the supertypes are not on the runtime classpath.hho
07/21/2021, 10:11 AMRob Elliot
07/21/2021, 10:12 AMRob Elliot
07/21/2021, 10:26 AMkotlin-maven-plugin
, in the hope that the kotlin-maven-plugin
has a way to modify the compile time classpath. In what possible way is that NOT KOTLIN
?hho
07/21/2021, 11:45 AMRob Elliot
07/21/2021, 11:49 AMkotlin-maven-plugin
to alter the classpath.