Custom Plugin transitive Dependency resolution in BuildConfig.groovy Grails 2.2.3

可紊 提交于 2019-12-04 14:32:18

Important actions to note and rectify (w.r.t Grails 2.2.3):

  • Check your application.properties file. There should not be any reference to installed plugins in application.properties. If you had been installing plugins using the install-plugin command (which I discourage now since it will no longer be available), they were likely be written to that file. Delete any lines referencing installed plugins before you do a grails refresh-dependencies and grails maven-install.

  • Upgrade release plugin inside your plugin to v2.2.1

as below if you are using latest version of grails.

......
build(":tomcat:$grailsVersion",
          ":release:2.2.1") {
        export = false
}
.......
  • When you do grails maven-install on the plugin, the resultant zip created will be named as grails-my-plugin.zip if the plugin project name is MyPlugin, but when you refer the plugin in your grails application (retrieving from .m2 local repo), you have to refer the plugin as

    compile ':my-plugin:0.1' //instead of "grails-my-plugin"

Observation:

  • I was facing issues (related to svn plugin) using release:1.0.0 (deliberately downgraded to replicate your issue) when testing so it is a better idea to upgrade to version 2.2.1 if you are using Grails 2.2.* etc. You would not be able to use v3.0.0 unless you use Grails 2.3 as mentioned in the doc.

  • It did not complain anything when I used mygrid repo while testing. [http://www.mygrid.org.uk/maven/repository]

  • Once my-plugin was added to my application I was able to compile my app where it installed spring security core referred from my-plugin.

  • Dependency report showed the transitive dependencies as well.

Tested in Grails 2.2.3

on the plugin project run package-plugin. it will generate the dependency file for you. Than you should not get this dependency issue.

Ramson Tutte

I had a similar issue of application not detecting transitive dependencies from plugin. My plugin's grails version was 2.3.4 and the app that used the plugin was 2.1.0.

The plugin was packaged using grails publish-plugin and manually uploaded to a private Maven compatible repository(Artifactory).

Grails 2.3.4 doesn't generate dependencies.groovy and the app didn't figure out the transitive dependencies and failed compilation.

As @rittinger mentioned in this post custom-plugin-dependencies-groovy-is-ignored pom does the trick. When I manually uploaded the plugin.zip file to Artifactory, it generated a pom file which didn't have a <dependencies/> section.

But when I followed the release plugin instructions and uploaded the plugin to Artifactory, the generated pom file had <dependencies/> section. Afterwards the App didn't have any problems resolving transitive dependencies.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!