Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring Roo 1.1 Cookbook

You're reading from   Spring Roo 1.1 Cookbook Over 60 recipes to help you speed up the development of your Java web applications using the Spring Roo development tool

Arrow left icon
Product type Paperback
Published in Sep 2011
Publisher Packt
ISBN-13 9781849514583
Length 460 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (14) Chapters Close

Spring Roo 1.1 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with Spring Roo 2. Persisting Objects Using JPA FREE CHAPTER 3. Advanced JPA Support in Spring Roo 4. Web Application Development with Spring Web MVC 5. Web Application Development with GWT, Flex, and Spring Web Flow 6. Emailing, Messaging, Spring Security, Solr, and GAE 7. Developing Add-ons and Removing Roo from Projects Index

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:\roo-cookbook\ch01-recipe directory. Download the ch01.roo file from the book's website and copy it to C:\roo-cookbook\ch01-recipe. Start the Roo shell from the C:\roo-cookbook\ch01-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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image