Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Generating code from multiple metamodels
| | | | |
Re: [Acceleo] Generating code from multiple metamodels [message #523426 is a reply to message #523406] |
Fri, 26 March 2010 08:00 |
|
This is a multi-part message in MIME format.
--------------090902050401050508090105
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Tobias,
As Stéphane mentionned, the Acceleo UI (thus the launch config) doesn't
allow users to generate on multiple models at once. You can either
create multiple launch configs (one for each of the models for which you
wish to generate), generate an "Acceleo UI plugin" that will
automatically generate all that's need for a right-click action on your
models to generate your code (you'll need to launch a new runtime
configuration with this plugin or install both this plugin and your
generators in your Eclipse to see this action) or create your own code
that will make use of the Acceleo API to launch generation on multiple
models with one click.
Laurent Goubet
Obeo
Stéphane Bouchet wrote:
> hi Tobias,
>
> You cannot select multiples models with launch config, but you can have
> a model that references your others models. ( for example like genmodel
> reference .ecore model )
>
> Tobias R a écrit :
>> Hello Stéphane,
>>
>> I use Eclipse Helios M6 along with Acceleo v 3.0.
>> Having extended the module declaration to work with multiple
>> metamodels, the Acceleo Lunch configuration dialogue allows me only to
>> specify a single model. How can I load my other models?
>> Thanks very much for your help!
>>
>> Tobias
>
>
--------------090902050401050508090105
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------090902050401050508090105--
|
|
| |
Re: [Acceleo] Generating code from multiple metamodels [message #523579 is a reply to message #523429] |
Fri, 26 March 2010 22:27 |
|
This is a multi-part message in MIME format.
--------------090809040906010608050901
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Tobias,
Indeed, that wasn't what I understood from your last post :).
If your two models are both required for the generation of a single
file, I believe one of the two references the other? The example of
Stéphane with the genmodel referencing the ecore is a good one : if your
model A has references towards model B, you can simply launch the
generation on A : references to B will be transparently resolved (much
like opening A in the EMF editor transparently loads B when needed if a
reference to it is visited). For example, a "GenPackage" element from
the genmodel has a reference "ecorePackage" that points to an "EPackage"
element from an ecore model.
However, if your two models are totally unrelated (A has no reference
whatsoever to B, B has no reference whatsoever to A), then the use case
cannot be handled through Acceleo (in fact, I fail to see how both could
be required for a single module if they don't share any reference to one
another).
I don't know if this helps, yet if not, I'll have to know a little more
about what you're trying to accomplish, the metamodels and models you
use and why loading both is mandatory.
Laurent Goubet
Obeo
Tobias R wrote:
> First thanks a lot for your information. However, I believe my question
> is somehow ambiguous --- at least if I regard the posting from Laurent
> Goubet. So, I don't know if we speak about the same thing.
>
> Let's try to state my problem again :)
>
> I have two models that conform to two different EMF metamodels. To
> generate a single source code file, both models are required. In other
> words, the contents of the two models are supposed to result in a single
> Java class by using Acceleo.
> To summarise: I don't need to generate multiple models at once, however,
> I need to generate a Java file from two given models!
>
> Is is possible to solve this problem by using a Genmodel?
>
> Thanks a lot!
>
> Tobias
--------------090809040906010608050901
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------090809040906010608050901--
|
|
| |
Re: [Acceleo] Generating code from multiple metamodels [message #524264 is a reply to message #523755] |
Wed, 31 March 2010 06:26 |
|
This is a multi-part message in MIME format.
--------------080806070005060305070604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Tobias,
Acceleo does support generation of files from multiple models ... but
not through its GUI. It is a matter of calling the API with the accurate
arguments (in your case, arguments coming from multiple resources). I
don't think this option will be added to the UI though ; experienced
users can call the API directly, but for all others it would clutter the
UI and make things unclear.
Laurent Goubet
Obeo
Tobias R wrote:
> Thanks a lot for your quick replies.
>
> My question has been solved now. Unfortunately, my problem is not
> solvable with Acceleo. My two metamodels are totally unrelated. A
> workaround is to use a M2M along with ATL which supports my requirements.
> But one question remains: Will Acceleo support generation of single
> source files from multiple models in future? This would be a very
> helpful feature because domains and their models are often divided into
> submodels in practice. And therefore I believe there is demand for such
> a feature.
> Keep up the good work, Obeo Team! I like Acceleo. It is simple to use
> and well documented. That's why I decided to use it and not OAW.
>
> Cheers,
>
> Tobias
--------------080806070005060305070604
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------080806070005060305070604--
|
|
| | |
Re: [Acceleo] Generating code from multiple metamodels [message #1691344 is a reply to message #1691266] |
Mon, 06 April 2015 10:46 |
Christoforos Zolotas Messages: 10 Registered: March 2015 |
Junior Member |
|
|
Hello Ed and thank you for your reply,
Before I type anything else let me ask you, should I open a new thread to continue this conversation? I initially asked for more details here as my question is identical to the opener's one.
As of the 1st module loading emulation:
I guess by stepping in my code you mean stepping and editing the "Generate.java" that is automatically generated when I build a new Acceleo project? If yes, let me write down a concrete example, since to me this "emulating" step is not clear at all:
Assume that I have 2 meta-models, MMA and MMB and have already populated two respective models MA (conforming to MMA) and MB (conforming to MMB). And the way I wish my @main template to look is something like this:
[comment encoding = UTF-8 /]
[module generate('file:/...full path to/MMA.ecore', 'file:/...full path to /MMB.ecore')]
[template public generateElement(anMMAElement : MMAElement, anMMBElement : MMBElement)]
[comment @main/]
[file (.....)]
.....
[anMMAElement.name/] <-- Access MA model
....
[anMMBElement.name/] <-- Access MB model
[/file]
[/template]
I guess that I have to edit the main function in the generate.java file like this? (with a preceding arrow are the added lines):
public static void main(String[] args) {
try {
if (args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
--> URI modelMBURI = URI.createFileURI("full path to/modelMB.xmi");[/b]
List<String> arguments = new ArrayList<String>();
--> arguments.add("anMMBElement : MMB");
Generate generator = new Generate(modelURI, folder, arguments);
--> Generate modelMBGenerator = new Generate(modelMBURI, folder, arguments);
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
generator.doGenerate(new BasicMonitor());
--> modelMBGenerator.doGenerate(new BasicMonitor());
}
(I do get an Argument types mismatch for module element generateElement exception at the line "generator.doGenerate(new BasicMonitor()); )
Thanks for your feedback,
Christoforos.
[Updated on: Mon, 06 April 2015 10:47] Report message to a moderator
|
|
| |
Re: [Acceleo] Generating code from multiple metamodels [message #1693636 is a reply to message #1691344] |
Mon, 27 April 2015 07:45 |
|
Hi,
The list of arguments should just be the list of the objects that you want as arguments. Your template has the following signature:
[template public generateElement(anMMAElement : MMAElement, anMMBElement : MMBElement)]
Then the arguments list should be something like this:
List<MMBElement> arguments = new ArrayList<>();
arguments.add(yourMMBElement);
and not
List<String> arguments = new ArrayList<String>();
arguments.add("anMMBElement : MMB");
And on top of that, do not use the path of the ecore model in the declaration of your module, you should use the NsURI of your EPackages in those ecore model.
[module generate('file:/...full path to/MMA.ecore', 'file:/...full path to /MMB.ecore')]
Regards,
Stephane Bégaudeau, Obeo
|
|
|
Goto Forum:
Current Time: Sun Dec 22 06:25:23 GMT 2024
Powered by FUDForum. Page generated in 0.05230 seconds
|