Hi atlassian,
I have jira versions 7.x and 8.x and I want to build jira plugin to get two jar files. For jira version 7.x getEntityProperty() method returned:
com.atlassian.fugue.Option<EntityProperty> class type,
for jira version 8.x:
io.atlassian.fugue.Option<EntityProperty> class type,
I check the versions with statement, here my code:
if (version.equals("7")) {
com.atlassian.fugue.Option<EntityProperty> jsonValues =
propertyValues.getEntityProperty();
entity = jsonValues.getOrNull();
} else {
io.atlassian.fugue.Option<EntityProperty> jsonValues =
propertyValues.getEntityProperty();
entity = jsonValues.getOrNull();
}
When the jira version is 7.x in my pom.xml I get the following error:
package io.atlassian.fugue does not exist
and the case when version is 8.x:
incompatible types: io.atlassian.fugue.Option<com.atlassian.jira.entity.property.EntityProperty> cannot be converted to com.atlassian.fugue.Option<com.atlassian.jira.entity.property.EntityProperty>
How can I solve this problem for in order to my plugin work for both jira versions?
Thanks in advance,
Hello @Mamikon Papikyan ,
This question has been already answered in the below threads, in the developers community and in here:
Specifically:
@verenok you mean to build an app that’s compatible with both Jira 7 and Jira 8? There are two approaches:
- build compatibility (adapter) libraries for Jira 7 and Jira 8 (compiling each against the appropriate Jira version) and call the right library based on the Jira version
- use Java introspection to call the methods; since the only difference is in the return type it’s actually easy.
And:
This is what we use to access the property value from the return value of issuePropertyService.getProperty:
public static <T> T getEntityPropertyOrNull(PropertyResult propertyResult) { try { Object option = propertyResult.getClass().getMethod("getEntityProperty").invoke(propertyResult); return option.getClass().getMethod("getOrNull").invoke(option); } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException var2) { throw new IllegalStateException(var2); } }
Finally, please notice that this might not be the best place to get help on development related questions. In case further help will be needed on this topic, you might want to refer to the resources listed in https://developer.atlassian.com/resources:
Cheers,
Dario
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.