Grails Plugins from GitHub - grails

If I want to use a plugin for Grails from Git Hub. Do I just download the zip file and make it available in my local maven repository? I'm behind a firewall which doesn't let me just resolve the dependencies.

You can get the source and run maven-install to make it available in your local maven repository, then you declare the dependency in the plugins block of the BuildConfig.groovy.

You shouldn't build from the repo source since that might include unfinished features and bugs. At the very least use source tagged for a particular release (if there are any).
If you want to download released plugins, they're available at http://repo.grails.org/grails/plugins/org/grails/plugins/
Keep in mind that running grails install-plugin /path/to/zip no longer works in 2.3, so you should stay away from that approach. Instead, you could run a local Artifactory instance that acts as a cached plugin repo - see this thread for some information to get started: http://grails.1312388.n4.nabble.com/Caching-plugins-using-artifactory-td4640164.html

The zip file which will be downloaded will be the source of the plugin. You have to extract the zip, go to the root of the plugin, and run grails maven-install (from release plugin) which would build the plugin artifact for you in you local maven repository if you have one setup.
Then you can use the plugin.
OR
You can use the plugin inline as mentioned in this answer.

Proxy setting can also be configured in grails by add proxy and set proxy.
grails add-proxy myproxy "--host=myproxy" "--port=myport" "--username=proxyuser" "--password=mypassword"
grails set-proxy myproxy
see grails docs.
if above solution doesn't work try then
create ProxySettings.groovy in C:\Documents and Settings\user-name.grails folder
add following two lines to this file and save
myproxy=["http.proxyHost":"myproxy", "http.proxyPort":"4300", "http.proxyUserName":"proxyuser", "http.proxyPassword":"mypassword"]
currentProxy="myproxy"
please check this link for more options

You can also keep plugins locally as described here
http://blog.armbruster-it.de/2011/10/project-setup-for-grails-with-customized-plugins-using-git-submodules/
git submodule add git://github.com/sarmbruster/grails-spring-security-ui.git plugins/grails-spring-security-ui
git add .gitmodules plugins/
git commit -m "added submodule"
now add plugins/grails-spring-security-ui as a inline plugin by adding to grails-app/conf/BuildConfig.groovy
grails.plugin.location.'spring-security-ui'="plugins/grails-spring-security-ui"
That's all.
More info in section "Installing Local Plugins" and "Specifying Plugin Locations" in docs:
http://grails.org/doc/latest/guide/plugins.html#12.1%20Creating%20and%20Installing%20Plug-ins

Related

Jenkins - load global pipeline library from filesystem instead of SCM?

I can't find anything in the docs on how to do this - anybody have any ideas?
It seems it is currently not possible. But you can easily init a local git repository and use it as SCM without any remote hostings.
To init a git repo use the following commands in the root directory of your shared library (for example C:\Users\Jenkins\pipeline-shared-library-test):
git init
git add .
git commit -m "init"
Then in Manage Jenkins->Configure System->Global Pipeline Libraries you can point Project Repository to you local repo using a file URI file:///c:/Users/Jenkins/pipeline-shared-library-test
This approach works fine for me.
You can use File System SCM plugin to load your library from file system.
Once you have installed this plugin, use "Legacy SCM" in your library configuration to set a path and choose "master" as default version. Can not use Load implicitly, so explicit configuration should be done in the pipeline.
As a reference, I read this approach in this slides https://www.slideshare.net/roidelapluie/jenkins-shared-libraries-workshop.

How to deploy grails app with private plugin to cloud

I've created a private plugin for domain objects that are shared between two grails applications. I'm able to use the plugin successfully in my local environment as I've set the path to it via the BuildConfig file. For example, I have the following directories:
appOne/
myPlugin/grails-my-plugin-0.1.zip (myPlugin is a grails plugin project dir)
In: appOne/grails-app/conf/BuildConfig.groovy:
grails.plugin.location.compileMyPlugin = "../myPlugin"
My question is, what is the proper/best way to handle "packaging" this plugin with my app release so I can deploy it to a cloud service where it won't be available for download? I imagine there is a way to have grails do this for you but I'm unsure. (I'm very new to grails)
When you create you .war file for deployment, grails simply includes your plugin. So you have nothing special to do.
If your project is build in the cloud, you might try to specify a file path as local repository:
repositories {
grailsCentral()
localRepo "../myPlugin"
}
Just drop your zipped plugin in this folder and grails will find it.
I ended up doing the following to resolve this in Grails 2.1.0:
1) In the Grails Plugin Project:
grails package-plugin Produces the grails-myplugin-0.1.zip file
2) Copy plugin to my application's lib directory (appOne/lib/grails-myplugin-0.1.zip)
3) In BuildConfig.groovy
Remove: grails.plugin.location.compilemyPlugin = "../myPlugin"
This was/is used during development to prevent the rebuild-reinstall process
when updating files included in the plugin.
Add:
plugins {..... compile ':grails-myPlugin:0.1' }
4) Test by cleaning appOne and re-run which will install/re-install the plugin via the lib directory
5) Commit all changes and add the plugin zip file to appOne and push. The cloud provider,
Heroku in this case, can then resolve the dependency.
Your build script should first package the plugin, then install the plugin into your Grails application. At least, that is how I have to do it. If you try and have both your plugin specified in the BuildConfig dependencies and as an inline plugin, Grails tends to complain about that.

