How Grails Manages Plugin Dependencies

I am creating a Grails plugin as a wrapper for a complex product. This product has many dependencies on other products, such as hibernation. The problem is that grails has the same dependencies, but with different versions. For instance. Grails β†’ winter 3.6.7 other product β†’ hibernate 3.5.6

How does Grails handle plugin dependencies? Does Grails create a separate ClassLoader for each plugin? Is this customizable?

Thanks in advance!

+4
source share
1 answer

Grails has a dependency resolution mechanism that resolves conflicts between dependencies:

  • Grails itself
  • Grails app
  • Application plugins
  • Plugin dependencies

Just make sure you point out what your plugin depends on, and let Grails dependency resolution take care of the rest. Grails has historically used Ivy to resolve dependencies, but starting with Grails 2.3.0, Maven / Aether with the ability to use Ivy is used by default.

Sometimes in an application, you want to override a selection made by resolving a dependency, for example. exclude transitive dependency or force the use of a specific version of the library, you can do it all in BuildConfig.groovy

As usual, the Grails reference document provides a very comprehensive overview of this section .

Update

In addition to your comment below, if you put the JAR in the lib directory of your application, it will be ignored by dependency resolution and will be directly placed in your classpath. Therefore, you usually should not do this. Specify the JAR and its version in the dependencies section of BuildConfig.groovy .

Update 2

Syntax for specifying JAR

 <scope> <group>:<artifact>:<version> 

the group, artifact, and version collectively determine which (JAR) you want to load, and the area determines how you want to use the JAR. The easiest way to find the group, artifact, and version of a specific JAR is to look for the Maven repository .

Read this to find out about the various areas that you can use.

+6
source

Source: https://habr.com/ru/post/1390657/


All Articles