Cross major JIRA versions 6.x-7.x development problem with User Entity Properties

Hello everyone,

Sorry to bother you but I am currently implementing a feature in one of our add-ons that requires using the UserPropertyService to have access to User Entity Properties. The problem is that User Entity Properties were added on JIRA 7.0 and our add-on provides compatibility down to JIRA 6.4.1. That means our code base is compiled against the lower version were the required service class is not available.

I am going to use a snippet of Java code to illustrate my problem. The following piece of code which is compatible with JIRA 7+, does not compile using JIRA 6.4 APIs:

@Scanned
public class MyComponent
   private UserPropertyService userPropertyService;

   @Autowired
   public MyComponent(@ComponentImport UserPropertyService userPropertyService) {
      this.userPropertyService = userPropertyService;
   }
}

to overcome this I have tried using the Object class like this, so that the code compiles and then the dependencies are injected on runtime when using JIRA 7+:

@Scanned
public class MyComponent
   private Object userPropertyService;

   @Autowired
   public MyComponent(@ComponentImport Object userPropertyService) {
      this.userPropertyService = userPropertyService;
   }
}

but unfortunately, the injection is performed by type and there is no way to use a qualifier based on name. If it worked I could then use reflection in those cases where the runtime is JIRA 7+ and ignore when on JIRA 6.4

I have also tried to use reflection, but since the UserPropertyService class is part of an external component/module, this attempt was also unsuccessful.

Does anyone know any other alternative to solve this conundrum, besides dropping JIRA 6.4 support?

Thanks just for reading :blush:
Angel

2 Likes

The best way to handle these types of cases (in my own opinion) is to create an interface and then have a different code path (you could create maven artifacts that you then pull in at build time). More than likely you’ll end up having to publish multiple artifacts with this route though.

But I’ve got to ask - do you really want to support JIRA 6.4? (7.0 was just EOL:d). At Wittified we follow the EOL schedule strictly since if we can’t get support for a product - we can’t really support it. Just something to bear in mind.

Thanks Daniel. My preferred option is to drop support for JIRA 6.4, but that’s kind of a business decision. That’s why I am trying to find an alternative technical solution. Separate artifacts is certainly a solution, but I don’t think we’ll go that route.

Thanks a lot again!