phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

FileCodeWriter uses PrintWriter, which in turn uses localized lineSeparator #39

Closed jjYBdx4IL closed 8 years ago

jjYBdx4IL commented 8 years ago

For obvious reasons I don't want the generated java source code files to be dependent on where I execute the codemodel code. Please give me an option to set the lineSeparator manually or always use UNIX lineSeparators. TY!

jjYBdx4IL commented 8 years ago

Didnt check, but I guess the output encoding is according to the environment, too, then. UTF-8 + UNIX LF should be the way to go nowadays.

BTW nice work. And about time someone continues that great library.

phax commented 8 years ago

Well the encoding can be provided in the FileCodeWriter constructor so no action needed here. By default the system encoding is used and I don't want to change this.

phax commented 8 years ago

A simple work around for all existing releases is to set the system property line.separator to the correct separator (e.g. System.setProperty ("line.separator", "\n");) before writing stuff out.

phax commented 8 years ago

JCodeModel.setBuildingCharset (Charset) and JCodeModel.setBuildingNewLine (String) should do the trick for you. Please verify and let me know if it works. If yes, I will build a new release.

jjYBdx4IL commented 8 years ago

Works. Nice. TY!

phax commented 8 years ago

Release 2.8.2 is out and soon on Maven central