|
|
|
Re: Two input models in Acceleo [message #1737025 is a reply to message #1737019] |
Tue, 05 July 2016 07:56   |
|
Hi,
This is a basic use case that should be working seamlessly. "Could not find public template generateElement in module generate." means that you likely haven't exported the package containing your main template (see the MANIFEST.MF file, on the "runtime" tab). Likewise, your generator project needs to have dependencies ("dependencies" tab of the same file) on the projects that contain your two metamodels.
If you've properly set that up, please provide us with a sample with which we can reproduce the issue.
Laurent Goubet
Obeo
|
|
|
|
Re: Two input models in Acceleo [message #1737056 is a reply to message #1737039] |
Tue, 05 July 2016 11:48   |
|
I can't reproduce exactly the issue since I'm missing quite a few bits (I don't have a workspace with both gmf and acceleo and you also have a hardcoded url to a sc model in the generate.java) but... There are quite a few things here that will rub acceleo the wrong way.
First things first, we recommand not to have the metamodels in the same workspace as your generators, since this will have us compile them with incorrect URIs in the references. You should have the metamodels in a first workspace, then use a runtime eclipse application to develop your generators (or have the metamodel plugins installed in the eclipse you use to develop the acceleo generators) in order to avoid these issues.
Second, Acceleo requires you to have generated the code of your metamodels before using them. As I see it you only have the ecore files but haven't generated the model code.
Please look into these first and see if it solves the issue.
Laurent Goubet
Obeo
|
|
|
Re: Two input models in Acceleo [message #1737059 is a reply to message #1737056] |
Tue, 05 July 2016 12:12   |
Habtamu Tolera Messages: 20 Registered: June 2016 |
Junior Member |
|
|
Hi Laurent, I just put meta-models if you want to reproduce the issue. For myself, I have metamodel plugins installed. For gmf, you can open the file and remove the gmf part of the model. I will remove and attach the file so that you don't need gmf. My problem here is when I have two models not with one model. With one model, it works perfectly. How can I use two models in acceleo since it is not possible to tell the second model in acceleo launcher? I have tried to modify generate.java to load the second model but that is not working.
Thanks,
Habtamu
[Updated on: Wed, 06 July 2016 08:57] Report message to a moderator
|
|
|
|
Re: Two input models in Acceleo [message #1737070 is a reply to message #1737065] |
Tue, 05 July 2016 13:14   |
|
Okay, sorry I misunderstood the state you were in.
All you need to do in your case is push another argument into the list of parameters to your main template, as states on the stackoverflow answer linked in the first post here. You can do so by simply overriding "getArguments" in the generated launcher. Something like the following will work (I've also overriden "postInitialize" to make sure I only load the additional model once):
private EObject additionalArgument;
@Override
protected void postInitialize() {
super.postInitialize();
Resource modelResource = model.eResource();
URI modelURI = modelResource.getURI();
URI additionalModel = modelURI.trimSegments(1).appendSegment("Sensor.sc");
try {
EObject additionalModelRoot = ModelUtils.load(additionalModel, modelResource.getResourceSet());
EObject statemachine = null;
Iterator<EObject> children = additionalModelRoot.eAllContents();
while (children.hasNext() && !(statemachine instanceof sc.statemachine)) {
statemachine = children.next();
}
if (statemachine instanceof sc.statemachine) {
additionalArgument = statemachine;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public List<? extends Object> getArguments() {
List<Object> args = new ArrayList<>();
args.add(additionalArgument);
return args;
}
Laurent Goubet
Obeo
|
|
|
|
Re: Two input models in Acceleo [message #1737075 is a reply to message #1737074] |
Tue, 05 July 2016 14:10   |
|
They are references to your metamodel's generated code. As I mentionned above you really should generate its code for Acceleo to work properly. You could also ignore that part and manually select the one object you want to pass as second parameter (the statemachine from the "Sensor.sc" model), but I don't know if it'll work without the code being generated.
You mentionned that you had the metamodels installed, the "sc.statemachine" class should be in there, but you need a direct dependency towards your metamodel plugins in order to have it available.
Laurent Goubet
Obeo
|
|
|
|
Re: Two input models in Acceleo [message #1737143 is a reply to message #1737119] |
Wed, 06 July 2016 06:42   |
|
Hi,
If it does call your template (and creates the file), but doesn't generate text, your issue is that "aStateMachine.name" is empty. That was the case when I tried your generator at least. Try inputting static text in there:
[file ('static_file_name', false, 'UTF-8')]
static text field
[aStateMachine.name/]
[/file]
Laurent Goubet
Obeo
|
|
|
|
|
|
|
|
Re: Two input models in Acceleo [message #1737225 is a reply to message #1737218] |
Wed, 06 July 2016 13:25  |
|
With the configuration above, and the template you initially provided me, Acceleo properly generates a file in the "gen" folder as specified. If it's not doing it for you then you either have something logged in your error log or a file generated somewhere unexpected. The confirmation telling you that a file generation happened is not foolproof and will not be shown on some launch configs.
|
|
|
Powered by
FUDForum. Page generated in 0.01881 seconds