Home » Modeling » M2T (model-to-text transformation) » [Acceleo] template/generation error listening(other than watching STDOUT)
[Acceleo] template/generation error listening [message #917733] |
Thu, 20 September 2012 11:30 |
Joel Gluth Messages: 5 Registered: May 2012 |
Junior Member |
|
|
I have a relatively large Acceleo component that functions as a Maven plugin. It's pretty useful, but one of the things that would make it better is having my Maven build fail if generation raises exceptions.
For example,
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 46 in Module java for block for (getOwnedContraintInPackage(ownedAttribute,Bag {'constraints'})). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.PropertyImpl@484d3500 (name: searchTerm, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false, isDerivedUnion: false, aggregation: none). Problem found while generating the file 'D:\Projects\whatever-proxy\target\generated-sources\java\com\whatever\forms\SomethingSearchForm.java'.
at java.generateValidationConstraints(Property)(java.mtl:46)
at java.generateValidationConstraints(Property)(java.mtl:45)
turns up in my STDOUT, and is definitely a failure. However, I can't find a way to listen for this happening - no exception gets thrown to or by my Generate class, which I'm wrapping in the Maven task.
Monitor and IAcceleoTextGenerationListener do not seem to have quite the capacity I want, though it's entirely possible I'm reading the API wrong.
How can I listen for these kinds of event?
[Updated on: Thu, 20 September 2012 15:19] Report message to a moderator
|
|
| | |
Re: [Acceleo] template/generation error listening [message #1005765 is a reply to message #917733] |
Mon, 28 January 2013 16:29 |
Joel Gluth Messages: 5 Registered: May 2012 |
Junior Member |
|
|
Apologies for the thread necromancy, but Acceleo has become topical for me again and I'm actually going to have to make this happen.
The suggestions itself is fine as far as it goes. The problem for me is ensuring the creation of the different AcceleoEngine implementation... my Generate class can override AbstractGenerator's createAcceleoService() method to get an AcceleoService (which is the class that actually manages the IAcceleoEngine). However, AcceleoService itself is mostly private, the class is final, and it does not implement an interface.
In particular, this bit is problematic:
private void createEngine() {
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
generationEngine = new DefaultEngineSelector().selectEngine(AcceleoEngineRegistry
.getRegisteredCreators());
}
if (generationEngine == null) {
generationEngine = new AcceleoEngine();
}
}
While IAcceleoEngine seems nice and extensible, the generator task has to access it through a layer that cannot be changed and which dictates the implementation of IAcceleoEngine when I am running outside Eclipse. Which is definitely where I am, with my standalone task!
Or does EMFPlugin.IS_ECLIPSE_RUNNING not do what it seems to do?
[Updated on: Mon, 28 January 2013 16:30] Report message to a moderator
|
|
| |
Re: [Acceleo] template/generation error listening [message #1005979 is a reply to message #1005938] |
Tue, 29 January 2013 13:15 |
Joel Gluth Messages: 5 Registered: May 2012 |
Junior Member |
|
|
Since AcceleoService is final, and its methods are mostly private anyway, my choices become
1. Fork Acceleo (I don't like this idea much) and alter AcceleoService directly, or
2. have my Generate class use something that is almost exactly an AcceleoService in terms of function and code, but isn't an AcceleoService (in the OO sense).
Neither of these is wonderful, given that there has been helpful effort in Acceleo to provide interfaces like IAcceleoEngine and AbstractGenerator and so on to allow extensibility. But I will do the second one
Out of interest, why is AcceleoService final?
[edit: looking at it, my idea won't work; too many parts of the Acceleo code take an AcceleoService argument explicitly when they are called from Generate. Hmm. Alternatively I can have just the parts of Generate that call AcceleoService, which in turn delegates to the Engine, do... something different.]
[Updated on: Tue, 29 January 2013 13:31] Report message to a moderator
|
|
|
Re: [Acceleo] template/generation error listening [message #1009510 is a reply to message #1005979] |
Fri, 15 February 2013 08:56 |
|
Joel,
Within Eclipse, you can locate the LogView and add log listeners to react to them.
Outside of Eclipse, we log errors on System.err (http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git/tree/plugins/org.eclipse.acceleo.engine/src/org/eclipse/acceleo/engine/AcceleoEnginePlugin.java#n73). The exception is not thrown "out" of Acceleo as long as it is not fatal. Furthermore, most exceptions won't even stop the generation. What you pasted in the first post of this thread is an example of such an exception : we failed on one template, but we can still continue to generate for the rest.
AcceleoService is final since it was simply not designed to be extended. This class is only meant as an interface between the client code and the generation engine, in order to avoid rewriting all the boilerplate code. Replacing the engine is something that is rarely necessary, and since it is sufficiently rare, we decided not to spend time trying to make it easier. You will have to copy/paste the "AcceleoService#doGenerate(...)" method that is closest to what you seek to do, and replace the default AcceleoEngine we call by your own instance.
This is something we have never needed to do, and as such some necessary methods may be internal, don't hesistate to raise enhancement requests if you hit a wall .
Laurent Goubet
Obeo
|
|
| | |
Goto Forum:
Current Time: Thu Dec 12 14:24:01 GMT 2024
Powered by FUDForum. Page generated in 0.03623 seconds
|