3

I have an application that has both JPMS modules and old fashioned non modular jar files. I don't want to put all of the jars on the classpath because then I loose some specific functionality baked into the modules (such as JPMS service provider interface). I also can't put the old fashioned jars on the module path as automatic modules because they have many package name conflicts.

The solution is to use both the module path and classpath at once. I could define the contents of my classpath and module path manually but this is liable to breaking if a dependency changes with a new version. As such this really needs to be done automatically and I have seen that this is actually done with maven-surefire when running unit tests as well as eclipse when launching the application from the IDE.

Does anyone know if there is a an existing library (or preferably maven plugin) that allows me to separate the dependencies that can be on the module path and the dependencies that have to be on the classpath in the same way that surefire or eclipse does?

  • Few things to clarify - *I have seen that this is actually done with maven-surefire when running unit test*, does the plugin list out dependencies on its own or expects you to specify the configuration? and you want to do this for an actual compile-time(or further runtime as you build) while using maven? – Naman Nov 23 '20 at 11:24
  • I am not 100% sure exactly what you want clarified so giving this my best shot: 1. I know that surefire will do this because when it runs unit tests it creates a separate java invocation where it creates arg files referenced with "@" in the execution. This is done by surefire without any configuration. You can see this behavior by having surefire crash (which leaves the arg files in the target directory). 2 I want to be able to do this myself for the packaging phase (or before then really) such that I can create one directory with classpath dependencies and one with module path dependencies. – oscar.haglund Nov 24 '20 at 08:23

0 Answers0