title: Using Kotlin to develope an Eclipse plugin
body: <p>Is it possible to use Kotlin to develop a plugin for Eclipse? The project I'm working on uses Maven Tycho and OSGi.</p>
  
  <p>To prevent misunderstandings, this is not about the <a href="https://marketplace.eclipse.org/content/kotlin-plugin-eclipse" rel="noreferrer">Kotlin Eclipse Plugin</a>, but about developing a custom plugin using the Kotlin language.</p>
  
  <p>I added a dependency to the Kotlin stdlib in my <code>pom.xml</code>, but that doesn't seem to be enough just yet.</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;
      &lt;artifactId&gt;kotlin-stdlib&lt;/artifactId&gt;
      &lt;version&gt;${kotlin.version}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Since there are a lot of potentially relevant files (<code>MANIFEST.MF</code>, <code>pom.xml</code>, ...) I thought it might be easier to just link the GitHub repo: <a href="https://github.com/Tornac/slr-toolkit/tree/kotlin/plugins/de.tudresden.slr.questionnaire" rel="noreferrer">https://github.com/Tornac/slr-toolkit/tree/kotlin/plugins/de.tudresden.slr.questionnaire</a>.</p>
  
  <p>Only the code in <code>plugins/de.tudresden.slr.questionnaire</code> is mine, and I only care about adding Kotlin code to that particular plugin. My attempt to integrate Kotlin can be found on the <code>kotlin</code> branch. All the changes can be found in this commit: <a href="https://github.com/Tornac/slr-toolkit/commit/18f8f6de3a35644ef1ae595024667f4bdd10b604" rel="noreferrer">https://github.com/Tornac/slr-toolkit/commit/18f8f6de3a35644ef1ae595024667f4bdd10b604</a></p>
  
  <p>During compilation, the following error is briefly shown:
  <code>ERROR: Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library (5, 14)</code>.</p>
  
  <p>Kotlin:</p>
  
  <pre><code>// file: KtTest
  package de.tudresden.slr.questionnaire
  
  class KtTest {
      fun doStuff() {
          System.out.println("hello world, this is kt!");
      }
  }
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>// trying to call KtTest's method from Java
  new KtTest().doStuff();
  </code></pre>
  
  <p>Stacktrace caused by calling doStuff():</p>
  
  <pre><code>java.lang.NoClassDefFoundError: de/tudresden/slr/questionnaire/KtTest
      at de.tudresden.slr.questionnaire.QuestionnaireView$1.mouseDown(QuestionnaireView.java:78)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:192)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
      at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
      at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      at de.tudresden.slr.app.Application.start(Application.java:20)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
      at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
  Caused by: java.lang.ClassNotFoundException: de.tudresden.slr.questionnaire.KtTest cannot be found by de.tudresden.slr.questionnaire_0.2.6.qualifier
      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
      at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      ... 29 more
  </code></pre>