Build a standalone application with grails

I wonder if there is a tool that creates a demo of my grails projects. What I can distribute on a CD or USB drive that will work in any environment.

Something that

  • comes with one shell script to run the application
  • looking for a free server port in the system (there is no error message if 8080 is already in use)
  • launches berth server
  • launches a standard browser with my application

Does anyone know about such an instrument?

+6
source share
3 answers

Check out the standalone plugin , which greatly facilitates the distribution of the demo version of your Grails application.

"A stand-alone plug-in creates an executable JAR file with a built-in war built from your application and a built-in instance of Tomcat 7. This allows you to create a single archive that can be run on any computer with Java 5 or higher by running java -jar standalone.jar. It can be convenient for demonstration or even very easy installation with low traffic Grails ".

Full documents for standalone plugin here

To prepare the jar file ...

grails -Dgrails.env=demo build-standalone our_cool_demo.jar 

To start the Grails application (port specified as parameter) ...

java -jar /path/to/jar_name.jar cool_demo localhost 9000


Update:

There are actually 2 standalone Grails plugins:

  • The following is a standalone plugin that is based on Tomcat7
  • The plugin is standalone , based on Jetty and works in a similar way.

There are also some options based on the Hudson and Winstone project, but there is no Grails plugin. Here are some links with more information: Build an executable war using grails, maven and jetty , Executable WARs using Jetty and Winstone

+15
source

The best thing that comes to mind is to use the Linux distribution on a USB stick with installed grails. You can export the application as a WAR file, and then create a script containing grails prod run-war to execute on boot. Finally, you can open firefox with firefox localhost:port#/AppName

The only drawback of this option is that you need to boot from the stick, and this will create a bit of delay time. However, the advantages are that you only need to worry about supporting one OS, do not scan the port at startup and simplicity.

+2
source

The answer suggested by Chris does not work for me, but it gave me a good starting point: It seems that creating such a stand-alone application is not so difficult:

  • A jetty is a good starting point: just drop the jetty files to the USB drive and deploy the grails application by dropping the .war file in the jetty webapps directory.
  • create a small groovy script that looks for two (!) free ports. You will need a second to stop the server again.
  • groovy script can start and stop the server
  • compile the script to avoid installing groovy on the target machine

what he. I think I’ll write more details when I find some more time ...

+1
source

Source: https://habr.com/ru/post/914452/


All Articles