Eclipse Project Setup for Bitbucket Plugin

Looking for some guidance on what I’m missing when trying to set up my Eclipse IDE for developing a BitBucket Plugin.

I have followed the steps from Installing Atlassian SDK and have installed the latest 1.8.0_201 JRE and JDK.

My Eclipse Project has refrences to:

  • C:\Applications\Atlassian\atlassian-plugin-sdk-8.0.7\repository
  • JRE System Library: C:\Program Files\Java\jre1.8.0_201

However, it still can’t seem to find:

  • import com.atlassian.bitbucket.hook.repository.* // There is no com.atlassian.bitbucket package in the 8.0.7 SDK
  • import org.springframework.stereotype.Component; // Where should it find org.springframework?
  • import javax.annotation.Nonnull; // Why can’t it find javax in the JRE?

What is missing in either my SDK setup, or my Eclipse references that would help find those packages?

Thanks for your help!

1 Like

Hello @jtigner,

I tried it just now and was able to successfully add

import com.atlassian.bitbucket.hook.repository.*;
import javax.annotation.Nonnull;

If eclipse is showing some errors, but runnin an atlas-run in the command line works, it is possible that you imported the project as a maven project. If this is the case, I’d advise that you run atlas-mvn eclipse:eclipse first then you import the project as an Existing Project into Workspace.

As for Component is it imperative for your use case to use this, or is it fine to use com.atlassian.plugin.spring.scanner.annotation.component.BitbucketComponent instead?


1 Like


Thanks for the follow up, based on your feedback I am much further along! I was able to get the project working in Eclipse by starting from scratch performing the following steps:

  • Install M2E plugin for eclipse
  • atlas-create-bitbucket-plugin
  • atlas-create-bitbucket-plugin-module
  • Eclipse: Import Existing Maven Project

Eclipse was able to locate the required Maven dependencies and compile the project.

It appears that with the Atlassian 8.0.7 SDK, the atlas-mvn command is deprecated. I seem to be running into many issues that are related to outdated documentation between 6.x and the new 8.x SDK.

This includes trying to use outdated tutorials like File Size Hook Example

In order to follow the example of using a DI constructor, I need to add a dependency for the CommitService.

private final CommitService m_commitService;
private final PluginCommandBuilderFactory m_commandFactory;
public MyFirstPrecommitHook(CommitService a_commitService, PluginCommandBuilderFactory a_commandFactory) 
    m_commitService = a_commitService;
    m_commandFactory = a_commandFactory;

I get the following error when attempting to load the plugin:

[INFO] 2019-03-25 17:25:56,550 ERROR [spring-startup]  c.a.p.manager.DefaultPluginManager There was an error loading the descriptor 'My First Precommit Hook' of plugin ''. Disabling.
[INFO] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.bitbucket.commit.CommitService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
[INFO] Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.bitbucket.commit.CommitService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

My next step was to attempt to use the @Component and the @Autowire annotations for my class and the constructor. However, Eclipse is now failing to recognize the spring-scanner annotations as being valid.

Are there any suggestions for how to update my Eclipse Maven Project to properly understand the spring scanner annotations?

Thanks for your help!

I feel like I am making some progress. I am now able to add the @Configuration and @Autowired annotations and have Eclipse recognize the calls.

I had to add the following to my pom.xml

<!--  Spring -->

This allowed me to add the proper import statements:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

Now, I am getting the following error when trying to load the plugin using atlas-debug

[INFO] 2019-03-27 13:19:41,568 ERROR [spring-startup]  c.a.p.o.f.OsgiPluginInstalledHelper Cannot determine required plugins, cannot resolve bundle ''
[INFO] 2019-03-27 13:19:45,944 WARN  [ThreadPoolAsyncTaskExecutor::Thread 6]  c.a.p.s.s.c.a.w.atlassian-webhooks-plugin Spring context started for bundle: com.atlassian.webhooks.atlassian-webhooks-plugin id(126) v(5.1.1) reference:file:/D:/GIT/BitBucket/my-first-precommit-check/target/bitbucket/app/WEB-INF/atlassian-bundled-plugins/atlassian-webhooks-plugin-5.1.1.jar
[INFO] 2019-03-27 13:19:49,995 WARN  [ThreadPoolAsyncTaskExecutor::Thread 2]  c.a.p.s.s.util.ProductFilterUtil Couldn't detect product, will use ProductFilter.ALL
[INFO] 2019-03-27 13:19:52,755 ERROR [spring-startup]  c.a.plugin.osgi.factory.OsgiPlugin Detected an error (BundleException) enabling the plugin '' : Unresolved constraint in bundle [127]: Unable to resolve 127.0: missing requirement [127.0] osgi.wiring.package; (osgi.wiring.package=bsh).  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
[INFO] 2019-03-27 13:19:52,755 WARN  [spring-startup]  c.a.plugin.impl.AbstractPlugin Unable to enable plugin ''
[INFO] 2019-03-27 13:19:52,762 WARN  [spring-startup]  c.a.plugin.impl.AbstractPlugin Because of this exception

I shall continue on with debugging these issues …