How does Grails handle plugin dependencies

前端 未结 1 1961
轻奢々
轻奢々 2021-01-03 07:41

I\'m creating a Grails Plugin as a wrapper for a complex product. This product has a lot of dependencies to other products like hibernate. The issue is, that grails has some

相关标签:
1条回答
  • 2021-01-03 07:56

    Grails has a dependency resolution mechanism that resolves conflicts among the dependencies of:

    • Grails itself
    • The Grails application
    • The application's plugins
    • The plugins dependencies

    Just make sure that you specify what your plugin depends on, and let Grails' dependency resolution take care of the rest. Grails historically used Ivy for dependency resolution, but starting with Grails 2.3.0 the default is Maven/Aether with the option to use Ivy.

    Occasionally in an application, you'll want to override the choices made by the dependency resolution, e.g. exclude a transitive dependency or force a particular library version to be used, you can do all this in BuildConfig.groovy

    As usual, the Grails reference document provides very comprehensive coverage of this topic.

    Update

    Further to your comment below, if you put a JAR in the lib directory of your application it will be ignored by the dependency resolution and placed on your classpath directly. So you shouldn't normally do this. Specify the JAR and it's version in the dependencies section of BuildConfig.groovy instead.

    Update 2

    The syntax for specifying a JAR is

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

    group, artifact, and version collectively identify what (JAR) you want to download, whereas scope specifies how you want to use the JAR. The easiest way to find the group, artifact, and version of a particular JAR is to search a Maven repository.

    Read this to learn about the different scopes you can use.

    0 讨论(0)
提交回复
热议问题