I'm not sure how to ask this question, but I'll try anyway. I found different people having some kind of similar problem. But none with the exact same issue.
I have a grails 2.3.x application, it uses a customized version of a plugin. I'm use to old versions of Grails (pre-Maven dependency resolution), when we were able to include the customized version of the plugin into the /lib folder. I'm doing the same thing, but I am not able to solve anything. :(
Is there a way to tell grails, that lib directory (or some other, into the project folder) have the plugin zip file on it as we were use to?
UPDATE
Just to clarify. I want the packaged plugin into the project directory, not the source code.
UPDATE 2
Try to add the packaged plugin into plugins folder inside project root without any luck. While BuildConfig.groovy have the dependency declared or not.
Not sure if I have understood your question correctly. It seems you want to use a customized version of a plugin in your grails-app. You can do so by creating a "custom-plugins" folder in the root of the application and placing the custom version of the plugin inside this folder. Then in the BuildConfig we can specify the plugin location at the beginning of the file like this:
Assuming I have
myGrailsApp/custom-plugins/custom-plugin-1
grails.plugin.location."custom-plugin-1"="custom-plugins/custom-plugin-1"
That is it.
If you package the plugin as a .zip file and put it in a plugins directory in the root of your application, it will be loaded from there. You might also need to remove the plugin dependency declaration from BuildConfig.groovy before this will work.
Related
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>/
In recent versions of Grails install-plugin command has been deprecated. What is now the recommended way of installing a plugin that is not available via some repository. Assume the plugin is only available locally as zip file, e.g. after running grails package-plugin?
I think the easiest approach is to place the zip file in the project's lib folder and then add an entry in the BuildConfig.groovy. For example:
1. 'grails-image-tools-1.0.5.zip' placed in lib.
2. runtime ":grails-image-tools:1.0.5" added to BuildConfig.groovy
Since the dependency manager looks inside the project's lib folder as well, I don't have to worry about setting any paths etc.
EDIT:
The latest Grails version that I worked on was 2.1.1. I'm unable to check but according to #Saurabh's comment below this isn't applicable for Grails 2.4.3
EDIT2:
But #Jay says that it works with 2.4.5
I don't know if it is the correct way but we get it working:
Download and unzip the plugin in a directory within your project
Change your BuildConfig.groovy file to point to the new plugin
Example: Download webflow.zip plugin and unzip it into a plugins directory within your project. Add this line at end of your BuildConfig file
grails.plugin.location."webflow" = "plugins/webflow"
I have an app in Grails that uses a .java to manage paypal MassPay feature. Like many .java, it needs some jars that enclose the classes that jar uses. Ok, i import that jars and the errors in the .java dissapears. But now, when I try to run the app, i receive 25 messages like this:
myapproute/grails-app/controllers/com/mycompany/widget/MassPay.java:3: package com.paypal.sdk.profiles does not exist
import com.paypal.sdk.profiles.APIProfile;
That file in the MassPay.java does not throw any error, since i imported the jar where that class is enclosed. But it doesn't allow me to run the project.
Any help? thanks.
Im using Eclipse, not NetBeans (i have read that there is a bug in Netbeans)
Adding JARs to the Eclipse project build path is not sufficient to make them visible to Grails. You need to either put them in the application's lib directory and run grails compile --refresh-dependencies or (better) if the JARs are available in a Maven-compatible repository simply declare your dependencies in BuildConfig.groovy and let Grails download the JARs itself.
Run this - it will work
grails clean
I recently upgraded a project to Grails 1.3.5. This deleted everything in the /lib dir, though the project continues to work, so I guess the way dependencies are specified (and the location they're stored) has changed. I want to remove some libs that I'm no longer using, but can't do this until I find where the dependencies are specified.
Thanks,
Don
I'm surprised that anything was deleted from your lib directory - that shouldn't happen.
Dependencies are registered in BuildConfig.groovy in your app and in the plugins that work with Grails 1.2 and above. Older plugins will continue to have jars in their lib directories which will be added to the classpath, and you can still do the same. Obviously it's best to use the dependency management if possible so you have just the one copy of the jar in your Ivy cache instead of one for every project on your machine.
You can run grails dependency-report to generate Ivy reports to see what's managed by Ivy in each environment. These will end up in target/dependency-report and there's no index file, so just open any of the .html files and you can navigate to the others from there, e.g. target/dependency-report/org.grails.internal-{appname}-runtime.html.
I started a grails application by grails create-app. For modularity, I feel like it would be better that component be a plugin. Can I convert this application into a grails plugin?
thanks,
Babu.
I never created a plugin based on an application written before but looking at the documentation for grails plugins you can read the following statement:
The structure of a Grails plugin is exactly the same as a regular Grails project's directory structure, except that in the root of the plugin directory you will find a plugin Groovy file called the "plugin descriptor".
So I would suggest to create a new plugin with grails create-plugin *your-plugin-name* and copy all files from your application into the plugin.
In case anyone else is looking, this should be exactly what you need: http://burtbeckwith.com/blog/?p=1973
Excerpt:
So to convert an application to a plugin, the general workflow would
be something like
Create the plugin descriptor, FooGrailsPlugin.groovy. The easiest way to do this is to rungrails create-plugin pluginname and copy the
generated file from there
delete everything from application.properties except the app.grails.version property
if you have jars in the lib directory that are available in a Maven repo, delete them and replace with BuildConfig.groovy dependencies
change any plugin and jar dependencies that are needed for development and testing but not when the plugin is installed to not be
exported, by adding export = false
If you need the _Install.groovy, _Uninstall.groovy, or _Upgrade.groovy scripts (you probably don’t) grab those from the dummy plugin from step 1 (but delete any you don’t need, they’re all
optional)
delete ApplicationResources.groovy if you aren’t using it and don’t depend on resources plugin
move code from BootStrap.groovy init() toFooGrailsPlugin.doWithApplicationContext
and/orFooGrailsPlugin.doWithDynamicMethods and destroy() to
FooGrailsPlugin.onShutdown, and delete BootStrap.groovy
add a dependency for the release plugin in BuildConfig.groovy
delete everything but the log4j configuration from Config.groovy
delete UrlMappings.groovy unless you have exported mappings; only keep the added ones
move bean definitions from resources.groovy to FooGrailsPlugin.doWithSpring and delete resources.groovy
delete grails-app/i18n message bundle files unless you added messages; only keep the added ones
delete everything from grails-app/views that you don’t use (in particular error.gsp,index.gsp, and layouts/main.gsp)
delete everything from web-app that you don’t use (including WEB-INF xml and tld files)
now would be a great time to write those tests you’ve been meaning to get to
create one or more test applications to install the plugin into to ensure that it works as a plugin; consider scripting this
write documentation for how to use the plugin; at a minimum a README file, but Grails gdoc files would be much better (run grails doc
--init to get started)