Equivalent to maven-install command in Grails 3 - grails

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.

Related

Grails war produces JAR file in version 3.1

We're using Grails 3.1 and I'm trying to build a WAR to be run on an external Tomcat container, but when I run grails war, it creates a JAR file in the <project_dir>\build\libs directory. How do I configure Grails to produce a WAR file?
Grails 3.1.2 was released earlier today and includes a bug fix for your issue: https://github.com/grails/grails-core/issues/9736.
Upgrading to 3.1.2 didn't solve the problem. I'm using the web-api profile, so I'm not sure if things are different from the default profile.
However, I did solve this by applying the Gradle war plugin in build.gradle. Note: originally I had the war plugin last, after the other Grails plugins; and it did not work. It worked fine after moving it before them.
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.plugins.views-json"
Grails 3 is using gradle.
gradle war
And make sure you are using Tomcat 8 and above. For tomcat 7 you need to remove internal tomcat8 jars from war in the config file.

Grails 2.5.1: use grails command-line tasks from binary plugin in lib folder

In Grails 2.5.1, is it possible to use grails command-line tasks from a binary plugin in the lib folder?
I had to modify an existing third-party plugin to get it to work properly.
I put the jar generated by the following command in my project's lib directory:
grails package-plugin --binary
When my project runs, it correctly uses my modified version of the plugin.
At build time, however, I need to run a Grails task on the command line that was provided by the plugin, but, using the binary plugin, the task does not appear to be available.
e.g., if the task was abc, when using the real plugin being referenced in the plugins section of BuildConfig.groovy, then I could run:
grails abc
Using the binary plugin in the lib folder, however, results in the task not being available from the command line.
Also, the original plugin hooked into grails war to include extra steps in the build process without changing the command line. These hooks no longer run with the binary plugin. Is there any way to reinstate the hooks for the binary plugin?
Thanks.

Jenkins + Grails or Jenkins + Gradle + Grails

I have a grails project. I want to set up some CI for it. Are my better off calling grails commands directly from Jenkins or using Jenkins to call Gradle to call Grails commands.
The reason I ask is that when using Gradle with Grails most Gradle stuff just calls out directly to Grails commands.
Thanks
The easiest is to use the (built-in) grails wrapper (http://grails.org/doc/latest/guide/single.html#wrapper).
You would then run
./grailsw refresh-dependencies
./grailsw test-app
First line to setup (install all plugins etc.) grails and second to run your tests.
The advantage of grails wrapper is that it takes care of downloading & installing the correct grails version. Which is very useful if you upgrade grails. You don't have to do anything on your ci server.
There is also a grails plugin for jenkins (https://wiki.jenkins-ci.org/display/JENKINS/Grails+Plugin) that supports the grails wrapper.

How do I create a Grails skeleton project for plugin development?

I am working with a (sort of) framework built on top of Grails. This framework is a set of Grails plugins that add functionality to the Grails app (e.g. user authentication). This framework is a bit of a pain to setup, as it requires around 64 lines of site specific configuration in the apps's Config.groovy file.
I want to develop my addons to this app as plugins. That is, the Grails app would really just be a set of installed plugins and some configuration files.
I have created a local Maven style repository to hold all of my plugins. Thus, I can add plugin dependencies to the BuildConfig.groovy file and they will be installed automatically (side question: is it possible to specify the install order?).
So my question is, how do I create skeleton project for developing my plugins that would:
Include the base configuration for my application (the aforementioned 64 lines)
Allow me to do a grails package-plugin to package only the plugin's code
You can use the post-installation hooks mechanism: http://grails.org/doc/latest/guide/plugins.html#hookingIntoBuildEvents
Not really an ideal setup for me, but the following works:
Create the "base" application: cd ~/GrailsDev/ && grails create-app my-app
Configure my-app as desired/required
Create your dependent plugin: cd ~/GrailsDev/ && grails create-plugin my-app-plugin
Add the new plugin to the app by editing "~/GrailsDev/my-app/grails-app/conf/BuildConfig.groovy" and appending the line: grails.plugin.location.'my-app-plugin' = "../my-app-plugin"
You can now run the my-app Grails application and the plugin will be included. When your plugin is fully developed, you can do grails package-plugin from within the "~/GrailsDev/my-app-plugin" directory to package your plugin.
use gradle. you can specify the order and package your plugin alone.
e.g. include the required plugins as git modules (for easy versioning) and gradle modules (for building your plugin) in your plugin project.
this setup will serve your requirements well I suppose.
https://github.com/grails/grails-gradle-plugin
IntelliJ does have a template for gradle-backed grails applications and plugins.

How to build from my checkout directory ... with a twist

We're using Maven 3 with Git as our SCM system. We are using the latest version of the scm plugin (1.5). Our project is in Grails 1.2.1 (Java 1.5). The question is, how do I run a single command to generate a WAR file after doing a checkout from our repo?
This question seems complicated by the fact that we're using the a Grails project (and hence the maven-grails plugin, version 1.3.4). Grateful for any info you have, - Dave
I'm assuming that the command line below below wont work for you because of your requirement to use maven.
grails <environment> war
You can generate a pom.xml for your existing grails project with the following command. This can be a useful starting point.
mvn grails:create-pom
More documentation about grails's maven integration can be found here:
http://grails.org/doc/latest/guide/4.%20The%20Command%20Line.html#4.5%20Ant%20and%20Maven

Resources