I've installed the asynchronous mail plugin into a Grails 2.1.4 application. This plugin has a dependency on version 2.1.1 of the Hibernate plugin, whereas my app depends on version 2.1.4 of the Hibernate plugin.
Every time I execute a Grails command like run-app, I am asked the following question:
You currently already have a version of the plugin installed [hibernate-2.1.4]. Do you want to update to [hibernate-2.1.1]? [y,n] n
I know that run-app has an --non-interactive argument, but AFAIK this will automatically answer y to this question. Ideally, I would like to solve this problem by excluding the transitive Hibernate plugin dependency from the asynchronous mail plugin, but transitive dependency exclusion only seems to be possible for JAR dependencies.
The docs in the plugin page are wrong - you need this for any Grails app not using version 2.1.1, not just older apps:
compile(":asynchronous-mail:1.0-RC3") {
excludes 'hibernate'
}
Related
Having updated my Grails app from Hibernate 2.2.4 to 2.2.5, I now get the following every time I run 'grails war':
You currently already have a version of the plugin installed [hibernate-2.2.5]. Do you want to update to [hibernate-2.2.4]? [y,n]
I understand that this is probably because of some requirement in a plugin I'm using, and the normal advice is to run 'grails dependency-report'. I've done that but I'm unsure how to interpret the result and take the necessary action to update the dependency. Any input would be appreciated.
My problem seems to have been to do with having Shiro plugin version 1.2.0 installed. When I updated to 1.2.1, the issue with the Hibernate version was resolved.
I asked this question on the Grails user list but didn’t get a response, so I’ll rephrase it here. I’m the author of a Grails plugin (https://github.com/kensiprell/grails-atmosphere-meteor), which has two external dependencies defined in BuildConfig.groovy.
When the plugin is installed in a new Grails 2.2.x application, the external dependencies are not resolved in the app. When running it I get "unable to resolve class" errors on the import statements for the classes defined in the plugin’s dependencies.
A plugin user should be able to insert the plugin dependency in an app’s BuildConfig.groovy and have the two external dependencies resolved automatically. grails.project.dependency.resolution.legacyResolve should be the default value of false.
Additionally, I want to test the plugin using https://github.com/kensiprell/grails-plugin-test-script before publishing it to the Grails plugin portal. I have an artifactory repo running on localhost (defined as localPluginReleases in the plugin's BuildConfig.groovy).
The plugin is built using Grails 2.2.3 and uses release plugin version 2.2.1. I've tried varying combinations of the below without success:
grails clean
grails compile
grails maven-install
grails generate-pom
grails package-plugin
grails publish-plugin --noScm --repository=localPluginReleases
grails maven-deploy --repository=localPluginReleases
What is the correct step-by-step to get this working?
I am using grails 2.2.1, in windows.
I want to develop a plugin which depends on spring-security-core plugin, so I add dependency into BuildConfig.groovy of my plugin:
plugins {
compile ':spring-security-core:1.2.7.3'
}
Then in my grail application project, I specify the dependency in BuildConfig.groovy in:
grails.plugin.location."xxxxx" = "../grails-plugins/xxxx"
After that, when I try to refresh dependency of my grail application project, it always prompt
unable to resolve class org.springframework.security.authentication.UsernamePasswordAuthenticationToken
this class is a class depends on by spring-security-core plugin and my plugin use this class too.
Is it a grails bug? or I miss something? Please help, thanks in advance!
I tested here. In Grails 2.2.1 you need to set legacyResolve to true since
Grails 2.2 no longer uses the BuildConfig of the plugin for dependency
resolution and only uses data provided by POMs
When you set this and refresh dependencies the install messages of Spring Security Core will appear.
I've just switched to grails 2.2 and have got a major plugin problem. I've got an application - my-app and a plugin - my-plugin. I want to install spring-security-core plugin into my-plugin, and then install my-plugin into my-app. When I've done this and did s2-quickstart, so that LoginController got created. I can start my-plugin with no problems now, but when I try to start my-app it complains that it cannot find any springsecurity classes. Errors looks like this:
12: unable to resolve class org.springframework.security.web.WebAttributes # line 12, column 1.
7: unable to resolve class org.springframework.security.authentication.AccountExpiredException # line 7, column 1.
11: unable to resolve class org.springframework.security.core.context.SecurityContextHolder # line 11, column 1.
It looks to me, like only my-plugin can see spring security plugin dependencies, and my-app cannot, so they didn't cascade even thought according to manual they should have.
I've also tryed to install spring-security-core plugin by adding in BuildConfig.conf this:
compile ":spring-security-core:1.2.7.3"
but it didn't work either.
Any ideas?
If you use install-plugin in a plugin, it's only installed locally by adding a line in application.properties. It doesn't get exported as a dependency of your plugin. This could be used for plugins like code-coverage where you want to use it during development and testing but not force users to also install it.
In older versions of Grails the dependsOn map in the plugin descriptor was used to express plugin dependencies. This is now deprecated in favor of dependencies registered in the plugins secton of BuildConfig.groovy. This is both for consistency and to take advantage of the more fine-grained features supported by the dependency DSL including specifying scopes and exclusions. This is also true for applications - don't use install-plugin for either apps or plugins, always use BuildConfig.groovy.
Take a look at the spring-security-ldap plugin's BuildConfig.groovy. It has a compile-scope dependency on the core plugin, plus one for the hibernate plugin that's not exported (since it's just for testing) and a build-scope dependency on the release plugin (also not exported since it's just used to release the plugins).
You should probably using a similar dependency on the core plugin in your BuildConfig.groovy. Delete any plugin references in your application.properties and convert to BuildConfig.groovy syntax and run grails clean followed by grails compile.
Thank you Burt for your advice. I've used it and here's what I came to:
I created a plugin-app and installed spring-security-core plugin in it (using DataSource.groovy, and not install plugin). Then I created a main-app and installed my plugin-app (again using DataSource.groovy). When I did this in grails 2.1.1 everything worked just fine - I could use spring-security in my main-app, so the dependency got pulled just right. When I did everything the same, but in grails 2.2 I couldn't use spring-security in my main-app, so dependencies didn't get pulled. That's why I think this might be some kind of a bug in new grails version.
When creating a plugin that depends on other plugins, you specify these dependencies in the config of the plugin via the dependsOn map.
What I want to know is if these plugins are downloaded automatically when you run install-plugin command??
If not, how can it be set up to do so?
That's how it works in 1.2 and 1.3. In 2.0 however you'll want to configure dependencies in the plugins section of BuildConfig.groovy since dependsOn doesn't populate the pom file and that's what's used for dependency management in 2.0.
1.3 can also work with dependencies in BuildConfig.groovy, but 1.2 and earlier cannot. I think it's safe to assume that there aren't many users still on 1.2 or earlier, but if you need to support older versions you can just include instructions for them to explicitly install the required dependencies before installing your plugin.