Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building an Eclipse plugin using Maven

I am trying to configure Maven to build an Eclipse application (Eclipse plugin packaged with all of the Eclipse EXEs etc).

I have already Mavenised dozens of dependencies of the project and deployed them to our internal Nexus (OSS) server. I have also installed the Nexus P2 Repository Plugin and the P2 Bridge Plugin (2.6.3-01) and the Nexus Unzip Plugin (0.12.0). I can browse to the .meta/p2 folder of our group repository, but it is currently empty.

This should be a lot simpler than it currently appears to be. I'm targeting Eclipse 3.4.2 (Ganymede) on Windows. If it makes any difference, we actually deploy our application packaged as a stripped-down/customised Eclipse installation.

eclipse-repository

When I run maven against a pom with <packaging>eclipse-repository</packaging> I get the following error:

[ERROR]   Missing requirement: MyApp 0.0.0 requires 
          'org.eclipse.equinox.executable.feature.group 0.0.0' 
          but it could not be found

...where do I get that from, and how do I add it to Nexus?

When I run maven against a pom with <packaging>eclipse-plugin</packaging> I get the following error:

[ERROR]   Missing requirement: MyApp 0.0.0 requires 
          'bundle org.eclipse.ui 0.0.0'
          but it could not be found

...but I found the following directories on my local file system (suspect itp-04-rcp generated the first one):

D:\maven\repository\p2\osgi\bundle\org.eclipse.ui\3.6.2.M20110203-1100
D:\maven\repository\p2\osgi\bundle\org.eclipse.ui\3.7.0.v20110928-1505

Tycho POM-First artifacts

I've also tried the pom-first-dependencies and manifest-first-dependency combo: http://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts

I don't understand how this works - I can build itp02 from Git. I can see that it builds two bundles:

+---------------------+---------------------+--------------------------------------+
| artifactId          | Bundle-Name         | Bundle-SymbolicName                  |
+---------------------+---------------------+--------------------------------------+
| pomfirst-bundle     | pomfirst-bundle     | tycho.demo.itp02.pomfirst-bundle     |
| pomfirst-thirdparty | pomfirst-thirdparty | tycho.demo.itp02.pomfirst-thirdparty |
+---------------------+---------------------+--------------------------------------+

...but how does build02 pick these up? The only bit that seems relevant is:

Import-Package: tycho.demo.itp02.pomfirst

...that doesn't have anything to do with either of the Bundle-Names.

Felix Maven Bundle Plugin

I tried the Felix maven-bundle-plugin. I include all of my regular maven dependencies in a pom with <packaging>bundle</packaging>.

  • mvn deploy creates something at /nexus/content/repositories/snapshots/.meta/p2/plugins. I can download the jar via a browser, but all of the dependency jars are named "artifact-vresion" rather than "artifact_version" - is that right?

  • mvn bundle:bundleall creates an OSGI bundle for each of the transitive dependencies, but I'm not sure what to do with them from here.

  • mvn bundle:deploy refuses to do anything unless I specify -DremoteOBR and probably a few other parameters which I don't really understand.

like image 245
Nicholas Albion Avatar asked Nov 27 '13 06:11

Nicholas Albion


People also ask

What is Maven Eclipse plugin?

The Maven Eclipse Plugin is used to generate Eclipse IDE files (*. classpath, *. project, *. wtpmodules and the . settings folder) for use with a project.

How do I run a Maven build in Eclipse?

Building and Running the Maven Project in Eclipse To run the maven project, select it and go to “Run As > Java Application”. In the next window, select the main class to execute. In this case, select the App class and click on the Ok button. You will see the “Hello World” output in the Console window.

Do we need Maven plugin for Eclipse?

By "use install a Maven plugin and use it" I am sure you are looking for a Eclipse plugin that will perform Maven functions within the IDE. If so, M2E is a good choice. You will find a lot of help within the Eclipse installation once you install M2E.

How to use Maven in Eclipse to build a project?

You can see that Eclipse has added Maven dependencies to java build path. Now, it is time to build this project using maven capability of eclipse. Right Click on consumerBanking project to open context menu. Select Run as option. Then maven package option. Maven will start building the project.

How to build Eclipse plugin using Maven 2 with OSGi?

You must add them as OSGi dependencies in the manifest. The dependencies are injected into the in-memory representation of the POM during the build. From now on you simply develop and test your Eclipse plugin in PDE as per usual. When building the plugin using Maven 2, the normal build lifecycle comes into effect.

What is a Maven plugin?

In the case of Maven 2, plugins are responsible for things like compilation, testing, code instrumentation (e.g. for code coverage), reporting and packaging.

How to update Maven dependencies in Eclipse IDE?

You can update maven dependencies with IDE. You can Launch Maven builds from within Eclipse. It does the dependency management for Eclipse build path based on Maven's pom.xml. It resolves Maven dependencies from the Eclipse workspace without installing to local Maven repository (requires dependency project be in same workspace).


2 Answers

The 'org.eclipse.equinox.executable.feature.groug' seems to be necessary if you build an eclipse product which includes the native launchers ("include laucher" property set to true in product configuration). Try to add the feature to your platform definition (e.g. copy from eclipse p2 repo or your running eclipse IDE).

See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=407272

Regards, Paolo

like image 155
Paolo Avatar answered Nov 07 '22 20:11

Paolo


To solve the Problem concerning the missing dependencies:

[ERROR]   Missing requirement: MyApp 0.0.0 requires 
          'bundle org.eclipse.ui 0.0.0'
          but it could not be found

seems that your Feature/Plugin MyApp requires to download the org.eclipse.ui Plug-in before it can be installed.

You should check your settings from your configuration-pom like this:

 <properties>
  <tycho.version>0.25.0</tycho.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <repository.url>http://download.eclipse.org/releases/neon</repository.url>
 </properties>

 <repositories>
  <repository>
   <id>NeonRepository</id>
   <url>${repository.url}</url>
   <layout>p2</layout>
  </repository>

if you have set up your self-hosted p2 repository, make sure that the page is correctly build. You can check this if you select(in eclipse) Help -> Install New Software. Eclipse should show the provided parts. If nothing is shown, even if you have deselected every checkbox, you should check your p2-repository. It should contain the "features" and "plugins" container as well as the artifacts.jar and content.jar. If you have only the two folders, you should run

eclipse -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
 -metadataRepository file:/<some location>/repository
 -artifactRepository file:/<some location>/repository
 -source /<location with a site.xml>
 -configs gtk.linux.x86
 -compress
 -publishArtifacts

in a CLI/Shell. For more Information check the eclipse documentation.

like image 42
L12 Avatar answered Nov 07 '22 20:11

L12