tanamonの稀に良く書く日記

KEEP CALM AND DRINK BEER

Spring Rooの動作(12) - 基本コマンド

Rooの基本的なコマンド

hint [topics]

  • 次に行えるコマンドについてのヒントを表示する
  • [topics]省略時にはヒント項目の一覧を表示する
  • [topics]を指定するとその操作についてのヒントを表示する
  • 英語が苦もなく読める人であればとても便利
roo> hint
Welcome to Roo! We hope you enjoy your stay!

Before you can use many features of Roo, you need to start a new project.

To do this, type 'project' (without the quotes) and then hit TAB.

Enter a --topLevelPackage like 'com.mycompany.projectname' (no quotes).
When you've finished completing your --topLevelPackage, press ENTER.
Your new project will then be created in the current working directory.

Note that Roo frequently allows the use of TAB, so press TAB regularly.
Once your project is created, type 'hint' and ENTER for the next suggestion.
You're also welcome to visit http://forum.springframework.org for Roo help.
roo> project --topLevelPackage com.example.hint
...
roo> hint
Roo requires the installation of a JPA provider and associated database.

Type 'persistence setup' and then hit TAB three times.
We suggest you type 'H' then TAB to complete "HIBERNATE".
After the --provider, press TAB twice for database choices.
For testing purposes, type (or TAB) HYPERSONIC_IN_MEMORY.
If you press TAB again, you'll see there are no more options.
roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
...
roo> hint
You can create entities either via Roo or your IDE.
Using the Roo shell is fast and easy, especially thanks to the TAB completion.

Start by typing 'ent' and then hitting TAB twice.
Enter the --class in the form '~.domain.MyEntityClassName'
In Roo, '~' means the --topLevelPackage you specified via 'create project'.

After specify a --class argument, press SPACE then TAB. Note nothing appears.
Because nothing appears, it means you've entered all mandatory arguments.
However, optional arguments do exist for this command (and most others in Roo).
To see the optional arguments, type '--' and then hit TAB. Mostly you won't
need any optional arguments, but let's select the --testAutomatically option
and hit ENTER. You can always use this approach to view optional arguments.

After creating an entity, use 'hint' for the next suggestion.

help [command]

  • コマンドの使い方を表示する
  • [command]省略時にはコマンド一覧を表示する
  • [command]を指定するとそのコマンドのオプションを表示する

reference guide

  • helpコマンドで画面上に表示される説明文をDocBook形式としてファイル出力を行う
  • ファイルはappendix-command-index.xmlという名前で出力される

version

  • 画面上にバージョンを表示する
roo> version
    ____  ____  ____
   / __ \/ __ \/ __ \
  / /_/ / / / / / / /
 / _, _/ /_/ / /_/ /
/_/ |_|\____/\____/    1.1.0.M1 [rev 3a0b8a3]

date

  • 画面上に日付時刻を表示する
  • Windows環境では日本語が化けまする
roo> date
2010?6?2? 15?40?00? JST

system properties

exit

quit

  • Rooコマンドを終了する

development mode [mode]

  • 例外のスタックトレースを画面に表示させるようにする
  • [mode]を省略するとtrueになる
  • 不思議な挙動をした時に使う
roo> focus --class hoge
roo> field string --fieldName hogeField
Java source code unavailable for type SRC_MAIN_JAVA/com.example.hint.domain.Hoge
roo> development mode
Development mode set to true
roo> field string --fieldName hogeField
Java source code unavailable for type SRC_MAIN_JAVA/com.example.hint.domain.Hoge
java.lang.IllegalArgumentException: Java source code unavailable for type SRC_MAIN_JAVA/com.example.hint.domain.Hoge
    at org.springframework.roo.support.util.Assert.notNull(Assert.java:112)
    at org.springframework.roo.classpath.operations.ClasspathOperationsImpl.addField(ClasspathOperationsImpl.java:149)
    at org.springframework.roo.classpath.operations.FieldCommands.insertField(FieldCommands.java:128)
    at org.springframework.roo.classpath.operations.FieldCommands.addFieldString(FieldCommands.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.roo.support.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191)
    at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy$1.callback(ProcessManagerHostedExecutionStrategy.java:
4)
    at org.springframework.roo.process.manager.internal.DefaultProcessManager.doTransactionally(DefaultProcessManager.java:169)
    at org.springframework.roo.process.manager.internal.DefaultProcessManager.execute(DefaultProcessManager.java:132)
    at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy.execute(ProcessManagerHostedExecutionStrategy.java:32)
    at org.springframework.roo.shell.AbstractShell.executeCommand(AbstractShell.java:158)
    at org.springframework.roo.shell.jline.JLineShell.promptLoop(JLineShell.java:200)
    at org.springframework.roo.shell.jline.JLineShell.run(JLineShell.java:126)
    at java.lang.Thread.run(Thread.java:619)

backup

  • プロジェクトファイルのバックアップを作成する
  • ファイルは[projectName]_[yyyy-MM-dd_hh.MM.ss].zipという名前で作成される

script --file [fileName]

  • 外部ファイルに定義されたRooコマンドを実行する
  • [fileName]に指定する「~」は他のコマンドとは違いsystem propertiesのuser.homeの値になるので注意
  • また、ディレクトリを指定していない場合、環境変数ROO_HOME以下samplesディレクトリ内のファイルも走査対象になるので、これも注意

focus --class [className]

  • cdコマンドみたいなもので、カレントポジションの変更を行う
  • 各コマンド--class指定を省略して実行することができる
  • 存在しない場所も指定できてしまうところが微妙
roo> focus --class ~.domain.SandboxClass
roo> field string --fieldName hoge
Java source code unavailable for type SRC_MAIN_JAVA/com.example.focus.domain.SandboxClass
roo> class --class ~.domain.SandboxClass
Created SRC_MAIN_JAVA\com\example\focus\domain
Created SRC_MAIN_JAVA\com\example\focus\domain\SandboxClass.java
roo> field string --fieldName hoge
Managed SRC_MAIN_JAVA\com\example\hint\domain\SandboxClass.java