I have a Grails 2.x project with a BuildConfig.groovy, and I need to read the dependencies programmatically, using some kind of API that will process the file so that I can read how it would be at runtime. So far I have been unable to locate the right class in the Grails API for processing a BuildConfig.groovy.
How can I do this?
Thanks
Use this simple command to generate your dependency report -
grails dependency-report runtime
reference - doc
Related
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
I am using Grails 2.3.8
I am using - org.yaml.snakeyaml.Yaml class.
Didn't have any issues with GGTS workspace finding the package during auto
complete in the source.
But when running the application I get
java.lang.ClassNotFoundException:org.yaml.snakeyaml.Yaml
My assumption was this is part of the core Grails and the jars will be
included automatically.
Do I have to configure and add the jar or dependency in the
BuildConfig.groovy ?
Grails 3 uses Yaml and includes it as a dependency but prior to 3.0 it didn't, so you need to configure it like any third-party dependency in BuildConfig.groovy, e.g.
dependencies {
...
compile 'org.yaml:snakeyaml:1.14'
}
I have found some code in grails plugins that can be use outside grails. Is there a way to use the code from the plugin as a dependency in a groovy project other than creating two projects?
For example I found the following project:
https://github.com/jeffellis/grails-yammer-metrics
Where they created some annotations for Groovy code that I would like to use outside a grails project.
As of grails 2.1, you can export a plugin as a binary plugin and then declare as a regular jar dependency (via grape in groovy). http://grails.org/doc/latest/guide/plugins.html#binaryPlugins
How reusable the code is would depend on how closely coupled the plugin is to the code, I guess.
i'm writing my first plugin,
but in test project, can't resolve the class of plugin (src/groovy)
I am guessing that you are not properly specifying the dependency between your plugin project and your app. Have you added a dependency either through the Grails plugin manager or by manually editing the buildConfig.groovy file?
I use STS for Grails development. When I install a plugin the IDE does not find some core classes of the plugin.
Example:
import grails.plugins.nimble.core.AdminsService
gives "Unable to resolve class import grails.plugins.nimble.core.AdminsService" .
The project runs OK.
Also, I can't find that classes myself in the project dir nor in Grails SDK dir. Where are they?
Grails uses the ivy dependency manager. You'll find the plugin classes under .ivy2/cache/org.grails.plugins/ in your home directory.
This post might help you with your STS issue.