Java dependency management has been a struggle in Mendix projects for a long time. Especially when you had no idea they existed in the first place. Sure, you might have imported a module or two from the Marketplace, and you might have even seen information about having to remove a userlib Java JAR, but most users have no idea.
With Mendix 10, Managed Dependencies have been introduced. This allows module developers to specify the Java libraries required to use the module.
Instead of placing these modules in the userlib folder, they are placed in the vendorlib folder. On top of that, a nice vendorlib-sbom.json file is created based on the dependencies specified.
“Mendix Studio Pro allows you to manage your Java dependencies. By specifying Java dependencies and their versions per module, Studio Pro can automatically download them and resolve conflicts by leveraging Gradle.”
This makes upgrading modules much easier. Instead of cleaning up any old Java libraries during an upgrade, Studio Pro will take care of them.
Once the dependencies are specified, they are automatically downloaded from Maven and Gradle repositories. If needed, you may specify custom repositories yourself in the Studio Pro settings.
Different versions of the same library or even libraries with the same classpath/-names could cause conflicts. For this particular reason, libraries may be specified with exclusions. This will ensure proper compilation and execution of every module.
When you upgrade your project from Mendix 9 to 10, you must update your modules to be compatible again. Most, if not all, platform-supported modules support the new dependency management (vendorlib), and even community-supported modules are gaining support. This means your upgrade to Mendix 10 will hopefully be the last time you must clean out the userlib folder.
I suggest moving all the existing files into a separate folder, and when the userlib folder is empty, start updating the modules. This should take care of most, if not all, dependencies getting imported via the new dependency management functionality.
The remaining dependencies will be those in your Java code. Use Sonatype’s Maven repository to look up the missing dependencies and add them to your module settings.
The managed dependencies will save many Mendix developers the headaches of managing the userlib folder mess that usually accumulates over time. It will also save module builders a lot of instructions for those developers who need to clean up older versions of the libraries included in the modules they build.
This is an excellent step in the area of developer experience improvements.
If you have any questions or need help with the transition, message us!