Order of Grails Bootstrap classes - grails

On one of our feature branches of our project we have a strange issue with running our grails integration tests. In our application we have the base project and one plugin, which relies on data from the base application. The default data is created in the "Bootstrap" Classes of the project and the plugin.
since yesterday the bootstrap of the plugin is called before the base bootstrap, and fails, because of the missing data from the application. This happens only if we run the integration tests, and only on our buildserver (Windows Server 2012 with Atlassian Bamboo).
test-app -integration --stacktrace -non-interactive
how can we fix this problem?

Grails makes no guarantees about ordering of BootStrap classes so it isn't something that should be relied about in your application.
If you need to control ordering of logic that is run at startup there are better solutions, for example you could use the platform-core plugin's event model to trigger an event in your application that your plugin listens to once the data it needs is in place. See http://grails-plugins.github.io/grails-platform-core/guide/events.html

Related

best way to create a grails 3 app for web

I have previously used "grails create-app myapp" and the resultant application has web built in - e.g. I can scaffold or modify my views.
I see that there are various profiles, including "web". Web has various features. What is not clear is what the consequence of adding or not adding features, and why "web" is different from no profile.
Web profile features are:
Provided Features:
asset-pipeline - Adds Asset Pipeline to a Grails project
events - Adds support for the Grails EventBus abstraction
geb - Adds Geb 1.1.1 and WebDriver 2.47.1 to run functional tests
geb2 - Adds Geb 2, WebDriver 3.6.0 and Webdriver binaries Gradle Plugin dependencies to run functional tests. Requires JDK8.
gsp - Adds support for GSP to the project
hibernate4 - Adds GORM for Hibernate 4 to the project
hibernate5 - Adds GORM for Hibernate 5 to the project
json-views - Adds support for JSON Views to the project
less-asset-pipeline - Adds LESS Transpiler Asset Pipeline to a Grails project
markup-views - Adds support for Markup Views to the project
mongodb - Adds GORM for MongoDB to the project
neo4j - Adds GORM for Neo4j to the project
rx-mongodb - Adds RxGORM for MongoDB to the project
The confusing thing is whether I select web profile or not, and select hibernateX or not, I get hibernate anyway.
I know I dont need mongodb, neo4, rx-mongodb, geb, geb2, but surely everyone needs asset-pipeline etc. Should I chose json-views, hibernate5, gsp etc? If I forget to add these, how can they be added later?
Does not matter what the default generated build.gradle file contains, you can remove the items you don't need straight away.
So, you should pick
asset-pipeline
gsp
hibernate4/5
and the web-profile.
The same is true for adding new plug-ins or dependencies: you can do it any time later.
You should strive to keep the dependencies at minimum, as they mihgt have internal (version) conflicts.

AST Browser in Intellij

Is there anyway I can open the AST Browser in Intellij for a Grails project? I am trying to figure out the compilation phases for various gorm objects and services.
I know it's not using the AST Browser in Intellij but the AST browser that comes with the Groovy console is quite handy.
Using the console command from your Grails application will launch the console with your Grails application fully setup and running. Within the console you can access all of your Grails application and the AST browser.
ctx within the console gives you a quick handle to the main application context so you can get a reference to any service/bean within your application. GORM and everything else is also available too.

Configure an Activiti BPM?

I want to know that how to configure/run Activiti BPM in Grails?? I'm using fedora as my OS, Grails 2.1 . If their is any tutorial websites are is plz mention it also..
There is a plugin for Grails applications that provides much of Activiti within a Grails app. http://grails.org/plugin/activiti However, development has sadly stopped on it by the main developer. The last update was for Activiti 5.9 and Grails 2.1, though much of the plugin content seems to be built for older versions of Grails; for example, actions in the plugin's TaskController are all closures, not methods. Also, someone did issue a pull request to update it to 5.10.
I've been trying to puzzle through the source for that plugin myself. I keep vacillating between simply setting up a standalone Activiti server and utilizing the RESTful API from within a Grails Service class, importing a few of the Activiti classes into my Grails app, or trying to re-engineer the plugin to suit my needs (my site is stuck on Grails 2.0.1 for the time being).

What is a Grails Plugin? What does it mean to Install a Plugin?

I used Grails recently, and added Grails plugin for JQuery, but I don't think it did anything more than just copy some jQuery files over.
So far, I have seen info only on 'how to install and use' plugins...but I can't find anything that describes the concept of a plugin.
Can somebody please tell me, what is a Grails Plugin? And what does it mean to 'Install' a plugin?
A Grails plugin is (or should be) a self-contained bundle of functionality that can be installed into a Grails application. When a Grails plugin is installed, it can do any of the following:
define additional Spring beans
modify the generated web.xml
add new methods to the application's artefacts (controllers, domain classes, services, etc.)
provide new tag libraries
make additional resources and classes available to the application
provide new Grails commands
For example, when you install the JQuery plugin
the JQuery JavaScript files are added to the application
a new Grails tag <jq:jquery> is added to the application
a new Grails command grails install-plugin jquery is added to the application
When you install a Grails plugin, that plugin's functionality is made available to the installing application. However, the plugin itself is not actually copied into the application, only the plugin name and version is added to the application's application.properties file. The plugin itself is downloaded to $HOME/.grails and the application loads it from there.
The structure of a Grails plugin project is identical to that of a Grails application, with the exception of a configuration file (known as a plugin descriptor) that is included in a plugin's root directory.
Well, a Grails plugin is some piece of software that extends the frameworks funcionalities in some manner. Generally, installing a plugin in Grails means copying it to your Grails folder, so projects can refer to it and Grails will know where to find it.
Grails plugins have this folder structure:
grails-app
controllers
domain
taglib
service
etc
lib
src
java
groovy
web-app
js
css
So anything it has there will also be available to the application that uses it. For example, the Searchable plugin has a service class which you can use to perform advanced searchs in your own domain classes .
The jQuery plugin you mentioned has the jQuery .js file, and a tag to include that file.
For information on creating plugins, see http://grails.org/doc/latest/guide/12.%20Plug-ins.html
A plugin is just a set of functionality around a desired purpose. So the Spring Security plugin provides a way to lock down your app, assign roles to users, restrict access, whatever. The Searchable plugin allows you to integrate advanced searching into your app. There are lots of plugins
The point is to provide useful functionality so that you don't have to implement hard things yourself. Someone did something useful, and they wanted to contribute back to the community, so they organized their functionality and made it available.
A plugin is code and configuration, like any functionality you would implement yourself.
There is some documentation here: http://grails.org/doc/latest/ref/Plug-ins/Usage.html

Is it possible to add Grails MVC classes at deployment time?

I'm writing a Grails app which I'd like 3rd parties to augment at runtime. Ideally they would be able to add a JAR/WAR to the webapp directory which contains new domain, controller and service classes, new views, and other content.
Is there a simple way to do this within grails? Would it be simplest to create a startup script which copies the new classes etc. into the relevant directories and then updates grails.xml and web.xml?
You will be able to do this in version 2 of grails in which plugins will be also OSGI plugins http://jira.codehaus.org/browse/GRAILS/fixforversion/15421
It seems that the Grails plugins will actually fit quite well for this: http://www.grails.org/Understanding+Plugins
A plugin can do just about anything... One thing a plugin cannot do though is modify the web-app/WEB-INF/web.xml or web-app/WEB-INF/applicationContext.xml files. A plugin can participate in web.xml generation, but not modify the file or provide a replacement. A plugin can NEVER change the applicationContext.xml file, but can provide runtime bean definitions

Resources