Soft Dependency in other Plugins

Hi,

One of the features of our plugin relies on the dashboard-view plugin. (it extends hudson.plugins.view.dashboard.DashboardPortlet).

It seems that the dashboard-view plugin is incompatible with CloudBees CI HA/HS. Although our plugin can still offer most of its benefits without the dashboard table, it has become ineffective because, when the dashboard-view plugin is removed, our plugin fails to load due to a dependency error.

Is there a way to declare that a dependency is “optional”? Will adding <optional>true</optional> to the pom.xml is a legit workaround?

Thanks,

Tal,

yes
Declaring a dependency optional this way will allow you to install your plugin without dashboard view

Thanks,
However, this means that it will shows an exception in the stdout each time Jenkins starts. Is there any way to catch this exception and printout something more informative to the end user?

Tal.

you might need to declare the extension as option as well
@Extension(optional = true)

1 Like

Thanks. Can you point me to the documentation of it? where should I mark this annotation for the optional Extention?

You have a class that extends something from dashboard-view plugin. This class has a descriptor that already is annotated with @Extension. For this class you need to add the optional=true to that annotation.

1 Like

Thanks, works well now.

1 Like