zyxist / chainsaw

Gradle plugin: adds support for building Java 9 modules.
Apache License 2.0
70 stars 4 forks source link

generated start scripts get "destroyed" #12

Closed Vampire closed 6 years ago

Vampire commented 6 years ago

You manipulate the generated start scripts and thereby destroy their line endings. The windows start script must have windows style line endings, the unix start script must have unix style line endings. With your code, you read in all lines of the scripts and then write it out with the current platform line ending. This either destroys the line endings of the windows start script if you build on *nix or the line endings of the unix start script if you build on Windows. You must save the start scripts with the correct line ending. If you don't want to hard-code them, you can use org.gradle.util.TextUtil.getWindowsLineSeparator() and org.gradle.util.TextUtil.getUnixLineSeparator(). Or you could maybe just read the whole file into one String, do the replace on the whole String and then write out the String to the file again. Would also be more performant, as it doesn't make too much sense to do the replace on each line. Besides that in this case you should pre-compile the regex instead of using String#replaceFirst which requires to compile the regex for each and every single line and thus cost pretty much performance.

zyxist commented 6 years ago

Regarding #12, #13, and #14 - the piece of code for generating startup scripts is mostly inherited from experimental-jigsaw and I did not do any improvements in this area. I see that this functionality is important for you, so I'll focus on it in the next days to fix the issues you have found. Thanks for your contributions :).

Vampire commented 6 years ago

I didn't imply it was your fault, I just reported it to you as you actively maintain your plugin. :-) I'll report to Gradle guys also in case they revive their stuff. Thanks for taking care.