How to develop DukeScript applications with Eclipse

I’ve been asked a couple of times, if you can develop DukeScript applications with Eclipse. And while we encourage people to try NetBeans, we don’t want to exclude Eclipse users. So I decided to give it a try. I have an Eclipse installation on my machine from writing a book on JavaFX, so I launched it, checked for updates and created a new project.

Prerequisites: Eclipse Luna (or better) with m2eclipse

Here are the steps I took:

1.) In the Java perspective select File -> New -> Project…

2.) A dialog pops up, select Maven -> Maven project, click “Next”:

3.) “Create a simple project (skip archetype selection)” should obviously not be ticked on the next screen, click “Next”

4.) On the next screen you’ll be asked to select an archetype. Type “dukescript” in the filter text field. This should give you a list of publicly available archetypes. Choose “knockout4j-archetype” (that’s the simple one).

4.a) If you don’t have anyting in the list, chances are that you don’t have the Maven Central Index. In that case click the “add archetype” button and register “”, then try step 4 again.

5.) On the next screen, choose a group id and archetype id (e.g. “com.mycompany” and “demo”). Also in the properties section remove the “target/” prefix on the values of “iospath”, “androidpath”, and webpath. This will create subprojects for ios, android and browser. You can leave nbpath untouched unless you really want to develop a NetBeans plugin :-). Click “finish”:

6.) The project opens. In Package Explorer right-click the “demo-pom” project and select “Run as” -> “Maven install”. The build should succeed, as you can see from the console output:

7.) Now go to the project named like the archetype id in step 5 (“demo” in my case). Right-click and choose “Run as” -> “Maven build”.

8.) This should open a dialog. In the field “Goals” enter “process-classes exec:exec” and confirm. The project should be launched now.

OK, now that we’ve finished the most basic integration, being able to build and run, let’s go for some closer integration. DukeScript makes use of AnnotationProcessors to create the ViewModel. I’ve talked to a lot of Eclipse users about this topic and with their approval I dare to say here that Eclipse support for AnnotationProcessors really sucks. As a result when you open the Eclipse will complain that it doesn’t know the “Data” class. Fortunately there is a plugin (on the good side: in Eclipse there always is a plugin ;-)). called m2eapt which aims at providing automatic Annotation Processing configuration in Eclipse based on your pom.

1.) Install it via Window > Preferences > Maven > Discovery > Open Catalog.

2.) Go to Window > Preferences > Maven > Annotation Processing and select “Experimental: Delegate Annotation Processing to maven plugin”

3.) Now go back to your DataModel class and check if the complaints have go away. You should now be able to e.g. add a new Property to the @Model like this:

@Model(className = "Data", targetId="", properties = {
    @Property(name = "message", type = String.class),
    @Property(name = "rotating", type = boolean.class),
    @Property(name= "test", type = String.class)
final class DataModel {
// more code...

Eclipse will allow the AnnotationProcessor to do its work and code completion will show you setters and getters for this property:

That’s it for now. You should now be able to run and develop DukeScript applications using Eclipse.

This blog post is work in progress, and I’d lik eto add it to our getting started guide, once Eclipse users report they’re happy with it (or don’t complain anymore). If you run into problems let me know. I’ll also ask some Eclipse users to give me their input. There’s an active discussion of bugs and problems when running with Eclipse on stackoverfow. It also has some hints when you run into problems.