Creating application artifacts from Roo script

In some scenarios, you may want to generate complete enterprise application skeleton by feeding a set of Roo commands to Spring Roo from a text file. To address such scenarios Spring Roo provides the script command, which allows you to execute commands contained in a text file. The convention is to name the script file containing commands with a .roo extension.

Note

Roo script is nothing but a text file containing Roo commands. The commands are executed in the order they appear in the text file.

In this recipe, we look at how we can execute the commands contained in a ch01.roo text file that accompanies this book. The ch01.roo file contains commands, which let's you create a fresh flight-app project.

Getting ready

If your Roo shell is still open, then exit it and remove all the files from the C: oo-cookbookch01-recipe directory. Download the ch01.roo file from the book's website and copy it to C: oo-cookbookch01-recipe. Start the Roo shell from the C: oo-cookbookch01-recipe directory.

How to do it...

To create the application skeleton execute the script command, by specifying the file containing Roo commands, as shown here:

roo>script --file ch01.roo --lineNumbers

How it works...

The script command accepts the following arguments:

Argument

Purpose

file

It is a mandatory argument, which specifies the name of the file that contains Roo commands

lineNumbers

It is an optional argument that instructs the Roo shell to print the line numbers of the command being executed from the file

There's more...

One of the features that you will not find in Spring Roo is to revert the execution of a previous command. For instance, if you added a field using the field command and now you want to rollback the changes it made, then it is not possible. If you have mistakenly executed a Roo command, you can remove it from the log.roo file and re-execute the commands in log.roo using the script command.

If a Roo command fails for some reason, it is commented out in the log.roo file. So, you don't need to worry about removing commands that failed execution from your log.roo file.

See also

  • The Setting up Roo recipe show how you can get started with Spring Roo.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.81.33