Cannot install Grails plugin with Eclipse (Grails 2.3.1) - grails

i have Grails 2.3.1.
when i try to install new plugins , i have the following console message :
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
...
plugins {
compile ":console:1.2"
}
}

Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Instead of using install-plugin (or an IDE feature like you're using that runs install-plugin for you), add a dependency in the plugins section in BuildConfig.groovy:
plugins {
compile ":console:1.2"
}
install-plugin adds entries in application.properties but that approach isn't configurable enough, so we deprecated install-plugin in 2.2 and removed it in 2.3. As you can see, when you run the script, it does nothing but does give you the code that you need to add yourself.

Related

How to install grails db-reverse-engineer

Trying to use the Grails db-reverse-engineer plugin. As this plugin doesn't work with Grails 3 I used SDKMAN to install older versions of Grails just to generate the models. First tried version 2.5.2 (which was still incompatible with the tutorial) and then spun back to 2.2.5. Following the tutorial still fails to install the plugin:
$grails create-app reveng-test
| Created Grails Application at /home/user/pnvStuff/grails/reveng-test
$ cd reveng-test
$ grails install-plugin db-reverse-engineer
| Environment set to development.....
| Warning The install-plugin command is deprecated and may be removed from a future version of Grails. Plugin dependencies should be expressed in grails-app/conf/BuildConfig.groovy. See http://grails.org/doc/2.2.x/guide/conf.html#pluginDependencies.
| Error resolving plugin [name:db-reverse-engineer, group:org.grails.plugins, version:latest.integration]. Plugin not found.
| Error Plugin not found for name [db-reverse-engineer] and version [not specified]
I also tried installing the plugin by referencing it in the plugins section of the BuildConfig.groovy.
runtime ':db-reverse-engineer:0.5.1'
How can I get this plugin installed to generate the needed domain classes?
Grails 2.x (and 1.x for that matter) plugins are now in a repository that isn't included in BuildConfig.groovy by default. You need to add the below Maven repo to your dependency resolution block.
grails.project.dependency.resolution = {
repositories {
mavenRepo "http://repo.grails.org/grails/repo/"
...

Creating and installing a grails plugin - how does my plugin access resources from a plugin its dependent upon during/after install?

This question is an extension from another question I posted here:
In Grails 2, how do you includeTargets from Gant scripts from a plugin your app is dependent upon?
I am writing a grails plugin that is a my-company specific version of the shiro plugin, ex. my-company-shiro. I set shiro as a dependency for my plugin in the BuildConfig.groovy like so:
plugins {compile(":shiro:1.1.4")}
I package the plugin and try to install it to a new grails app called foo:
foo> grails install-plugin ../my-company-shiro/grails-my-company-shiro-01.zip
No problems.
Now, I want to run a script in foo that is part of my-company-shiro which in turn references a script from the shiro plugin:
foo>grails create-auth-controller
I get the following failure:
Error Error executing script CreateAuthController: No such property: shiroPluginDir for class: .....
This occurrs b/c one of my scripts being executed tries to access one of shiro's scripts like so:
includeTargets << new File (shiroPluginDir, "/scripts/_ShiroInternal.groovy")
This reference works when I compile my plugin, but not here when I am installing it in another grails app.
Am I setting the dependency incorrectly in the BuildConfig.groovy such that shiro's files are not being included in my plugin therefor I cannot reference it?
The shiro plugin shows up in my .grails cache my-compnay-shiro/plugins/shiro-1.1.4
When I install my-company-shiro plugin to foo, in the .grails cache foo/plugins/my-company-shiro-0.1/dependencies.groovy and plugin.xml files reference shiro. I do not see any of shiro's scripts or files here, but I have no idea if they are supposed to be copied here.
Is the reference to shiroPlugin incorrect at install time?
Thanks in advance!
grails install-plugin is deprecated, you need to use BuildConfig.groovy instead. I tested here, declaring the custom plugin inside the app and it works, you can use grails.plugin.location to specify the folder of your plugin.
Considering a plugin named shiro-test, the BuildConfig should be:
grails.project.dependency.resolution = {
...
legacyResolve true // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
...
}
grails.plugin.location."shiro-test" = "path/to/plugin"
Then you refresh your dependencies and can run any script from shiro-test.

I can't install spring-security-core plugin in Grails

I have windows 7 and Grails-2.0.4. Trying to install plugin spring-security-core. I've tried from everywhere: cmd, Idea, SPS. Nothing works. Everywhere the same error:
!Error resolving plugin [name: spring-security-core, group: org.grails.plugins, version: latest.integration(1.2.7.3 in SPS)]. Plugin not found.
!Error Plugin not found for name [spring-security-core] and version[not specified(1.2.7.3 in SPS)]
I tried to put the zip-file of this plugin in different directories. Doesn't work. With connection everything is OK. Help me please.
Check the repositories section of your BuildConfig dependencies, and add the following if it is not already there:
grailsRepo "http://grails.org/plugins"
The grails plugin repository moved earlier this year and the old repository does not contain any plugin versions released since April 2012. I don't remember exactly which versions of Grails will use the new repository by default, the change happened somewhere around 2.0.3/4.
The preferred way to install it is to add a dependency in BuildConfig.groovy. The syntax for this is listed for each plugin, in this case from http://grails.org/plugin/spring-security-core: compile":spring-security-core:1.2.7.3"(look for the 'Dependency' section at the top). So theplugins` section of your BuildConfig.groovy should look like this:
plugins {
runtime ":hibernate:$grailsVersion"
build ":tomcat:$grailsVersion"
...
compile ":spring-security-core:1.2.7.3"
}
Alternatively you can install it with the install-plugin script:
$ grails install-plugin spring-security-core
but the dependency approach is the better way.

publishing Grails plugins

I'm trying to follow the new process for publishing Grails plugins. I've installed the latest version of the release plugin by adding the following to BuildConfig.groovy
plugins {
build(":tomcat:$grailsVersion", ":release:1.0.1") {
export = false
}
}
But when I try and execute the publish-plugin script, it tells me no such command exists:
c:\workspace\grails-flash-helper>grails publish-plugin
| Script 'PublishPlugin' not found, did you mean:
1) ListPlugins_
2) ListPluginUpdates
3) PluginInfo_
4) InstallPlugin
5) UninstallPlugin
The source code of the plugin is here, in case anyone wants to take a look.
That simply means the plugin hasn't been installed yet. Run grails compile or grails refresh-dependencies first.
BTW, to follow the new mechanism for publishing plugins, you need to use version 2.0.0.BUILD-SNAPSHOT (or 2.0.0 when that's released) of the Release plugin. Version 1.0.1 won't work.

install plugins manually?

is it possible to install and uninstall plugins manually in grails??
if yes, how can it be done?
If the commands are failing for some reason, you can remove them by:
delete the entry for the plugin from application.properties
delete the plugin folder from ~/.grails/grails version/projects/project name/plugins
(Grails 2.2.4) To add a plugin that exists for example in your grails-project-dir\lib\the-grails-plugin-0.1.zip directory. Edit your grails-project-dir\grails-app\BuildConfig.groovy to include the following
plugins {
// ....
compile "lib:the-grails-plugin:0.1"
}
This will update your ivy-cache with folder called lib\the-grails-plugin
e.g: [user-home]\.grails\ivy-cache\lib\the-grails-plugin
For Grails 2.x, that's what the
grails install-plugin <plugin>
and
grails uninstall-plugin <plugin>
commands are for. See the command line reference at http://www.grails.org/doc/latest/.
Well, I know this is an old question, but it's probably a good idea to say here that since Grails 2.0, the best way to install a plugin is to update BuildConfig.groovy, adding it in the plugins section:
plugins {
// ....
compile ":console:1.2"
}
The scripts for installing/uninstalling plugins are deprecated and will likely be removed because they have issues regarding scopes and transitive dependencies.
If you want to install a plugin that is not in the central repositories, you can install the plugin in your Maven cache with grails install and then you'll be able to use it in your applications the same way.

Resources