I am using Acceleo to create Java main method in my ".mtl", like this
[template public generateElement(aMiniFamily : MiniFamily)]
[comment @main/]
[file ('CreateMiniFamily.java', false, 'UTF-8')]
public static void main(String[] args) {
}
[/file]
[/template]
But Acceleo gives me error as "The invocation isn't terminated" around "String[]".
I tried with "\[]" and "/[]", not working.
CodePudding user response:
The acceleo template syntax is kind of annoying when you want to print []
, but there's a very simple way to go over this issue, it's to remember that Acceleo will evaluate OCL expressions inside of the [ /]
. Consequently, you can put a string inside of the [/]
and it will be printed as a string in your result file. The expression will then be ['[]'/]
and your code:
[template public generateElement(aMiniFamily : MiniFamily)]
[comment @main/]
[file ('CreateMiniFamily.java', false, 'UTF-8')]
public static void main(String['[]'/] args) {
}
[/file]
[/template]