Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Load class in Idea SDK

AV August 13, 2019

Hi.

I try to read data from idalko table grid plugin customfield.

PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class dataManagerClass = pluginAccessor.getClassLoader().loadClass("com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager");
Object tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
tgeGridDataManager.readGridData(...)

 But IDEA can't resolve tgeGridDataManager methods.

How to properly load this class in project?

1 answer

1 accepted

0 votes
Answer accepted
DPKJ
Community Champion
August 13, 2019

IDE won't be able to resolve this class, as you don't have it in your dependency and you are loading it at Runtime.

For IDE it is only possible if you have package containing class

com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager

 as maven dependency in your POM file.

AV August 14, 2019

Thank you. It's works.

1. step install jar to maven
C:\Applications\Atlassian\atlassian-plugin-sdk-6.3.10\apache-maven-3.2.1\bin>atlas-mvn install:install-file -DgroupId=com.idalko.jira.plugin -DartifactId=igrid -Dversion=1.29.5 -Dpackaging=jar -Dfile=C:\Applications\SituationReport\lib\idalko-igrid-1.29.5.jar

2. step add depedency to pom
<dependency>
<groupId>com.idalko.jira.plugin</groupId>
<artifactId>igrid</artifactId>
<version>1.29.5</version>
<scope>compile</scope>
</dependency>
AV August 14, 2019

But i have another question.

This classes provides interfaces but i don't understand how to use it.

TGEGridTableDataManager tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager.class);

Causes

Causes  Caused by: java.lang.ClassCastException: Cannot cast com.idalko.jira.plugins.igrid.impl.data.TGEGridTableDataManagerImpl to com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager

How to use this interface?

Thanks for advice.

DPKJ
Community Champion
August 14, 2019

I guess dependency scope should be `provided` and not `compile`.

If this doesn't work, try explicitly importing it in `maven-jira-plugin` configuration.

 

 

<Import-Package>       
  *;version="0";resolution:=optional
</Import-Package>

OR

<Import-Package>
com.idalko.jira.plugins.igrid.api.*;resolution:=optional, *;version="0";resolution:=optional </Import-Package>

 

 

AV August 14, 2019

Yep there was error in scope. Need to set provided. Thanks a lot.

Suggest an answer

Log in or Sign up to answer