Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] handline of newlines in mtl templates
[Acceleo] handline of newlines in mtl templates [message #1763529] Wed, 17 May 2017 06:28 Go to next message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Is there a way I can make acceleo use the end of line delimiters of the system it is generating on?

I created my generator on a Windows machine, which means I have \r\n line delimiters in the mtl files.

This seems to mean that users on a mac/linux machine will also get \r\n when using the generator.

I was hoping Acceleo would take care of this, but apparently not.

Is there a way I can configure/program acceleo to generate code that adjusts to the sytem it is used on?
Re: [Acceleo] handline of newlines in mtl templates [message #1763535 is a reply to message #1763529] Wed, 17 May 2017 07:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

There are Resource save options that you can program. Sometimes they default correctly, but what is correct when file/project/workspace/system may have different opinions?

I strongly recommend that you try to always use \n on all systems. Notepad seems to be the only Windows tool that actually has limitations, so use Notepad2. Set your project preferences to Unix, (and UTF-8).

I use Windows and \n and have very few problems as a result.

Regards

Ed Willink

Re: [Acceleo] handline of newlines in mtl templates [message #1763626 is a reply to message #1763535] Thu, 18 May 2017 07:17 Go to previous messageGo to next message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Hi

Can you please give me some pointers about this "resource save options" that one can program?

I tried in Eclipse to change the settings "Workspace > new textfile line delimiter" to (Unix), but it does not seem to help - Even when I try to generate completely new files.

Are you suggesting otherwise, that I should change the MTL files to use \n instead of \n\r? (I'm afraid that this may similarly cause some problems later for Windows users)
Re: [Acceleo] handline of newlines in mtl templates [message #1763647 is a reply to message #1763626] Thu, 18 May 2017 10:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You seem to be confusing issues.

*.mtl is an Acceleo internal. I strongly recommend you do not mess with it until you are an experienced Acceleo and EMF user.

Your generator is your generator where presumably you can do what you like. I strongly recommend \n only.

See org.eclipse.emf.ecore.resource.Resource.OPTION_LINE_DELIMITER for explicit setting. Often the project is best for configuration since that propagates through GIT/CVS/... to other workspaces.

Regards

Ed Willink
Re: [Acceleo] handline of newlines in mtl templates [message #1763653 is a reply to message #1763647] Thu, 18 May 2017 11:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry, I'm forgetting. It is *.emtl that is Acceleo internal. *.mtl is a source file, do what you like. I recommend \n so that you can interchange between OSes.

Regards

Ed Willink
Re: [Acceleo] handline of newlines in mtl templates [message #1763655 is a reply to message #1763647] Thu, 18 May 2017 11:30 Go to previous messageGo to next message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Hi,

So, I guess that I need to clarify that I am the developer of the mtl files, as well as the EMF model. I have full control over the generator project (I hope I am using the right technology).

I am trying to deal with the problem users of my generatror have, when they are using Linux/Mac.

Having said that, I assume your suggestion would still be that I produce the mtl files using \n only?
Re: [Acceleo] handline of newlines in mtl templates [message #1765957 is a reply to message #1763655] Wed, 14 June 2017 15:16 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Jad,

The line ending on your eclipse workspace is defined as a preference:
Window > Preferences, then in there you want to go to General > Workspace and explicitely set your line delimiter to Other: Unix instead of Default (Windows)

If you only want to change your project, right-click the project and go into its properties. The first screen (select "Resource" in the properties tree) allows you to explicitely set the line delimiter of your project. Other: Unix is again the one you want.

That will only apply to new files though, so you will have to manually change the ones you've already created : select the mtl files you want to change to the "\n" line delimiter, then use the File > Convert line delimiters to > Unix menu of eclipse.

[edit] Note that Acceleo will use the line delimiters that are used in the template when generating, not the line delimiter from the system. That choice was initially made to ensure people generating code on multiple machines will always have the same result since the template is what defines said result.

Laurent Goubet
Obeo

[Updated on: Wed, 14 June 2017 15:21]

Report message to a moderator

Re: [Acceleo] handline of newlines in mtl templates [message #1766337 is a reply to message #1765957] Tue, 20 June 2017 11:22 Go to previous message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Ok thanks. This is clearer. I will give it a go.
Previous Topic:[Acceleo] Multi-model to text transformation
Next Topic:Vhdl code generation from UML model using acceleo
Goto Forum:
  


Current Time: Thu Apr 18 23:19:34 GMT 2024

Powered by FUDForum. Page generated in 0.02066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top