What are inline plugins? - grails

What is an inline plugin in Grails 2.X? How to make a plugin inline? I can find the documentation for Grails 3 but not for Grails 2.

Inline plugins in Grails 2.x are outlined in the documentation section for plugins.
From the documentation:
An application can load plugins from anywhere on the file system, even
if they have not been installed. Specify the location of the
(unpacked) plugin in the application's
grails-app/conf/BuildConfig.groovy file
Creating an inline plugin is done using the grails create-plugin command, just like a non-inline plugin.
The only real difference between an inline-plugin and regular plugin is how it is referenced by your application. A normal plugin is pulled from a repository (such as maven) while an inline-plugin exists in source format local to the application that is using it. Take for example:
/usr/foo/grails/MyApplication
/usr/foo/grails/MyInlinePlugin
/usr/foo/grails/MyOtherInlinePlugin
The above application (MyApplication) can include the two plugins listed as inline plugins by using the following in the BuildConfig.groovy
// BuildConfig.groovy
grails.plugin.location.'my-inline-plugin' = "../MyInlinePlugin"
grails.plugin.location.'my-other-inline-plugin' = "../MyOtherInlinePlugin"
Overall inline plugins are useful when developing (or testing) a plugin as well as creating modular Grails applications.

You can find the documentation in this URL: Grails Documentation
Go to the section: User guide for older versions
And select your version of Grails.
Here you can find, for example, the documentation of Grails 2.5.0: Grails Documentation 2.5.0
The inline plugins can help you to debug an application or change the code of your plugins to do your tests, instead of apply the changes in the plugin and when it's released, test if it's OK. It's very useful to change different plugins in the same time.
Hope this helps!

Related

Adding in-place plugin to grails 3 project

In grails 2.x, we were allowed to add an in place plugin by adding following in BuildConfig.groovy
grails.plugin.location."my-plugin" = "../my-plugin"
My question is, can we add our local plugins similarly in-place in grails3.0 as well or there is some other way to do this in grails.
Actual purpose is to test the plugin whether it's working properly or not before pushing it to bintray.
Yes, there is. Grails 3 is based on Gradle so multi-project gradle builds solve your issue.
Basically you add dependency as:
compile project(':../my-custom-plugin')
and has to modify settings.gradle to include plugin:
include '../my-custom-plugin'
Check Grails documentation on Plugins and Multi-Project Builds in http://grails.github.io/grails-doc/latest/guide/plugins.html
Other way is to install plugin in local maven repository using gradle publishToMavenLocal command and resolve if from there, before publishing to Bintray or other dependency repository.
Additionally since Grails 3.1.1, reloading is now supported for 'inline' plugins. Check https://github.com/grails/grails-core/releases/tag/v3.1.1 and http://grails.io/post/138665751278/grails-3-gradle-multi-project-builds
It is done using grails { plugins { syntax. Copied from docs:
grails {
plugins {
compile ":hibernate"
compile project(':myplugin')
}
}
This multi-project thing is a bit too big to answer in a short post. I just recently started with it, but, thankfully, I now have the hang of it. There's a tutorial on my site with a plugin handling the domain classes and services and all other sub-projects (just one, a web application in this example) using the plugin. The code is also downloadable. Here's the link: http://www.databaseapplications.com.au/grails-multi-app.jsp Make no mistake, there are a few things to watch out for.

How do I configure installation of plugins in Grails 3.0.4?

I'm porting an application from Grails 2.4.2 to Grails 3.0.4, and I'm having problems with some plugins that were installed previously. Specifically one that is referenced in a GSP page. The particular plugin is called google-visualizer, and I've found some info here:
https://github.com/bmuschko/grails-google-visualization/blob/master/grails-app/views/formatter/index.gsp
However, I am clueless as to how to install this. I have not found the particular jar file in any maven repo, so I can't add it as a Gradle dependency. In general, where is it documented how to install existing plugins in Grails 3.X? I've read the documentation on how to port existing plugins, but that's not what I'm trying to do. I simply want to tell Grails/Gradle that I'd like to use this particular plugin and have it resolve the dependencies for me. I've tried this syntax as shown here:
https://grails.org/plugins/tag/grails3
Example:
compile ":quartz:1.0.2"
I've put that line in the dependencies block in my build.gradle file, but it doesn't work. I get errors from Gradle. Is there a particular Maven repo that has to be added for plugins? Any help with this is appreciated. Thanks.
Grails 1.x and 2.x plugins are sadly not compatible with Grails 3.x.
You can find the plugins that already have been ported to Grails 3 at: https://bintray.com/grails/plugins/
The grails-google-visualization plugin is not released in a Grails 3 version, but from the repo, it appears that work has started on upgrading.
You can see the progress on a Grails 3 version in this issue: https://github.com/bmuschko/grails-google-visualization/issues/49
Benjamin searched for a new maintainer back some time ago, and found a volunteer - see this tread for details: https://twitter.com/bmuschko/status/498610606896066560
For those plugins that are most important, the Grails Core team maintains a list here: https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins
Some of the old plugins will be replaced by their Gradle counterpart, fx. the codenarc plugin, that exist in a Gradle version already.
A simple way is to find out the JAR file for the plugin and then use them in Grails 3.0.4. In this way there is no need to change the source code of the plugin

Grails/GGTS 2.4.2 not putting plugins on classpath?

I am trying to update an older 1.3 Grails project to the latest Grails/Groovy/etc. So I downloaded Grails 2.4.2, Groovy 2.3, and Java 1.7.0_65. Then I imported the project via Import->Grails. I found out that plugins are now configured via the BuildConfig.groovy file, so I edited that with the plugins section and ran Grails Tools -> Update Dependencies. None of my plugins appear on the classpath? However, if I startup the plugin manager (which I'm not fully clear on why it is in the product as it states it won't do much after version 2.3...), it does list:
Plug-ins you currently have installed are listed below:
-------------------------------------------------------------
mail 1.0.6 -- Provides Mail support to a
running Grails application
routing 1.2.0 -- Routing capabilities using
Apache Camel
routing-jms 1.2.0 -- JMS integration for the
grails-routing plugin
shiro 1.2.1 -- Apache Shiro Integration for Grails
So SOME part of Grails seems to know about the plugins. Also, if I delete the plugins from my $HOME/.grails/projects/myProject/plugins directory and re-run the Grails Tools -> refresh dependencies, I get both text on the console saying they are being installed and they come back to that directory.
The ONLY thing that seems abnormal, is that during the second set of files compiled (my project files) there ARE compile errors. I expected these (for instances of grailsApplication / etc). To fix them, I wanted to use GGTS - however, there are SO many compile errors in there from the plugins not being on the classpath it is not very feasible.
If anyone has ideas or suggestions for me to try that would be greatly appreciated!
I think it's a problem with GGTS not knowing what your grails work directory is.
You can check you .project file to see if the .link_to_grails_plugins resource is defined correctly.
GGTS may have created the .project like this
<linkedResources>
<link>
<name>.link_to_grails_plugins</name>
<type>2</type>
<locationURI>GRAILS_ROOT/projects/myProject/plugins</locationURI>
</link>
</linkedResources>
GRAILS_ROOT is a variable defined in your GGTS Preferences under General -> Workspace -> Linked Resources
You might have to add the variable if it's not there.
Set the value to the absolute path for $HOME/.grails and then try to refresh your dependencies.

How do I create a Grails skeleton project for plugin development?

I am working with a (sort of) framework built on top of Grails. This framework is a set of Grails plugins that add functionality to the Grails app (e.g. user authentication). This framework is a bit of a pain to setup, as it requires around 64 lines of site specific configuration in the apps's Config.groovy file.
I want to develop my addons to this app as plugins. That is, the Grails app would really just be a set of installed plugins and some configuration files.
I have created a local Maven style repository to hold all of my plugins. Thus, I can add plugin dependencies to the BuildConfig.groovy file and they will be installed automatically (side question: is it possible to specify the install order?).
So my question is, how do I create skeleton project for developing my plugins that would:
Include the base configuration for my application (the aforementioned 64 lines)
Allow me to do a grails package-plugin to package only the plugin's code
You can use the post-installation hooks mechanism: http://grails.org/doc/latest/guide/plugins.html#hookingIntoBuildEvents
Not really an ideal setup for me, but the following works:
Create the "base" application: cd ~/GrailsDev/ && grails create-app my-app
Configure my-app as desired/required
Create your dependent plugin: cd ~/GrailsDev/ && grails create-plugin my-app-plugin
Add the new plugin to the app by editing "~/GrailsDev/my-app/grails-app/conf/BuildConfig.groovy" and appending the line: grails.plugin.location.'my-app-plugin' = "../my-app-plugin"
You can now run the my-app Grails application and the plugin will be included. When your plugin is fully developed, you can do grails package-plugin from within the "~/GrailsDev/my-app-plugin" directory to package your plugin.
use gradle. you can specify the order and package your plugin alone.
e.g. include the required plugins as git modules (for easy versioning) and gradle modules (for building your plugin) in your plugin project.
this setup will serve your requirements well I suppose.
https://github.com/grails/grails-gradle-plugin
IntelliJ does have a template for gradle-backed grails applications and plugins.

How can I easily link sources for dependencies in Grails project in IntelliJ IDEA?

Is there any way to get IDEA to automatically download sources for Grails, my plugins and all the dependencies? Alternately, is there an easy way to get IDEA to pickup sources downloaded by this plugin?
http://www.grails.org/plugin/eclipse-scripts
It puts them under ~/.ivy2/...
IDEA should automatically load all plugins for a Grails project, if the Grails/Griffon plugin is being used.
I see all the Grails plugins for a given project in my Grails View, under Plugins.
If you aren't seeing the files, try right-clicking on the project's name in the Grails View, and choosing Grails > Synchronize Grails settings.
Please note that if you are using the free (community) version of IntelliJ IDEA, it does not include the necessary plugins for working with Grails directly. You must pay for the full version to get it.

Resources