I am attempting to utilize the groovyScript() functionality of live templates to generate copy constructors on the fly.
Generally my process to create a POJO for this project involves the following process.
1) Custom File Template - Named Processable, executes flawlessly.
2) Add attributes for class using some live template autocompletion or good ole typing.
3) Ctrl + N -> g s enter, select everything and use the builder setters.
4) cc TAB to generate my custom copy constructor, which iterates over all the methods of the class and calls every setter with the contents of a supplied object to be copied using its getters.
Then all I need to do is close the file, except 4 doesn't work all together.
EDIT: While it should probably be easily inferred, I am using Class.forName() for reflection to obtain the list of Methods via Class.getDeclaredMethods(). As alluded to below, I have also done some searching to find Groovy specific alternatives to using the java libraries, again to no avail.
The live template portion of the process works flawlessly, I get my constructors named, formatted and set up correctly. The included groovyScript, when executed via the built in groovyConsole of the project executes flawlessly, returning the exact strings of expected code. What doesn't work, is when I put them together. I have tried all manner of uses to execute this, down to manually attempting to add the current folder to the classpath via URLClassLoader in java. I have used all manner of groovy specific classes as well on the off chance that this issue is somehow groovy classloader not behaving well with the java classloader. Nothing I do, seems to be able to get the parser to be able to find the class files which are within my project (contiuously built via maven). I am now operating under the assumption that jvm which is executing this groovyScript is not project scope but likely IDE scoped, so my question is.. where the hell is this classpath and or how can I flag my packages in such a way that this classloader will be able to locate these class files. It does not use PATH environment variable, as I have explicitly put the target/classes/ folder on the path to no avail.
While doing all manner of testing with the class loaders the exception I kept getting was ClassNotFoundException, since CNFE and NSCE are thrown in different circumstances. I have rejected the thought that it is a permissions issue with the loader not being allowed to read the file as that just doesn't make sense, but I have not done any work to see if that is the cause.
I'm working on OSX - El Capitan (such a bad update).
Message was edited by: Original Poster