Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-dev] canonical way to handle optional dependencies

Wouldn't it be an option to simply supply a "cli-only" bundle that supplies the missing interfaces with dummy implementations?

Am 15.04.21 um 15:04 schrieb Jonah Graham:

On Thu, 15 Apr 2021 at 08:38, Christoph Läubrich <laeubi@xxxxxxxxxxxxxx <mailto:laeubi@xxxxxxxxxxxxxx>> wrote:

    I think there is no "one fits all". Optional dependency are really
    problematic to handle right and should be avoided as they often mean
    your bundle/services are not well shaped.


Thanks - I do agree.

    If you describe your case it might be possible to give some more advice.


The issue is we (CDT project) have a bundle that has been around for a very long time. It is supposed to be a "core" bundle, but has some UI dependencies in it. This bundle is used headlessly today, and there are UI code paths than when run headlessly are effectively no-ops.

Most of the dependencies on the UI are relatively easy to resolve. However one area is in the API - the API includes references to org.eclipse.ui.dialogs.IOverwriteQuery, and in the headless case these references are null.

We would like to refactor the code so that an installation can be made that has no UI bundles included in it. The long plan is to deprecate and remove the code that depends on UI, but in the meantime we wanted to make the UI dependency optional.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=572850 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=572850> tracks the actual work.

Thanks
Jonah



    Am 15.04.21 um 13:38 schrieb Jonah Graham:
     > Hello,
     >
     > (Not sure this is on topic for the list - but not sure where to ask.)
     >
     > What is the canonical way to check if an optional dependency is
    available?
     >
     > I know of a couple of methods:
     >
     > 1. wrapping code in try/catch and catching something wide like
    Throwable
     > or NoClassDefFoundError
     > 2. checking for bundle status (e.g. calling
     > Platform.getBundle(symbolicName) and Bundle.getState)
     >
     > Thank you.
     > Jonah
     >
     >
     >
     >
     > ~~~
     > Jonah Graham
     > Kichwa Coders
     > www.kichwacoders.com <http://www.kichwacoders.com>
    <http://www.kichwacoders.com <http://www.kichwacoders.com>>
     >
     > _______________________________________________
     > platform-dev mailing list
     > platform-dev@xxxxxxxxxxx <mailto:platform-dev@xxxxxxxxxxx>
     > To unsubscribe from this list, visit
    https://www.eclipse.org/mailman/listinfo/platform-dev
    <https://www.eclipse.org/mailman/listinfo/platform-dev>
     >
    _______________________________________________
    platform-dev mailing list
    platform-dev@xxxxxxxxxxx <mailto:platform-dev@xxxxxxxxxxx>
    To unsubscribe from this list, visit
    https://www.eclipse.org/mailman/listinfo/platform-dev
    <https://www.eclipse.org/mailman/listinfo/platform-dev>


_______________________________________________
platform-dev mailing list
platform-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/platform-dev



Back to the top