Grails plugins repository is a hive of useful features, which help you extend your project’s functionality. For easier communication with the repository, IntelliJ IDEA provides a special tool that allows:
- Exploring the repository contents: viewing the latest versions of existing plugins, finding new plugins, reading plugins’ descriptions, sorting and filtering plugins.
- Installing or uninstalling plugins for your project, without memorizing command-line syntax, plugin names and versions.
- Adding plugins that reside outside the Grails plugins repository.
So, let’s see the Grails plugins manager in action.
- You are working with IntelliJ IDEA Ultimate edition, version 9 or higher. See the latest available version
- You are working with a Grails module of your IDEA project (see Getting Started with Grails)
- Grails SDK is installed on your machine. You can download and install Grails SDK from this page
Accessing the Grails plugins manager
The tool for managing the Grails plugins is implemented in the form of Grails plugins dialog box. To open it, just press Ctrl+ Alt+ K, or choose Grails→ Pluginson the Tools menu.
Exploring the repository contents
If you have just installed Grails, and you are now opening the Grails plugins dialog for the very first time, the list will be empty. To show the plugins that currently exist in the repository, click the reload button . This runs the grails list-plugins target. Later, reload the list of plugins from time to time, to keep it up to date.
All the plugins available in the Grails repository are listed in the console; at the same moment, the list of plugins is updated in the Grails plugins dialog box:
For each plugin in the list, the Grails plugins dialog shows its name, status in project, version, and title in the Grails plugins table, and, optionally, description and vendor information. You can sort the list by any of the columns, or filter out the necessary plugins by typing in the search field some characters contained in the plugin name, title, or description.
Installing and unistalling plugins for Gradle version 2.3.0 and later
The list of plugins is available in Grails plugin repository.
- In your project, open BuildConfig.groovy file.
- In the Editor, in the grails.project.dependency.resolution.plugins section of the code, enter compile ":pluginName:pluginVersion" command for the plugin you want to install.
If your plugin resides in a separate repository, you need to enter the repsository as well. (For example, in our case, it is mavenRepo http://maven.alfresco.com/nexus/content/groups/public/.)
- To remove the plugin, simply delete the specified line.
Installing and uninstalling plugins
Look at the Enabled column in the Grails plugins table. The check boxes in this column denote plugin statuses in the project:
- The check boxes are cleared for the plugins that exist in the Grails repository, but are not installed in your project.
- The check boxes are selected for the plugins that are already installed for your project.
If you want to change the status of a plugin - install or uninstall it- select or clear the check box next to its name. The names of plugins with the modified status are color-coded: the ones to be installed are green; the ones to be deleted are violet.
When you click Apply changes, IntelliJ IDEA asks you to confirm your choice. For the plugins to be installed, you can also select the desired version:
When you click OK, IntelliJ IDEA executes the grails install-plugin and grails uninstall-plugin targets for the selected plugins. For each of the installed plugins, IntelliJ IDEA produces special directory structure in the module named <your application>-grailsPlugins
You can see it in the Project tool window:
If you want to install a local plugin, click the Add custom plugin button on the toolbar of the Grails plugins dialog, and find the packaged archive you need:
Apply the changes and install the plugin the way you’ve done that for the repository plugins. Now, you can check that the new plugin has really been installed: see the record added to the metadata file of your Grails application: