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

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.

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.

Where are Grails 2.4.2 installed plugin files?

I installed Spring Security Core plugin for my Grails project and it works just fine. The problem is that I can't locate the actual plugin files. I can't find any of my projects inside .grails/2.4.2/projects where according to my understanding Grails is suppose to store all the plugins. The directors exists but there are no projects in this folder.If I want to edit grails.plugin.springsecurity.LoginController where do I go to find this controller? I am on OS X 10.9.3
By default the plugins are in .grails/<version>/<project>/plugins. You can change it by setting grails.project.plugins.dir (setting it to 'plugins' will create a plugins folder in your project source directory) in BuildConfig.groovy.
then copy the LoginController to your own source tree (to the same location) to override and edit the plugin version.
Just in case someone else runs into this.
In 2.4.4 you would put the theme into
/<project>/target/work/plugins/jquery-ui-<version>/web-app/jquery-ui/themes/<themename>/

What is the .link_to_grails_plugins folder used for?

Background: I'm just learning Groovy and Grails. I inherited a project from someone who has disavowed themselves of it completely, so I'm basically just thumbing around blindly. I am using the Springsource IDE.
My source had a number of plugin dependencies. I attempted to install these via the plugin manager but one plugin (image-tools) was not available through that medium and needed to be installed separately. I've been unable to install it or the others, as I always end up with build errors which apparently reverts the partial plugin install. While search for references to the image-tools plugin which I could comment out in an attempt to get SOMETHING compiling correctly, I found the .link_to_grails_plugins directory, which seemed to contain the source of all the necessary grails plugins.
Adding this to my classpath and rebuilding seemed to let me make some progress, but I'm not sure if that's what I should actually be doing. Can someone explain to me what this folder is used for? Google hasn't been particularly helpful.
.link_to_grails_plugins is not a standard Grails directory - it has been created by the STS IDE.
The Grails plugins are cached in the grails.project.plugins.dir and grails.global.plugins.dir as described in the documentation for Customizing the Build:
The image-tools plugin documentation indicates that it must be built from the source and provides the instructions for doing so.

Resources