I have a problem where I try to access my plugin component from Groovy-script.
As far as I know the Groovy Script Runner can't load custom classes without a workaround:
File jiraHome = ComponentAccessor.getComponent(JiraHome.class).getHome();
def jardir = new File(jiraHome,"\\plugins\\installed-plugins\\" );
def urlList = []
def jars = jardir.listFiles().findAll { it.name.endsWith(".jar") }
jars.each {
def url = it.toURI().toURL()
urlList.add(url)
}
def urls = (URL[]) urlList.toArray()
def loader = new RootLoader( urls, this.class.classLoader);
I use this to get a Class object with the Class.forName() method, but when I try to get a managed instance with ComponentAccessor.getComponentOfType(myClass), it returns a null value (I suspect something with the JVM not knowing the two classes are the same is the problem).
Does anyone knows a workaround for this? (besides adding the class to the groovy runner's POM)