I tried to use Acceleo to translate a model to a text in an Eclipse plugin. The model is fine and the loaded Acceleo module looks fine as well. Still, acceleo does not generate anything.
Here is my code:
AcceleoService as = new AcceleoService(new PreviewStrategy());
URI alfToSpecSharpTemplate;
try {
alfToSpecSharpTemplate = getTemplateURI("my-valid-uri", new Path("/path/to/generate.emtl"));
} catch (IOException e) {
e.printStackTrace();
return null;
}
as.addListener(new IAcceleoTextGenerationListener() {/* print every method name on call */});
ResourceSet mtlSet = new ResourceSetImpl();
final Resource mtlRessource = mtlSet.getResource(alfToSpecSharpTemplate, true);
final Module module = (Module) mtlRessource.getContents().get(0);
List<Object> arguments = new ArrayList<Object>();
Map<String, String> result = as.doGenerate(module, "generateElement", myModel, arguments, null, new BasicMonitor());
System.out.println("Generation: " + as.hasGenerationOccurred());
The IAcceleoTextGenerationListener prints that listensToGenerationEnd() is called and nothing else. The loaded module looks fine in debug. It has the generateElement-template. The generate.mtl looks like this:
[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/papyrus/alf/Alf')]
[template public generateElement(test : Test) post (trim())]
[file('expr.specs', true)]
[test.block.generateElement() /]
[/file]
[/template]
My problem is that nothing is generated, i.e. result is an empty map. Also "Generation: false" is printed to console. Especially no error is printed.
Anyone have any idea on what is going wrong? I had it working once but I can't get it to work any more.