Gradle Equinox Plugin – Part 1: How to create the project skeleton


I decided to start a new  Gradle plugin project which will ease the creation process of OSGi Equinox container during the development.

In this post, I’ll try to describe how I’m developing Gradle plugins and how I’m using IntelliJ IDEA as IDE. I choose IntelliJ , because in my opinion, IDEA  has better support for Groovy and Gradle than Eclipse (including the available plugins at the marketplace).

As first step, I created a new repository at Github and skeleton project on the file system:


The file structure has:

  • a build.gradle file – the main build file
  • a properties file under src/main/resources/META-INF/gradle-plugins named – this file represents the name of the plugin. It is needed to apply the plugin with string constant in the builds after the ‘apply plugin:’ statement. The name of the file represents the string which MUST be used. If such file not present, the full plugin class name must be used. In this case to apply the plugin, the build script has to contain apply plugin: ‘name.mazgalov.equinox’. The domain  notation is used due to restrictions for publishing of custom plugins.  For more information how to publish, visit

I prefer the Gradle Wrapper for the builds startup, because it doesn’t need a Gradle installation, you need just to start a script and the required Gradle version will be downloaded and executed. It is OS independenct as well, the wrapper can be started on Linux and Windows with gradlew. For more information:

To create the Gradle Wrapper files for the project, just a simple command must be executed:

gradle wrapper

And yes, for the creation of the wrapper files will be need an existing Gradle instance.

>gradle wrapper


The result:


Now the project is ready to be imported in IntelliJ IDEA IDE as Gradle project:


I’m using the default options. As you see if a Wrapper is available, the IDE prefers to use it. IDEA builds the project and imports it. At first look nothing will be changed, but the valuable is the new available toolbar:


When you open it, the full sized toolbar will appear:


The toolbar menu has a refresh icon which rebuilds the Gradle project. This is required when a change is available like adding a new compile/runtime dependency, it will add it to the classpath. Also when a new project is being added in multi-project build, it will appear as module in the IDE.

Now let’s add a Groovy class file:


The content of the file is only the class declaration:

class EquinoxPlugin {


As next step, the build must be configured to recognize the Groovy classes and the Gradle API must be added to the compilation classpath (in any case this is a Gradle plugin). To achieve that, the following code must be added to the build,gradle file:

apply plugin: 'groovy'

dependencies {
    compile gradleApi()

Now the project must be rebuilt (with the refresh icon 🙂 ) and the magic happens:


IntelliJ recognizes the source Groovy files, the resources and the Gradle API is available at the compilation classpath.

All required files from the basic structure are available, but first the EquinoxPlugin class must be moved to proper package, I do not want to use the default one.



This is the end of the first part. I explained how to create a project from the scratch with the IntelliJ IDEA (Community Edition – Free) IDE. It is fast and easily can continue with the development of the plugin. I think that similar actions  will be required with the Eclipse IDE and the available plugins at the marketplace.

I hope that this is useful. Enjoy 🙂

One thought on “Gradle Equinox Plugin – Part 1: How to create the project skeleton

Leave a Reply

Your email address will not be published. Required fields are marked *