Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources doesn't play nicely with jquery plugin configs #7

Open
felipero opened this issue Sep 29, 2011 · 2 comments
Open

Resources doesn't play nicely with jquery plugin configs #7

felipero opened this issue Sep 29, 2011 · 2 comments

Comments

@felipero
Copy link

I was trying to use resources plugin with the latest version of JQuery.

On the plain JQuery plugin I could do that:

jquery {
sources = 'jquery' // Holds the value where to store jQuery-js files /web-app/js/
version = '1.6.4' // The jQuery version in use
}

And the JQuery tag would know how to find that in my own /js/jquery/ directory.
<g:javascript library="jquery" />

I don't want to update the plugin jquery version on the plugin directory, but the resources plugin can't find the .js on my dir. It keeps giving me this exception:

java.lang.IllegalArgumentException: Module [jquery] depends on resource [/plugins/jquery-1.6.1.1/js/jquery/jquery-1.6.4.min.js] but the file cannot be found

I tried to find where to fix that so I could provide a pull request or something like that, but I couldn't. so far. Any help where to find that or maybe you guys could fix that either. :)

Thanks by the way for the great plugin.

@marcpalmer
Copy link
Contributor

On 29 Sep 2011, at 01:21, Felipe Rodrigues de Almeida wrote:

I was trying to use resources plugin with the latest version of JQuery.

On the plain JQuery plugin I could do that:

jquery {
sources = 'jquery' // Holds the value where to store jQuery-js files /web-app/js/
version = '1.6.4' // The jQuery version in use
}

And the JQuery tag would know how to find that in my own /js/jquery/ directory.
<g:javascript library="jquery" />

I don't want to update the plugin jquery version on the plugin directory, but the resources plugin can't find the .js on my dir. It keeps giving me this exception:

java.lang.IllegalArgumentException: Module [jquery] depends on resource [/plugins/jquery-1.6.1.1/js/jquery/jquery-1.6.4.min.js] but the file cannot be found

Hi Filipe,

Just override the "jquery" resource module using the "overrides" mechanism and point it at your new jquery version.

This is what the module declaration looks like in jQuery plugin:

// Resource declarations for Resources plugin
def jqver = org.codehaus.groovy.grails.plugins.jquery.JQueryConfig.SHIPPED_VERSION

modules = {
'jquery' {
resource id:'js', url:[plugin: 'jquery', dir:'js/jquery', file:"jquery-${jqver}.min.js"],
disposition:'head', nominify: true
}

'jquery-dev' {
    resource id:'js', url:[plugin: 'jquery', dir:'js/jquery', file:"jquery-${jqver}.js"], 
        disposition:'head'
}

}

... so you just add your own AppResources.groovy or whatever you want to call it and add:

modules = {
overrides {
'jquery' {
resource id:'js', url:[dir:'js/jquery', file:"jquery-1.6.4.min.js"]
}
}
}

This will amend the module to point at your own file.

Make sense?

Thanks
Marc

~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java)

Founder @ http://noticelocal.com | Developer @ http://weceem.org
Member @ http://spottymushroom.com | Contributor @ http://grails.org
Twitter: http://twitter.com/wangjammer5 | Resumé: http://www.anyware.co.uk/marc/
Blog: http://www.anyware.co.uk | Grails Rocks: http://www.grailsrocks.com

@felipero
Copy link
Author

Great,

It works, but it is not documented anywhere on the docs. Also, would be nice to have a convention. Look for the app version and then for the plugin version? Not sure it is easy to implement. Maybe with some exception fallback or some config instead of a convention.

By the way, thanks for the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants