Unzip Spring Roo in a directory, you could either have it by downloading it directly or have it as part of the Spring STS zip file.
Set the environment variable ROO_HOME and append ROO_HOME\bin to the PATH
Run Roo by:
$ mkdir new_project_dir
$ cd !
you can use tabs extensively here for suggestions, just use hint
roo> project --topLevelPackage com.apress.springrecipes.roo.test1 //You’ll get a directory with a Maven 2 (or greater) project
preconfigured already with Spring and more. type: roo> quit to exit roo shell and via find command you'll see the following directory structure:
(initial content) Maven projects are described by the pom.xml file in the root of the project. They store metadata about the dependencies required in the application, as well as their scope: .jar files that are required only for unit testing are not included in the final build intended for deployment. Similarly, .jar files that provide interfaces needed only at compile time, such as the Spring Roo aspects (since the Spring Roo annotations are source-level only) and the various standard interfaces (you need to compile against javax.servlet.*, for example, but your deployment server already has those libraries on its path and there’s no need to furnish them.)
It imports standard jar files e.g. JUnit 4.x, Apache Commons Logging, AspectJ, Java Servlet APIs, etc.
You would notice that roo is only for compile time and has no footprint in runtime.
<scope>provided</scope> //meaning that it won’t exist at runtime and is there only for the compiler.
A directory to hold the non–unit-test Java files for your application. This could include control classes (as opposed to view files e.g. jsp files)
Holds classpath resources that aren’t Java class files. You can see here that it’s appropriate to put the META-INF/ directory as well as any other artifacts (like Spring application contexts) there. Note, this is for classpath resources and is not appropriate, for example, for web application resources. For that you need src/main/webapp.
This directory holds artifacts intended to test the Java classes under the src/main/java folder. Typically, the package structures mirrors the package structure in src/main/java, allowing your tests to have package-friendly visibility to the classes under test.
This directory holds resources needed by your test classes at test time, in the same way that src/main/resources works.
This is a Maven project. directory structure is consistent for all Maven projects.
Maven works over the notion of convention over configuration.
$ mvn package in the same directory as pom.xml or run roo> perform package in the roo shell: it will compile, deploy, document, test, and share your project artifacts for you. It will create a ./target directory besides the ./src directory put the jar file it has made there besides classes and other files. Plug-ins can be written to hook into each phase.
To list the content of the jar file created
$ unzip -l test1-0.1.0.BUILD-SNAPSHOT.jar
Length Date Time Name
--------- ---------- ----- ----
0 2011-03-16 11:01 META-INF/
124 2011-03-16 11:01 META-INF/MANIFEST.MF
0 2011-03-16 11:00 META-INF/spring/
3953 2011-03-16 11:00 META-INF/spring/applicationContext.xml
554 2011-03-16 11:00 log4j.properties
0 2011-03-16 11:01 META-INF/maven/
0 2011-03-16 11:01 META-INF/maven/com.apress.springrecipes.roo.test1/
0 2011-03-16 11:01 META-INF/maven/com.apress.springrecipes.roo.test1/test1/
9436 2011-03-16 08:58 META-INF/maven/com.apress.springrecipes.roo.test1/test1/pom.xml
139 2011-03-16 11:01 META-INF/maven/com.apress.springrecipes.roo.test1/test1/pom.properties
14206 10 files
***You can also make a roo project via STS program->File->New->Roo Project. You can also have a Roo shell in the STS via Window -> show View -> Roo Shell
Steps to make a project with roo:
roo> project --topLevelPackage com.apress.springrecipes.roo.test1
// Spring Roo 1.1.2.RELEASE [rev fbc33bb] log closed at 2011-03-16 09:15:54
// Spring Roo 1.1.2.RELEASE [rev fbc33bb] log opened at 2011-03-16 10:58:46
//perform package this makes the jar files, etc
roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
// Spring Roo 1.1.2.RELEASE [rev fbc33bb] log closed at 2011-03-17 08:12:20
you can refer to the base project (parent) by ~
roo> ent --class ~.domain.Customer --testAutomatically