Is there any posibility to make it work a plugin created using grails 3 as a dependency of a grails 2 project? Both projects use the same groovy version.
Is there any posibility to make it work a plugin created using grails
3 as a dependency of a grails 2 project?
Not really. We re-wrote the plugin system in Grails 3 such that Grails 3 plugins are not compatible with Grails 2 and vice-versa.
That said, Grails 3 plugins are just .jar files. You could have a Grails 2 application which depends on a Grails 3 plugin (just express the dependency like a normal library dependency, not a plugin dependency) and then whatever classes are in the Grails 3 plugin jar will be available in the Grails 2 app, but you won't have any of the plugin specific behavior imposed, you would just have access to the classes in the jar. Depending on the particulars, that might or might not be helpful.
For the most part the answer to your question is "no".
Both projects use the same groovy version.
That doesn't sound right. I think the latest version of Grails 2 supports an earlier version of Groovy than the earliest version of Grails 3.
Related
Is there a way of disabling a plugin on a Grails 3 project? I am using dependencies that have Grails plugins but I just want to keep the classes that are in the dependency.
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.
I have begun the journey of migrating my Grails apps to version 3.
I have a number of plugins that I with Grails 2 have installed to the local maven repository with the maven-install command available with the release plugin. They have then been easily accessible to my main project for import.
As far as I can see the release plugin does not exist for Grails 3. My question is, should I try to migrate the release plugin or is there some other, better way, in Grails 3?
If you have
apply plugin: 'maven-publish'
and the two apply from: 'https://raw.githubusercontent.com/... lines from the build.gradle file that's created for you when you create a Grails 3 plugin you can run
./gradlew install
to do the same thing as the maven-install script.
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
What is an inline plugin in Grails 2.X? How to make a plugin inline? I can find the documentation for Grails 3 but not for Grails 2.
Inline plugins in Grails 2.x are outlined in the documentation section for plugins.
From the documentation:
An application can load plugins from anywhere on the file system, even
if they have not been installed. Specify the location of the
(unpacked) plugin in the application's
grails-app/conf/BuildConfig.groovy file
Creating an inline plugin is done using the grails create-plugin command, just like a non-inline plugin.
The only real difference between an inline-plugin and regular plugin is how it is referenced by your application. A normal plugin is pulled from a repository (such as maven) while an inline-plugin exists in source format local to the application that is using it. Take for example:
/usr/foo/grails/MyApplication
/usr/foo/grails/MyInlinePlugin
/usr/foo/grails/MyOtherInlinePlugin
The above application (MyApplication) can include the two plugins listed as inline plugins by using the following in the BuildConfig.groovy
// BuildConfig.groovy
grails.plugin.location.'my-inline-plugin' = "../MyInlinePlugin"
grails.plugin.location.'my-other-inline-plugin' = "../MyOtherInlinePlugin"
Overall inline plugins are useful when developing (or testing) a plugin as well as creating modular Grails applications.
You can find the documentation in this URL: Grails Documentation
Go to the section: User guide for older versions
And select your version of Grails.
Here you can find, for example, the documentation of Grails 2.5.0: Grails Documentation 2.5.0
The inline plugins can help you to debug an application or change the code of your plugins to do your tests, instead of apply the changes in the plugin and when it's released, test if it's OK. It's very useful to change different plugins in the same time.
Hope this helps!