When using the grails plugin dsl in BuildConfig.groovy, such as
plugins {
build "org.grails.plugins:db-util:0.4"
}
Is there a way to specify to use a plugin from a zip file like you can do with grails install-plugin?
Not directly, but of you put the zip file in a directory and name it without the grails- prefix, then declare that directory as a flatDir repository then Grails will be able to resolve the plugin from there.
repositories {
flatDir name:'localPlugins', dirs:'../local-plugins'
}
// copy plugin zip to ../local-plugins/my-plugin-1.2.zip
plugins {
compile ':my-plugin:1.2'
}
Or if it's a locally built plugin you could install it into your local maven cache using grails maven-install and just use mavenLocal() instead of the flatDir.
Related
I would like to change my project from Grails from 3.0.9 to 3.0.10 since latter contains Promise API.
How to do that in IntelliJ?
in the gradle.properties file change
grailsVersion=3.0.10
also in the build.gradle change
buildscript {
ext {
grailsVersion = project.grailsVersion
}
}
You just need to change the grails version in gradle.properties. The gradle build script will pull the required jar files from the grails repo specified in your build file.
I have a plugin project which I created as grails create-plugin myPlugin. I also created a 'normal' grails project as grails create-app myPluginDemo. I'm trying to install myPlugin plugin in myPluginDemo but don't understand how to use grails.plugin.location.
Where do I put grails.plugin.location inside BuildConfig.groovy? Inside plugins section? Inside repositories section?
What should I append to grails.plugin.location? Should it be grails.plugin.location.myPlugin? Or grails.plugin.location.grails-my-plugin? Something else?
grails.plugin.location is not a dependency resolution, so it goes outside grails.project.dependency.resolution.
It should be like below, if both myPluginDemo and myPlugin are in the same directory. Moreover, this will not install the plugin into the app, but the application will refer to the file system for the plugin which is convenient in development mode. In order to use the packaged plugin it has to be referred in plugins inside grails.project.dependency.resolution
grails.plugin.location.myPlugin = "../myPlugin"
grails.project.dependency.resolution = {
repositories {
}
dependencies {
}
plugins {
}
}
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.
I am running Grails v2.4.0 and I have been trying to install the Grails CXF plugin for web services. I downloaded the .zip file for the plugin and then ran the grails install-plugin /path/to/zip. While trying to install, it gives me an error that it can't find this dependency : org.apache.cxf:cxf-rt-frontend-jaxws:2.3.0. The page where I downloaded this plugin mentions that everything required is in the zip. I can't use maven to download the required files automatically because my work location doesn't allow anything to be downloaded. Is there a list of files required to install CXF manually that I can reference?
Since you can't download the transitive dependencies using Maven, you should be able to exclude them like this:
grails.project.dependency.resolution = {
plugins {
compile ":cxf:0.9.0" {
excludes([ group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws']
// you may need to exclude quite a few...
}
}
Then download the dependency manually and put them in your lib directory. For instance, download the cxf-rt-frontend-jaxws from here: http://search.maven.org/#search|ga|1|g%3A%22org.apache.cxf%22%20AND%20a%3A%22cxf-rt-frontend-jaxws%22%20AND%20v%3A%222.3.0%22
Instead of using install-plugin you should add a dependency to the relevant section of your BuildConfig.groovy, and make sure the mavenCentral() repository is enabled. Uninstall the zip plugin you have already installed and then edit your BuildConfig:
grails.project.dependency.resolution = {
// ...
repositories {
// other repositories as before
mavenCentral()
}
plugins {
// other plugins as before
compile ":cxf:0.9.0"
}
}
We have a Project that contains 2 modules; web and client
The web module is a Grails application and the client module is mostly just groovy code and touch of Java code. The client module is being managed by a Gradle build script.
The Grails module has dependencies in the client module. In IntelliJ I can define that in the module config with no problems. However, when building the Grails WAR I really need to build the client JAR and have it placed in the WAR file. I'm wondering what is the best approach for this?
Here is what I ended up doing.
In my Gradle script I have the following:
repositories {
mavenCentral()
flatDir {
name "genRocketRepos"
dirs "${System.properties['user.home']}/.genRocket/repos"
}
}
uploadArchives {
repositories {
add project.repositories.genRocketRepos
}
}
I then run the uploadArchives task via Gradle. This published the JAR file to a local repos. In Grails BuildConfig.groovy I defined the following:
repositories {
...
flatDir name:'myRepo', dirs:'${userHome}/.genRocket/repo'
}
dependencies {
...
runtime 'genRocket:client:1.0'
}
Now Grails sees the dependency and includes in the classpath as well as places the JAR in the WAR for me.