I have a script structure that might look like this:
scripts/
my_main_class.groovy
my_class/
my_class1.groovy
my_class2.groovy
From "my_main_class", I want to instantiate either "my_class1" or "my_class2" depending on a variable.
I am trying use the following:
def cname = 'my_class1'
def a = this.getClass().classLoader.loadClass(cname)?.newInstance()
I get a java.lang.ClassNotFoundException: my_class1 error.
Clearly the CLASS_PATH is not finding this class. Does anyone know how to make this work?
I can instantiate the classes normally
import my_class.my_class1
def a = new my_class1()