tags:

views:

14

answers:

0

I'm trying to pass one of my own classes to a Java Emitter Template but i can't get it to work. The generated Java file looks ok and can be compiled manually. But the JETEmitter will fail like this:

The import test cannot be resolved : 'C:/prj/.JETEmitters/src/test/eclipse/codegen/TestTemplate.java' at line 4
Hello cannot be resolved to a type : 'C:/prj/.JETEmitters/src/test/eclipse/codegen/TestTemplate.java' at line 28

All this is inside an Eclipse plugin. The test.Hello class is contained in the same plugin and is created and passed to the JETEmitter without any problems.

Hello hello = new Hello();
ClassLoader classloader = hello.getClass().getClassLoader();
JETEmitter emitter = new JETEmitter(templateURI, classloader);
result = emitter.generate(monitor, new Object[] { hello });

I tried it with different classloaders as well as without and also tried subclassing the JETEmitter (see here). Nothing seems to work.

Right now i'm guessing i need to use JETEmitter.addVariable to set a classpath... but where to? The classes are inside the plugin and should already have been loaded by the classloader.

I'm using org.eclipse.emf.codegen 2.5.0