What is the .link_to_grails_plugins folder used for? - grails

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.

Related

Errors in Eclipse (Spring Tool Suite) in Spring Security

I'm attempting to become a contributor for Spring Security, it's not going so well. I am getting validation errors in Spring Tool Suite although the build/compilation of the .gradle project is succeeding. The errors show up in the "Markers" view in Eclipse. Here is what I've done so far.
Forked the Spring Security master branch on Github
Copied the https URL for my forked branch
In Spring Tool Suite, Import->Git->Projects from Git->Clone URI
After #3 Spring Tool Suite downloaded the project from Git
Spring Tool Suite prompted asking me what type of project to create
I selected "Import as a general project"
I deleted the project from my workspace (but did not delete it on disk)
I imported the project using Import->Gradle->Gradle project and the recommended settings
After everything finishes building, I get the following error in Spring Tool Suite:
The error is accompanied by several messages including the following:
Pointcut cannot be resolved to a type
The method aspectOf() is undefined for the type ...
The method proceed() is undefined for the type ...
This error can be fixed (with an ugly hack) if I open the Eclipse .project file and add the following:
<buildSpec>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
</natures>
Question
How can I properly set up my development environment? What should I look into for figuring out why I'm getting these errors? I'm currently researching how the gradle/maven configurations relate to the Eclipse .project file, but I have not gotten very far yet.
Here is what works for me (and what I discussed with Rob Winch):
download STS 3.7.2 (not the latest 3.7.3, it has a few issues when importing spring-security projects) from https://spring.io/tools/sts/all. There is a link to previous versions of STS. There you find STS 3.7.2.
install Groovy-Eclipse into that from here: http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/
install the Gradle STS tooling from here:
http://download.springsource.com/release/TOOLS/update/3.7.2.RELEASE/e4.5
after installing all the components mentioned above, import the spring-security projects using the STS Gradle support ("Import -> Gradle -> ...")
it might take a while, but after downloading the necessary artifacts, all those projects should appear in your workspace. The "aspects" one has an error marker on it. Right-click on the project, go to the Groovy context menu entry, and do the "remove Groovy nature" (or something like that). That removes the groovy tooling for that project and it compiles fine.
After all those steps, I get a workspace with all those projects compiling fine. But it looks like we could/should simplify this procedure in the future using an Eclipse Oomph setup file maybe. But that is a story for the future.
Hope this helps!!!
I found this walkthrough on how to bring spring projects into eclipse via gradle. It actually looks like it was based on Spring Security which might create a nice process flow for you.
My guess is, eclipse is not defaulting to use the gradle configuration for its dependency management.

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 to generate zip file for a grails plugin

I wrote a Grails plugin, lets say PluginA which has dependency on another plugin, lets say PluginB, which I wrote myself too, these both plugins are being used by a main project. I am trying to build a continious integration system for this project using jenkins, so far I managed to setup everything in Jenkins. But while building the project, I get this error
Zip C:\Users\me\project\PluginA\grails-PluginA-0.1.zip is not a valid plugin
So, how do I generate that zip file, I noticed that all my other plugins have that zip file but I don't remember building them. I also tried to do a grails compile-plugin but I got an error saying that few classes were not found as they were in PluginB. So, how can I specify that PluginA has dependency on PluginB while running a grails command?
It's not entirely clear, but I believe the problem you are having occurs when trying to build the main project and not the plugins, so I will address that situation.
Since the error message mentions a zip file, I will also assume you are using Grails 2.x. If you are using Grails 3.x, then stop reading now and add info on how you are specifying your dependencies.
Key info: In my experience plugins don't come with their dependencies; I've had to re-declare them in my top-level projects. I have no idea if that is the intent of the grails plugin design, but I have found it works to do so.
Step 1: Build PluginB and install it to your local maven repo using
grails maven-install
Step 2: Specify PluginB as a dependency for PluginA in its app/conf/BuildConfig.groovy
Step 3: Build PluginA and install it to your local maven repo using the same command as for PluginB.
Step 4: In your main project, specify dependencies on BOTH PluginA and PluginB in app/conf/BuildConfig.groovy
Step 4 is the key.
If I've misinterpreted your problem, sorry about that! Please provide some more detail on exactly which part is failing and I'll let you know if I have any info on it.

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

ThymeLeaf with Grails 2.4

Is it possible to use ThymeLeaf with Grails 2.4?
There is a plugin that was started (https://grails.org/plugins/pending/250), but it doesn't appear to be active anymore and it noted some significant issues.
I've done quite a bit of searching and haven't been able to find anything on this subject other than the abandoned plugin... maybe I should take that as a sign.
Try it out and see. Clone the repo, then edit ThymeleafGrailsPlugin.groovy and change the version to a -SNAPSHOT version:
def version = "0.1-SNAPSHOT"
Then run grails compile and grails maven-install. That second script will build the plugin and copy it to your local Maven cache in the same format as if it were retrieved as a published plugin.
To use it in a project, add it like any released plugin, e.g.
compile ':thymeleaf:0.1-SNAPSHOT'
and it will resolve from your Maven cache.
To make changes, leave the version but run clean and maven-install again, but delete the plugin directory in the cache. That'll be something like $HOME/.m2/repository/org/grails/plugins/thymeleaf/0.1-SNAPSHOT - delete the whole directory, and after rebuilding the new version will be used.
David's email is in ThymeleafGrailsPlugin.groovy if you get stuck. It's easy to miss comments in the plugin proposal pages, so don't take a lack of a reply there as an indication that the plugin is totally abandoned.

Resources