How to run a local plugin in Grails 2.0?

In Grails, there is a variant how to include local plugin from sources. According to docs, one may type in BuildConfig.groovy:
// Useful to test plugins you are developing.
grails.plugin.location.shiro =
"/home/dilbert/dev/plugins/grails-shiro"
// Useful for modular applications where all plugins and
// applications are in the same directory.
grails.plugin.location.'grails-ui' = "../grails-grails-ui"
The problem is that it doesn't work in Grails 2.0.RC1. I've tried to do grails clean, to install plugin with grails install-plugin and to place it to BuildConfig.groovy. Still unable to resolve.
This works for me
grails.plugin.location.shiro = "/home/dilbert/dev/plugins/grails-shiro"
Where shiro is the name of the plugin (not the name of the directory it's in). Make sure the path to the plugin is either an absolute path or the relative path to the plugin from the application.
I've found that this sometimes doesn't work if the plugin is listed in application.properties or BuildConfig.groovy, so if it is, remove it, then execute grails clean and restart the app.
You can also install the plugin into your local maven cache.
The documentation speaks about this:
3.7.10 Deploying to a Maven Repository
maven-install
The maven-install command will install the Grails project or plugin artifact into your local Maven cache:
grails maven-install
This has the advantage of allowing you to include the plugin in your parent application using the more common ":plugin-name:version" syntax
Which allows your application to determine the best place to retrieve the plugin when in production. From an internal maven-repo or equivalent.
With Grails 3.x there is another way to do this. Suppose you've a grails app and plugin (source code) inside the same project directory:
/my-project
---/my-app
---/grails-shiro
To run your local plugin, you must create a settings.gradle file in the my-projectdirectory specifying the location of your application and plugin:
include 'my-app', 'grails-shiro'
Then add the dependency in your application's build.gradle:
compile project(':grails-shiro')
You've done.
Look at the plugins documentation for more information.
Surround the plugin name with quotes in case it contains dashes:
grails.plugin.location.'plugin-name-with-dashes' = "<path>"
You can add the .zip file for the plugin in your /lib and it will be installed.
Example:
compile ":myPlugin:1.0"
File:
/lib/myPlugin-1.0.zip
Note: You have to zip the content of the plugin folder.
Source: http://grails.1312388.n4.nabble.com/Insert-own-local-plugin-into-build-config-td4646704.html

Including Grails Plugin Source in Grails 1.3.5 project

I want to use a snapshot version of the grails quartz plugin. The issue is, I want to be able to specify the dependency or include the source of the plugin in my project so that my coworkers and our build server don't have to download the plugin's zip file themselves.
I was able to solve this by connecting to the plugin's repository through an svn:external, and then adding the following to my BuildConfig.groovy.
grails.plugin.location."quartz" = "path/to/svn/external"

Installing Nimble for Grails

I came across Nimble yesterday, but couldn't get past Step 1, configuring BuildConfig.groovy to find the Nimble's remote repository.
My BuildConfig.groovy file is one line:
grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/
Here is the message I get when running grails install-plugin nimble 0.2:
Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/dev/sdks/grails-1.1.1
Base Directory: /home/wraith/dev/source/demo
Running script /opt/dev/sdks/grails-1.1.1/scripts/InstallPlugin.groovy
Environment set to development
No authentication for svn repo at intient ...
Reading remote plugin list ...
Reading remote plugin list ...
Reading remote plugin list ...
Plugin 'nimble' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
This is the first time I have tried to install a plugin not in the official repository. What is the best way to narrow down if it is a problem at Intient.com or with my configuration?
Follow these instructions with the following modifications:
Step 1 is correct
Instead of using the remote repository, download the zipped plugin
Move the plugin to ~/dev/plugins
grails install-plugin ~/dev/plugins/grails-nimble-0.2.zip
Steps 3-5 are correct
We were performing some maintenance on intient.com and the load balancer wasn't providing this content for the last 12 hours or so (oops!).
Should be sorted now but the steps Wraith Monster gave above work for a manual install as well.
Once Grails 1.2 proper hits Nimble will be part of the official plugin repo and we won't need to worry about this at all.
you could always download the zip file for the plugin and install it manually
Download source code from http://github.com/intient/nimble
Unzip under your plugins directory of your project (usually under ${USER_HOME}/.grails/<grails-version>/projects/<myproject>/plugins)
Rename the extracted folder into "nimble-0.2"
Remove from BuildConfig the line grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/"
Edit the file application.properties of your project and add the line plugins.nimble=0.2
If not installed under your project, you should install the plugins : shiro (version 1.0-SNAPSHOT at least) and mail (>0.6). (run command grails install-plugin <pluginName> <version>)
Start directly from Step 3
It should work (at least, it worked for me). Good luck

Resources