Automated Eclipse Project creation and deployment (for JavaFX)


Our believe is that the best runtime techology is meaningless without proper tooling support so if you’ve ever developed an Eclipse Plug-in to allow easier adoption of a runtime technology you might have faced the same problem I’m facing with e(fx)clipse.

The runtime platform I deeply care about is e(fx)clipsee4 on JavaFX and we are providing beside specialized editors for CSS and FXML, a set of wizards who allow people to bootstrap a complete e4 on JavaFX project setup but we don’t stop at the project stub creation like the SWT tooling currently does but generate a some more projects and artifacts.

Whenever I write a wizard who does such a project setup I’m getting tired of how complex and not understandable my code looks like although all it does is to setup a folder structure and generate the content of some files (e.g. MANIFEST.MF, plugin.xml , … ).

The last time I wrote a wizard like this it drove me so crazy that I decided that something has to done to make the process of generating intelligent code structures (I know there is this PDE-Template stuff but frankly I really hate that and want something much more dynamic) more streamlined.

The first thing I did was to develop a Meta-Model for the most important resource elements.

RobotTask

BundleProject

So one can use it programmatically like this:

// ... wizard setup
public boolean performFinish() {
  Bundle b = FrameworkUtil.getBundle(getClass());
  BundleContext ctx = b.getBundleContext();
  ServiceReference<RRobot> ref = ctx.getServiceReference(RRobot.class);
  final RRobot r = ctx.getService(ref);

  final RobotTask task = TaskFactory.eINSTANCE.createRobotTask();
  task.getProjects().add(
    createBundleProject(
      projectPage.getProjectName(),
      contentPage.getData().getId(),
      ((AbstractFieldData)contentPage.getData()).getExecutionEnvironment(),
      contentPage.getData().getVersion(),
      configPage.getProductName(),
      configPage.isMavenTycho()
    )
  );

  // the rest of the setup

  WorkspaceModifyOperation w = new WorkspaceModifyOperation() {

    @Override
    protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
      r.executeTask(monitor, task, new HashMap<String, Object>());
    }
  };
			
  getContainer().run(true, true,w);
}

So far so good but even this code it gets really noisy and hard to understand. To reduce noise and describe the problem domain in a concise format, Xtext – a framework to develop DSLs – is a perfect match. This short screencast shows the DSL in action.

The first part of the video shows the DSL and Resource-Robot in action but the 2nd part is not less interesting for the people developing JavaFX application. The roboter generates a project structure including all artifacts needed to package up the final application for submission e.g. to the Mac App Store in future.

The DSL and robot are part of the e(fx)clipse project but they can be installed on theirown in any Eclipse IDE >= 3.7.2.

This entry was posted in e(fx)clipse. Bookmark the permalink.

2 Responses to Automated Eclipse Project creation and deployment (for JavaFX)

  1. Pingback: Java desktop links of the week, December 17 | Jonathan Giles

  2. Pingback: JavaFX links of the week, December 17 // JavaFX News, Demos and Insight // FX Experience

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.