سؤال

I am trying to create a self-contained executable jar and I am using Eclipse Indigo and Maven. In my code I am using a number of classes from eclipse plugin jars, which in the IDE I could just add (said jars) to the build path to have their classes available. However, in order to create the self-contained executable jar, I need to add those jars as maven dependencies (in the pom.xml).

Is it possible to add those eclipse-plugin jars (also known as "Eclipse bundles" or "OSGi bundles") as dependencies in Maven?

Examples of eclipse-plugin jars I am using:

org.eclipse.emf.common_2.6.0.v20100914-1218.jar  
org.eclipse.emf.ecore.xmi_2.5.0.v20100521-1846.jar  
org.talend.dataquality_5.4.1.r111943.jar  

Thanks in advance

هل كانت مفيدة؟

المحلول

It depends, but in general yes. OSGi bundles are normal JAR files, so you can add them to your project as any other JAR file. Just write the according Maven dependency, let's say:

<dependency>
    <groupId>your.group.id</groupId>
    <artifactId>yourArtifact</artifactId>
    <version>1.0.0</version>
</dependency>

If the JAR file exists in the public central Maven repository, this is already enough (BTW: have you looked for your bundles there?). If not, you must either add the repository where the bundles are located or you have to add the JAR to your locale Maven repository one on your laptop:

mvn install:install-file \
            -Dfile=<path-to-file> \
            -DgroupId=<group-id> \
            -DartifactId=<artifact-id> \
            -Dversion=<version> \
            -Dpackaging=<packaging> \
            -DgeneratePom=true

That's all. But: Are you developing an OSGi plugin? Or an OSGi application? If yes, it could be a bit more difficult since OSGi and Maven will not work so well together. In this case, you should provide some more information and take a look at BND tools.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top