lazybones templates to create new OpenDolphin based projects
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
gradle/wrapper
templates
.gitignore
README.adoc
build.gradle
devnotes.adoc
gradlew
gradlew.bat

README.adoc

Open-Dolphin Lazybones templates

These project templates make it very easy to create new Open-Dolphin applications.

Installation of Lazybones using gvm (Linux, OS/X)

Install sdkman (new name of gvm, see also http://sdkman.io/ ):

$ curl -s http://get.sdkman.io | bash

Install lazybones:

$ sdk install lazybones

Add the following entry to your $HOME/.lazybones/config.groovy file (create the file if it isn’t there):

bintrayRepositories = [
  "opendolphin/lazybones-templates"
]

Installation of Lazybones without sdkman

Grab the distribution from Bintray, unpack it to a local directory, and then add its bin directory to your PATH environment variable.

Usage

Since Open-Dolphin is independent from any framework or library it can be used together with many frontend and backend technologies. This is the reason why there is not just one single template for project creation. You can choose whether your project should be java or groovy based and you may also choose which technology you would like to use. Currently there is a template for JavaFX and a HTML5 frontend is included in the webapp submodule. Here is a list of all currently available templates:

  • dolphin-client-javafx-groovy

  • dolphin-client-javafx-java

  • dolphin-combined-groovy

  • dolphin-combined-java

  • dolphin-gwt

  • dolphin-server-groovy

  • dolphin-server-java

  • dolphin-server-webapp

  • dolphin-server-webapp-angularjs

  • dolphin-shared-groovy

  • dolphin-shared-java

You can see this list with the command lazybones list.

The following sections will help you setup a new Open-Dolphin project. You will end up with a simple hello world GUI connected to the server.

Setup the project structure

First let us create a new folder and cd into it

mkdir hello_dolphin
cd hello_dolphin

For our first example we will create a JavaFX client which will use a service of the server side to display a hello world greeting. Therefore we need the following modules: dolphin-client-javafx-java, dolphin-combined-java, dolphin-server-java, dolphin-shared-java and dolphin-server-webapp. Create the modules as follows:

lazybones create -Pdv dolphin-client-javafx-java client
lazybones create -Pdv dolphin-combined-java combined
lazybones create -Pdv dolphin-server-java server
lazybones create -Pdv dolphin-shared-java shared
lazybones create -Pdv dolphin-server-webapp webapp
Note

What does -Pdv mean?

Usually lazybones asks the user to enter values of template’s parameters. To get our example up and running as quickly as possible we want to work with the default values.

The option -Pdv means that the default values for parameters are applied:

group

org.group

version

0.1.0-SNAPSHOT

package

org.group

If you would like to specify these properties interactively simply do not use this parameter.

A third possibility is is to specify the values on the commandline using -Pgroup=org.mygroup for example.

  • cd into the combined folder and you should see the familiar files of a gradle based project:

build.gradle
gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
src

At this moment the setup of our project is complete and our directory structure looks as follows

hello_dolphin
├── client
├── combined
├── server
├── shared
└── webapp

Next we will run the application.

Running the application

You can run the application in two modes: the development mode and the remote mode.

Development mode

To run it in development mode make sure you are in the combined folder and invoke:

./gradlew :run

which shows the hello dolphin GUI with an entry field for the name and Greet button on it. Clicking the button will show a Hey Duke greeting:

hello dolphin javafx

On the terminal you can watch the commands which are sent forth and back between client and server.

Running the application this way (especially with an IDE) is most convenient for development since it requires only one process to be started.

Remote mode

To run the application in remote mode you need we use the webapp module which we already have created. It contains an embedded Jetty server which will run the application’s war file which got created from the modules shared, server and webapp.

  • If still running from the development mode stop the JavaFX GUI now.

  • Open a terminal, cd into webapp and invoke:

./gradlew --info :appRun
Note
This will start an embedded jetty container (via the gradle plugin gretty). On the first run it will take a little longer as usual to start jetty since it’s dependencies need to be downloaded.
  • Open a second terminal, cd into client and invoke:

./gradlew :run

Note that the client and the server communication messages now appear separately in the client respectively server terminal.

HTML5 Frontend

If you would like to develop a HTML5 frontend the project template comes with an example in form of a JSP: webapp/src/main/webapp/hellodolphin.jsp which you can use as a start. To try it out:

  • start jetty as described in the remote mode :

  ./gradlew :appRun

This will show a page which looks very similar to the JavaFX GUI we already saw:

hello dolphin html5

IDEs

IntelliJ IDEA

IntelliJ IDEA users simply choose File/Import Project from the menu bar and then select hello_dolphin/combined/build.gradle. This will open the Import Project from Gradle dialog. Having confirmed the dialog you are ready to go. To run the application open ApplicationInMemoryStarter from combined/src/main/java... and run it. This corresponds to ./gradlew :run which we performed earlier for development mode.

Netbeans 8

I am an IntelliJ IDEA user and unfortunately could not quite figure out how to import the gradle based project into Netbeans. If anyone has some hints on how to do it properly please let me know. This is what I found so far: Netbeans 8 users need to install the Gradle Support plugin via Tools/Plugins. After restarting the IDE simply choose File/Open Project from the menu bar and then select the hello_dolphin folder which already carries the gradle icon. At this point unfortunately Netbeans complains that it cannot find the :shared module although it works on the commandline and in IntelliJ IDEA.

Eclipse

Make sure the Eclipse plugin Buildship is installed which makes the gradle integration into Eclipse very easy. See https://projects.eclipse.org/projects/tools.buildship for more details.

Note that if you are not using JDK 8 but JDK 7 you might need to add the JavaFX jar JAVA_HOME/jre/lib/jfxrt.jar to your classpath.

Conclusion

Now you have a running Open-Dolphin project setup which you can use to develop your application. For more information have a look at the Open-Dolphin webpage and the Jumpstart tutorial at DolphinJumpStart

Additional Information

Complete Java setup
lazybones create dolphin-client-javafx-java client
lazybones create dolphin-combined-java combined
lazybones create dolphin-server-java server
lazybones create dolphin-shared-java shared
lazybones create dolphin-server-webapp webapp
Complete Groovy setup
lazybones create dolphin-client-javafx-groovy client
lazybones create dolphin-combined-groovy combined
lazybones create dolphin-server-groovy server
lazybones create dolphin-shared-groovy shared
lazybones create dolphin-server-webapp webapp

Using a groovy script it becomes even easier. Copy the following into a file called j.groovy adjust group, version, and pkg and then call invoke it with: groovy j.groovy:

j.groovy (for a Java setup)
def group = 'com.mycompany'
def version = '1.0.0-SNAPSHOT'
def pkg = "${group}"

Map map = [
  'client'  : 'dolphin-client-javafx-java',
  'combined': 'dolphin-combined-java',
  'server'  : 'dolphin-server-java',
  'shared'  : 'dolphin-shared-java',
  'webapp'  : 'dolphin-server-webapp',
]

map.each { k, v ->
  "lazybones create -Pgroup=${group} -Pversion=${version} -Ppackage=${pkg} $v $k".execute()
}

And here comes the equivalent for a groovy setup:

j.groovy (for a Groovy setup)
def group = 'com.mycompany'
def version = '1.0.0-SNAPSHOT'
def pkg = "${group}"

Map map = [
  'client'  : 'dolphin-client-javafx-groovy',
  'combined': 'dolphin-combined-groovy',
  'server'  : 'dolphin-server-groovy',
  'shared'  : 'dolphin-shared-groovy',
  'webapp'  : 'dolphin-server-webapp',
]

map.each { k, v ->
  "lazybones create -Pgroup=${group} -Pversion=${version} -Ppackage=${pkg} $v $k".execute()
}

Gradle Project Structure

To tie the individual modules together to form an application we use gradle’s multi project build facility but adapted it a bit so that the root project does not have to be located in the top level folder but can be inside one of the modules like combined or client. Have a look at the combined/settings.gradle and combined/build.gradle for example to see how they depend on each other. If necessery you can then adjust the dependencies according to your needs.

Note that this way it is possible to have the individual project folders in any location you like. Technically each project is a multi module project and you can import each of them into your IDE where the dependent projects appear as well.

Troubleshooting

In case something went wrong during the application of the template setting the loglevel might help:

lazybones --logLevel=FINE ...

Documentation of other Open-Dolphin Templates