- GWT (Google Webtoolkit) comes with "generators" which focus on ANT as build system
- Ruby on Rails has its way of starting a new application and scaffold models and their views
- JRuby allows to use java side by side with ruby and allows to run a rails application in a java servlet engine
- Maven is a build tool mainly for java project. but with a set of jruby maven plugins (j)ruby project can be managed almost as well. with the advent of Roo the maven support for GWT drastically improved.
- Ruby-Maven Gem tries to bridge the ruby and maven world by offering a more concise commandline interface. as gem it is easy to install from ruby point of view.
- RestyGWT is a GWT generator for REST services and JSON encoded data transfer objects.
walkthrough of an examplefirst you need ruby-maven installed. when you use it with ruby (MRI) then you also need java >1.5 installed or use jruby. please update the gem if already installed:
jruby -S gem install ruby-maven
ruby -S gem install ruby-mavenusing MRI will improve startup time drastically.
create a rails applicationwith ruby-maven there are new commands rmvn, gwt and jetty-run with this you can create a new rails application with GWT setup like this
gwt new my_app com.example
with this you have already a GWT application with EntryPoint and could be started but does not do much. the class layout within the GWT client package:
src/main/java/com/example/client/ ├── client │ ├── ActivityPlaceActivityMapper.java │ ├── ActivityPlace.java │ ├── managed │ │ ├── ActivityFactory.java │ │ ├── MyAppModule.java │ │ └── MyAppPlaceHistoryMapper.java │ └── MyAppEntryPoint.java └── MyApp.gwt.xml
scaffold a resource with model, controller, gwt-model, etc
go into the created application (or any existing rails app)
now you can scaffold a model (currently two steps are required for this)
this creates a rails like structure following the GWT activity/place/view pattern:
rmvn rails generate scaffold user name:string
finally you can run the application.
src/main/java/com/example/client/ ├── activities │ └── UserActivity.java ├── models │ └── User.java ├── places │ ├── UserPlace.java │ └── UserPlaceTokenizer.java ├── restservices │ └── UsersRestService.java └── views ├── UserViewImpl.java ├── UserView.java └── UserView.ui.xml
start the GWT development shell
before running the application you need to migrate the database
and start the GWT development shell
rmvn rake db:migrate
the start url for the new resource is
http://localhost:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997#usersto run the application with default webrick you need first to compile the GWT part
run the rails server
run the rails server
the compiler will output the GWT app in public/my_app and then start the webrick. the start url is http://localhost:3000/MyApp.html#users
or if you prefer the jetty server with http://localhost:8080/MyApp.html#users
rmvn rails server
build the war file
the war file can be found in the target directory
moreyou can also use proper maven3 instead of ruby-maven but the command-line-interface of maven is much more clumsy though the functionality is the same.
more up to date infos are here: https://github.com/mkristian/rails-resty-gwt
any comment and/or suggestion is welcome.