URLs

Do you want to improve this page? Please edit it on GitHub.

Description

This repository contains some experiments I do with Eclipse JDT.

  • java-formatter

  • programcreek examples

    • programcreek-osgi

    • programcreek-standalone

java-formatter

Usage of the JDT from a simple Java main method (Java SE only, no OSGi, no maven tycho). All dependencies are fetched from Maven Central. See blog post: Use the Eclipse Java Development Tools in a Java SE application

Source code is available is in the java-formatter folder.

Programcreek examples

The two projects programcreek-osgi and programcreek-standalone contain unit-tests based on examples from the articles of the Eclipse JDT Tutorials proposed by the site www.programcreek.com.

Maven can be used to run the unit-test and to see the JDT code in action.

mvn verify

The code is spitted into two sub-projects, depending if the JDT code used in the example needs a Workspace (that requires an OSGi runtime) or not.

programcreek-osgi

The JDT examples presented in this project use operations (search index, Built-in AST Rewrite, …) that require a Workspace.

A Workspace can be created programmatically and doesn’t need to fire up the Eclipse UI, but this operation requires an OSGi runtime. The services provided by org.eclipse.core.runtime have to be available (the Workspace code in org.eclipse.core.resources rely on those).

The Workspace location is driven by the osgi.instance.area property.

To run the tests inside an OSGi container, the proposed solution relies on the maven bnd plugins. This makes the pom file more complex than for plain java projects.

To execute the tests in an IDE, be sure to run them inside an OSGi container (in the same way the maven build is doing it). If you are using Eclipse IDE, consider installing bndtools. IntelliJ IDEA Ultimate seems also to have support for OSGi and bnd.

Source code is available is in the programcreek-osgi folder.

programcreek-standalone

The JDT examples presented in this project are not relying on a Workspace. They can be executed in a traditional Java SE application. A simple main(String args[]) method could be used instead of the unit-tests.

Source code is available is in the programcreek-standalone folder.

Get in touch

You can also contact me on Twitter: @j2r2b

License