Eclipse Equinox, how to configure auto load the bundles in plugin folder
Asked Answered
I

3

8

I've followed http://www.eclipse.org/equinox/documents/quickstart-framework.php but it seems to be old and not valid.

There is no such bundles as described org.eclipse.update.configurator_3.2.100.jar

I tried with the org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503, but doesn't work.

Anyone can tell me how to make Equinox auto load the bundles inside plugins folder?

Iou answered 2/3, 2011 at 18:9 Comment(0)
D
14

Simplest approach would be to use Apache Felix File Install. It works just fine with Equinox, you only need to put File Install configuration parameters into the configuration/config.ini. Note though that if you launch Equinox via launcher JAR or via binary, the working directory would be parent of configuration/ or plugins/ directory.

Excerpt from our project config.ini:

# Start File Install itself
osgi.bundles=reference\:file\:org.apache.felix.fileinstall_3.1.0.jar@1\:start
# The name of the directory to watch
felix.fileinstall.dir=./plugins
# A regular expression to be used to filter file names
# We have all bundles in plugins/ directory, this regexp
# forbids monitoring bundles that are started via osgi.bundles property
felix.fileinstall.filter=^(?!org.apache.felix.fileinstall|org.eclipse.osgi).*
# Determines if File Install waits felix.fileinstall.poll milliseconds before doing an initial scan or not.
felix.fileinstall.noInitialDelay=true
# Not sure why we have this...
felix.fileinstall.start.level=2

Other possible solution would be to use Eclipse P2. It is much more advanced and powerful, though I find it quite difficult to use.

Good thing is that if your application is agnostic to the way bundles are provisioned (and it should be this way), you can always change your mind later.

Deuteronomy answered 2/3, 2011 at 18:40 Comment(4)
I would like to use Apache Felix File Install, but how can I put in Eclipse config.ini the "felix.fileinstall.dir" configuration? I tried felix.fileinstall.dir=..\plugins\ without sucess... how can I put this system property in a config file?Iou
I'm using now the File Install with jvm parameters to system properties. It's like -Dparemter=value.. It's working now.Iou
Have you tried felix.fileinstall.dir=./plugins ? If you start Equinox via the launcher jar/binary, the working directory would be parent of the configuration/ directory. Besides that, should work fine.Deuteronomy
I'm just getting some classpath erros now... The Activator class is not finding the JFrame main class. Strange that both are in the same bundle, and in Eclipse it works. =\Iou
D
0

Here is the fragment from my automated eclipse installer written in ant.

This installs all features from the custom update site. The code is 'as is', but I sure would have liked to have something like this to guide me when I wrote it.

This script also uses antcontrib extension to ant. Antcontrib tasks are have 'ac:' namespace prefix

Hope this helps.

    <property name="real.eclipse.home" location="${eclipse.home}/eclipse"/>

    <property file="${real.eclipse.home}/configuration/config.ini" prefix="ECLIPSE_CONFIG"/>

    <property name="eclipse-plugins.dir" location="${real.eclipse.home}/plugins"/>

    <path id="newest.equinox.launcher-library.path.id">
      <dirset dir="${eclipse-plugins.dir}">
        <include name="org.eclipse.equinox.launcher.*"/>
      </dirset>
    </path>

    <property name="equinox.launcher-library.full-path" refid="newest.equinox.launcher-library.path.id"/>

    <basename property="equinox.launcher-library.dir" file="${equinox.launcher-library.full-path}"/>

    <echo message="equinox.launcher-library.dir='${equinox.launcher-library.dir}'"/>

    <path id="newest.equinox.launcher.path.id">
      <fileset dir="${eclipse-plugins.dir}">
        <include name="org.eclipse.equinox.launcher_*.jar"/>
      </fileset>
    </path>

    <property name="equinox.launcher.jar" refid="newest.equinox.launcher.path.id"/>
    <basename property="equinox.launcher.jar.basename" file="${equinox.launcher.jar}"/>

    <echo message="equinox.launcher.jar='${equinox.launcher.jar}'"/>

    <java jar="${equinox.launcher.jar}"
      fork="true"
      failonerror="true"
    >
      <arg value="-consolelog"/>
      <arg value="-application"/>
      <arg value="org.eclipse.equinox.p2.director"/>
      <arg value="-repository"/>
      <arg value="http://${repository.server}/custom-update-site"/>
      <arg value="-list"/>
      <redirector
        logError="true"
        outputproperty="features.list"
      >
        <outputfilterchain>
          <linecontains>
            <contains value="feature.group="/>
          </linecontains>
          <replaceregex pattern="(.*feature\.group)=.*$" replace="\1"/>
        </outputfilterchain>
      </redirector>
    </java>

    <ac:for list="${features.list}" delimiter="${line.separator}" trim="true" param="feature">
      <sequential>
        <ac:if>
          <isset property="feature.comma.list"/>
          <then>
            <ac:var name="feature.comma.list" value="${feature.comma.list},@{feature}"/>
          </then>
          <else>
            <property name="feature.comma.list" value="@{feature}"/>
          </else>
        </ac:if>
      </sequential>
    </ac:for>

    <echo message="Found following features to install"/>
    <echo message="${features.list}"/>

    <java jar="${equinox.launcher.jar}"
      fork="true"
      failonerror="true"
    >
      <arg value="-consolelog"/>
      <arg value="-application"/>
      <arg value="org.eclipse.equinox.p2.director"/>
      <arg value="-repository"/>
      <arg value="http://${repository.server}/custom-update-site"/>
      <arg value="-destination"/>
      <arg file="${real.eclipse.home}"/>
      <arg value="-installIU"/>
      <arg value="${feature.comma.list}"/>
      <arg value="-profile"/>
      <arg value="${ECLIPSE_CONFIG.eclipse.p2.profile}"/>
    </java>

P.S. For its usefulness and complexity Eclipse P2 is surely one of the most underdocumented features.

Delphinium answered 2/3, 2011 at 18:42 Comment(0)
C
0

In your eclipse installation folder you have the file bundles.info, for example:

eclipse-3.6.1/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

You can modify the file to add any bundle you want, and also the start level. But the simplest method of adding bundles to an eclipse installation is to add them to the "dropins" folder. This will lead to an automatic modification of the bundle.info file.

Carte answered 3/3, 2011 at 13:53 Comment(5)
hmmm... where is the "droppins" folder? The equinox will change the bundles.info automatically at runtime?Iou
In eclipse-3.6.1/, at the same level as plugins and features. And yes, equinox will do that automatically. Here you have some more information: link. The mechanism is similar to what felix install does, but "the eclipse way" :)Carte
This does not work for a plain Equinox installation. JARs from the dropins directory are not automatically loaded.Leanoraleant
Yes, you are right, this is not available on a standard equinox installation. You have to install p2 bundles for the dropins folder to be watched.Carte
Not sure why this was ever voted down... but this was exactly what I needed. I was trying to get plugins to work in an old version of eclipse I'm being forced to use, and this was the ONLY way I could get them to be found and loaded. I tried all of the other 'standard' ways, and for whatever reason, in this particular installation, they did not work.Dreyfus

© 2022 - 2024 — McMap. All rights reserved.