Eclipse plugin with Maven dependencies for third party libraries

maven-dependency-plugin
how to add external jars in eclipse plugin
eclipse install plugin manually
tycho maven plugin eclipse
eclipse plugin development

I am converting Subclipse to build with Eclipse Tycho and Maven.

Subclipse depends on a few third party JAR files that are not Eclipse plugins so do not exist in any p2 repository. Currently, I just include these in a lib folder within the plugin.

Since these JAR files do exist in Maven, I was hoping that by converting the plugins to build with Maven I could use Maven dependencies. IOW, the plugin would have a pom.xml where I used Maven dependencies to grab and include the third party jar's that have to be included in the plugin. Basically, it would just automate having to refresh what I include in the lib folder of the plugin.

Is this possible? I tried doing what I said above by when I build, I saw no sign that Maven/Tycho was trying to fetch the dependencies. I imagine it is because when the packaging is eclipse-plugin it looks solely at the Eclipse configuration files for the dependency information.

Thanks

To add plain (without OSGi metadata) jar files into your folder at biuild time, you can specify an <execution> of the maven-dependency-plugin to fetch them. However it will require to update your MANIFEST.MF Bundle-Classpath directive whenever a version changes.

It's usually better to hunt for OSGi-able jars or to make an extra effort to package existing libs as OSGi bundles/p2 artifacts like Eclipse Orbit or JBoss Tools Locus do.

[tycho-user] Working with 3rd party dependencies, [tycho-user] Working with 3rd party dependencies only: 1. get the library using maven dependency plugin 2. in eclipse create a new plugin I ended up using twice the maven dependency plugin to unpack both the artifact's  So you decided to use a third party library to assist you instead of writing raw Java code and do all the hard work yourself. One of the most popular and easy to use Java libraries out there for

Tycho/How Tos/Dependency on pom-first artifacts, 4.2 Pom-first dependencies of manifest-first projects are not fully transitive with packaging=jar that uses maven-bundle-plugin:manifest goal to generate thirdparty library available from maven repository in an OSGi bundle. If third party libraries need to be included in the generated application.xml, the 'includeInApplicationXml' flag could be used. This flag works only for jar modules since they define third party libraries packaged within the EAR.

Just adding the plugin to pom dependencies and including the entry <pomDependencies>consider</pomDependencies> in the configuration of target-platform-configuration makes it work.

<plugins>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho.version}</version>
        <configuration>
            <!-- The configuration to make tycho consider the maven dependencies -->
            <pomDependencies>consider</pomDependencies> 
            <!-- other configurations -->
        </configuartion>
    </plugin>
    <!-- other plugins-->
</plugins>
<dependencies>
    <!-- An example third-party bundle (plugin) present in maven repository-->
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.gogo.shell</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>

Reference link here.

Maven, Eclipse Tycho and 3rd-party dependencies • Flames of Code, Maven, Eclipse Tycho and 3rd-party dependencies Creating a single standalone Eclipse RCP that builds with Maven using Tycho plugin, as for By this time your local repository will have two variants of the library  I'm developing an eclipse plugin and I'm in the process of converting it to Maven project. I used "Configure->Convert to Maven project" option and wrote the pom.xml file with the appropriate dependencies and a reference to tycho and to maven plugin.

How to create Eclipse plug-ins from Java libraries (JAR files), Integrating external jars / third party libraries. 3.1. Creating a plug-in Convert JAR files to OSGi bundles with the p2-maven-plugin. 7. Exercise - Convert Find the JAR via an existing Eclipse repository, e.g. Orbit. Use Maven  Using Maven to Manage Library Dependencies in Eclipse without m2eclipse Eclipse has a built-in function managing library dependencies. By the usual practice, for each project (as the term means in Eclipse), one downloads the libraries (i.e. jar files) and places them under a directory name lib under the project base directory, and adds the jar files onto the project’s Build Path.

Using maven to handle Eclipse plug-in dependencies, That is, a plugin can list its dependencies as a list of other plugins. a jar from a 3rd party library's website, or maven for that matter, and use it as a plugin. Similarly, Eclipse can not install libraries from maven repositories. Tycho just resolves dependencies via Eclipse plug-ins, and it cannot leverage normal Maven dependency resolution directly to pull in a bunch of JARs. If all of your dependencies are already plug-ins, you're fine. If not, you may have to use the workaround above to package a set of libraries for your plug-ins to use.

Maven and Eclipse · ftsrg/cheat-sheets Wiki · GitHub, A Maven project is defined by its Project Object Model file ( pom.xml ). A Maven artifact is It's important to note that Eclipse plug-ins are also OSGi bundles. Equinox is an Using 3rd party libraries with Eclipse/Tycho. Project Transitive Dependencies The following is a list of transitive dependencies for this project. Transitive dependencies are the dependencies of the project dependencies.

Comments
  • I'm this case I maintain the third party libraries and publish the artifacts. Is it easy to have Maven also build an OSGI artifact for each jar and publish at same time? Any pointers?
  • You have to use the maven-bundle-plugin so it will generate a MANIFEST.MF for you according to packages you consume. Then you can consume the Maven OSGi bundles in Tycho as explained in wiki.eclipse.org/Tycho/…