How do I know what webserver gradle / grails is using? - grails

This thread: Gradle / Grails application describes how to set up the grails plugin for gradle.
The command gradle grails-run-app tries to start the grails application on port 8080. What webserver is gradle using here?
Does it have an embedded one? If so how can I access / configure it?

It just shelling out to the same thing that Grails would have done without Gradle, as if you had run grails run-app. That depends on which server plugin you have installed. By default it's http://grails.org/plugin/tomcat, but you can switch to http://grails.org/plugin/jetty by changing the values in grails-app/conf/BuildConfig.groovy

Gradle is nothing but a build and config tool like maven. When you use it with Grails app the dependencies are managed by it as it happens when maven is used.
When you use gradle grails-run-app it does nothing more other than running grails run-app from its own context. The same embedded Tomcat server is used by default.

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 Standalone Plugin Not Found

I'm trying to use the grails standalone plugin with a new grails project but I can't get it to work.
I've added it as a plugin dependency in my BuildConfig.groovy file:
plugins {
compile: ":standalone:1.2.3"
}
But I get the following error when I attempt to run grails prod build-standalone:
Script 'BuildStandalone' not found, did you mean:
1) InstallDependency
2) Stats
3) InstallJQuery
4) CreateMultiProjectBuild_
5) TestApp
I tried running grails clean, grails clean-all, grails refresh-dependencies, and grails compile as answered in this question, but nothing seems to help. I would expect refresh-dependencies to either download the necessary artifacts or fail trying.
What am I doing wrong?
Here is my environment:
Mac OS X 10.9.5
JDK 1.8.0_05
Grails v2.4.4 installed with GVM
Always run grails compile after editing dependencies in BuildConfig.groovy; this triggers dependency resolution and installs the plugin, downloads the jars and adds them to the classpath etc. Once that happens the plugins' scripts will resolve.

Resolving view from webflow when running app with run-web

I have grails app that uses plugins to modularize app. Structure of app is as follows:
pluginA
pluginB
pluginMain
On one of those plugins (say pluginA) I have controller that uses Spring Webflow (using Spring Webflow 2.0.8.1).
Plugins are resolved locally in BuildConfig.groovy of pluginMain (grails.plugin.location.'pluginA' = "../pluginA"
grails.plugin.location.'pluginB' = "../pluginB").
When running app with run-app views used by webflow are resloved OK.
But, when I run app with run-war controller from pluginA tries to resolve view from location pluginMain/WEB-INF/grails-app/views/controllerName/flowName/nameOfView.jsp instead from pluginA
so I am getting HTTP 404 not found error.
I am using grails 2.3.7 and java jdk 1.7.
Please help!
The location that it is looking for in the run-war situation is the standard location for resolving page and flow views. You are likely getting into trouble by attempting to create a war file using inline plugins (the grails.plugin.location).
The inline plugin support is really nice when developing plugin functionality, but it has its quirks, particularly when you get multiple dependent plugins in play. At some point you have to break down and start publishing your plugins.
Try publishing the plugin to your local Maven repository using the "maven-install" command. Then change your BuildConfig.groovy file to reference the installed version of the plugin.
My normal workflow is something like this:
Develop the new plugin functionality using an inline plugin definition in BuildConfig.groovy, testing with run-app and run-test until I'm happy.
Publish a SNAPSHOT version of the plugin (ie. 1.0.1-SNAPSHOT) and update BuildConfig.groovy to point to the snapshot and test using run-app and run-war eg:
compile (":ark-kpi:1.0.1-SNAPSHOT")
Publish your plugin in release form either to your local maven repository (maven-install) or a public repository like a locally running Artifactory if you want to share with colleagues (publish-plugin).
You should read the guide section on plugins and configuration for details on setting up repositories.

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.

Reinstall grails plugin from a simple HTTP location

I installed a plugin using 'grails install-plugin http://blahblah/blah.zip'. The location does not follow the grailsRepo standard or maven standard. It's a simple zip file on a remote server.
How do I configure grails so that it finds the plugin?
I don't think it is possible. You either have to install the plugin in a maven-compatible repo or you'll have to run install-plugin every time you build from scratch.
in grails project directory grails-app/conf/BuildConfig.groovy
grails.plugin.location."pluginName"="../path/to/plugin"

Resources