I am developing a plugin for Bitbucket Server. When I try to start it, it fails because of banned dependencies:
[INFO] --- bitbucket-maven-plugin:8.1.0:validate-banned-dependencies (default-validate-banned-dependencies) @ diffPlugin ---
[INFO] validate banned dependencies
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
make sure platform artifacts are not bundled into plugin
Found Banned Dependency: org.slf4j:slf4j-api:jar:1.7.30
Found Banned Dependency: commons-fileupload:commons-fileupload:jar:1.4
Found Banned Dependency: org.apache.httpcomponents:httpclient:jar:4.1.1
Found Banned Dependency: org.slf4j:slf4j-log4j12:jar:1.7.30
Found Banned Dependency: commons-io:commons-io:jar:2.6
Found Banned Dependency: org.apache.httpcomponents:httpcore:jar:4.4.12
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
I cannot find any reference to the error message. Why are those dependencies banned? They are widely used packages.
I would appreciate any help in tracking this issue down.
Here is the POM (I removed everything until the properties tag). One other thing of note is that this POM works with Bitbucket version 5.16, but when I use 7.2.4 it throws this error.
On all the banned dependencies, please add <scope>provided</scope> to indicate to maven that it does not need to package those dependencies as the parent application will provide them. The default value for <scope/> is compile so right now Maven is trying to compile those dependencies into your plugin, which should not work and is now failing in newer versions of Bitbucket.
Adding a <dependency> tells the SDK that your code will use this artifact, but specifying <scope>provided</scope> refines that to mean “these classes will be provided at runtime by the product”.
Thank you, that helped. I think I am getting confused with the scopes, I thought that provided means that the SDK has those plugins. At least, it seemed to work that way with the older version of the plugin that the POM was based on.
I think it causes them problems when plugin authors bring their own packages, so I think newer versions are just getting more restrictive about how you package things.
[INFO] 2021-02-04 18:54:27,054 ERROR [spring-startup] c.a.plugin.osgi.factory.OsgiPlugin Detected an error (BundleException) enabling the plugin 'com.mysoftware.bitbucket-scanner' : Unresolved constraint in bundle com.mysoftware.plugin [125]: Unable to resolve 125.0: missing requirement [125.0] osgi.wiring.package; (osgi.wiring.package=org.eclipse.jgit.api). This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
[INFO] 2021-02-04 18:54:27,054 WARN [spring-startup] c.a.plugin.impl.AbstractPlugin Unable to enable plugin 'com.mysoftware.bitbucket-scanner'
[INFO] 2021-02-04 18:54:27,094 WARN [spring-startup] c.a.plugin.impl.AbstractPlugin Because of this exception
[INFO] com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.mysoftware.bitbucket-scanner
[INFO] at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418)
[INFO] at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:287)
[INFO] at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130)
[INFO] at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1248)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1218)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.addPlugins(StashPluginManager.java:80)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:597)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.lambda$earlyStartup$0(StashPluginManager.java:55)
[INFO] at com.atlassian.stash.internal.plugin.PluginUpgradeHelper.withUpgrade(PluginUpgradeHelper.java:76)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.earlyStartup(StashPluginManager.java:55)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:527)
[INFO] at com.atlassian.stash.internal.plugin.SpringPluginSystemLifecycle.start(SpringPluginSystemLifecycle.java:35)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:350)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
[INFO] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880)
[INFO] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
[INFO] at javax.servlet.GenericServlet.init(GenericServlet.java:158)
[INFO] at java.lang.Thread.run(Thread.java:748)
[INFO] ... 8 frames trimmed
[INFO] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.mysoftware.plugin [125]: Unable to resolve 125.0: missing requirement [125.0] osgi.wiring.package; (osgi.wiring.package=org.eclipse.jgit.api)
[INFO] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
[INFO] ... 22 common frames omitted
[INFO] 2021-02-04 18:54:27,128 ERROR [spring-startup] c.a.plugin.manager.PluginEnabler Unable to enable plugin com.mysoftware.bitbucket-scanner
[INFO] com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.mysoftware.bitbucket-scanner
[INFO] at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418)
[INFO] at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:287)
[INFO] at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130)
[INFO] at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1248)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1218)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.addPlugins(StashPluginManager.java:80)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:597)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.lambda$earlyStartup$0(StashPluginManager.java:55)
[INFO] at com.atlassian.stash.internal.plugin.PluginUpgradeHelper.withUpgrade(PluginUpgradeHelper.java:76)
[INFO] at com.atlassian.stash.internal.plugin.StashPluginManager.earlyStartup(StashPluginManager.java:55)
[INFO] at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:527)
[INFO] at com.atlassian.stash.internal.plugin.SpringPluginSystemLifecycle.start(SpringPluginSystemLifecycle.java:35)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:350)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
[INFO] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
[INFO] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880)
[INFO] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
[INFO] at javax.servlet.GenericServlet.init(GenericServlet.java:158)
[INFO] at java.lang.Thread.run(Thread.java:748)
[INFO] ... 8 frames trimmed
[INFO] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.mysoftware.plugin [125]: Unable to resolve 125.0: missing requirement [125.0] osgi.wiring.package; (osgi.wiring.package=org.eclipse.jgit.api)
[INFO] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
[INFO] ... 22 common frames omitted
Yes, I like using this forum as a KB article, since other sites disappear or change over time. I’d appreciate it at least! I think that the hardest part for new Atlassian Plugin Developers is the Maven/Spring/Dependency Injection portions of the build so I think any advice you can provide is helpful to the community.
Did you create a post? I got the same problem. When I use provided, my plugin is disable or disappear. And when I use compile, I got this error message during build : [WARNING] Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message: make sure platform artifacts are not bundled into plugin Found Banned Dependency: org.apache.httpcomponents:httpcore:jar:4.4.14 Found Banned Dependency: org.apache.httpcomponents:httpclient:jar:4.5.13 Use 'mvn dependency:tree' to locate the source of the banned dependencies.
I would appreciate to find your post Cheers