Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

Tutorial Plugin

Michael Barth edited this page Jul 20, 2017 · 4 revisions

The example

The first example is located at Example1. It contains one plugin with the name "MonkeyPlugin". This plugin adds a button to the button bar of Eclipse and pops up a hello box when clicking. Building this with Eclipse is easy. With gradle it is a bit more difficulty.

Build and execute with Eclipse

  1. Download example from the URL above.
  2. Start eclipse (tested with Eclipse Neon.2) and select a workspace.
  3. Import an existing project and point to the MonkeyPlugin at the downloaded example.
  4. Open project and open plugin.xml.
  5. Select the 'Overview' rider in the editor window and click on 'Launch an Eclipse Application' on the right side at group 'Testing'.
  6. A new Eclipse instance started and the 'MONKEYWORKS' Button appears.

Build and deploy with gradle

Prerequisites

A build needs a gradle tool. We prefer 3.3 or higher. A gradle wrapper is contained in the root folder of BuildMonkey or install a local gradle from Gradle Install.

Build

Go to the folder example/example1 and type gradle clean build (if using installed gradle) or ../../gradlew clean build (using the gradle wrapper).

The build starts and you will see a lot of console output. This will be explained below. The results can be found at the example/example1/build folder and at example/example1/MonkeyPlugin/build. The content will explained below too.

Deploy

Go to the folder example/example1 and type gradle publishP2 (if using installed gradle) or ../../gradlew publishP2 (using the gradle wrapper). This will create a new P2 repository containing a feature with the plugin and the plugin itself.

Install at Eclipse

  1. Open Eclipse and select 'Install New Software' from the 'Help' menu.
  2. Add a new update site by clicking the 'Add' button in the right upper area.
  3. Give the site a name like 'MonkeyPlugin' and press the 'Local' button. Select the example/example1/build/monkey-repository as 'Location'.
  4. If you dont see an item, uncheck the 'Group items by catagory' in the down area. Select the 'Example Plugin' and press 'Next'.
  5. At the next dialog press 'Finish'. The installation process starts. After calculating all dependencies a Security Waring occurs, that this plugin is untrusted. Continue installation by pressing 'OK'.
  6. Eclipse must be restarted and asks for this. Acknowledge this and press the MONKEYWORKS after Eclipse is started.

The build process

build.gradle

The build process is controlled by the build.gradle file. It has 4 main sections

buildscript

The buildscript instruction defines plugins or dependencies and where to find it for the execution of the gradle build process. So here the BuildMonkey gradle plugins are addressed.

buildscript {
    repositories {
        // Uncomment for local deployment of built plugins
        // mavenLocal()

        // The BuildMonkey plugins are published here
        maven {
            url "https://plugins.gradle.org/m2/"
        }

        // Default repositories for all the maven dependencies of this world
        mavenCentral()
        jcenter()
    }

    // Get BuildMonkey plugins
    dependencies {
        classpath "de.monkeyworks.buildmonkey:gradle.p2:0.4.2"
        classpath "de.monkeyworks.buildmonkey:gradle.p2publish:0.4.12"
        classpath "de.monkeyworks.buildmonkey:gradle.mavenize:0.4.1"
        classpath "de.monkeyworks.buildmonkey:gradle.dependency:0.4.11"
        classpath "de.monkeyworks.buildmonkey:gradle.projectsetup:0.4.1"
    }
}