Closed GitGraf closed 2 years ago
Bnd uses LF line endings for the formatted output in bnd/bndrun files.
Using different line ending for Windows than for other systems just leads to problems and frustration. I would venture that all important developer tools for Windows work fine with LF line endings and that you should consider migrating your project to consistently use LF line endings. Bnd itself uses LF line endings everywhere.
https://github.com/bndtools/bnd/blob/69e89a439548278fe1156f61f7ebeefc204975ff/.editorconfig#L5-L6
Changing Bnd to use platform specific line endings for the formatted output in bnd/bndrun files (that is, CRLF on Windows) will create havoc for the existing user base which is expecting LF line endings.
For your usage here, I would suggest you use outputBndrun
as mentioned here:
https://github.com/bndtools/bnd/tree/master/gradle-plugins#create-a-task-of-the-resolve-type
Later tasks which depend on outputBndrun
can be configure as mentioned here:
https://github.com/bndtools/bnd/tree/master/gradle-plugins#create-a-task-of-the-testosgi-type
See https://github.com/osgi/osgi-test/blob/main/examples/osgi-test-example-bndworkspace/org.osgi.test.example.player.test/build.gradle for an example of doing this.
Okay, while looking through the bnd repository I did get the impression that the LF line endings are intentional, thank you for explanation on this. It looks like migrating my project to use LF will cause some issues and is currently not an option. By using your examples I was able to implement a "Line Endings Fixer" Gradle task to solve my issue.
Closing this.
There is an option in git to normalize line endings. Many projects have mixed PC / Mac+Linux users.
I assume you are referring to the "core.autocrlf" git option. Since we are using Windows, we have it set to checkout Windows Style and commit Unix style. The difference in line endings is not causing any issues per se, it's just that TortoriseGit detects differences in bndrun files after I resolve them (even if nothing changed - Except for the line endings).
See .gitattributes which can configure line ending by file type. It is quite useful.
Version: BND Gradle Plugin: "biz.aQute.bnd.builder" Version 6.4.0 Java: openjdk version "1.8.0_275" OpenJDK Runtime Environment Corretto-8.275.01.1 (build 1.8.0_275-b01) OpenJDK 64-Bit Server VM Corretto-8.275.01.1 (build 25.275-b01, mixed mode) OS: Windows 10
I am using the Bnd Gradle Plugin to resolve my bndrun files. I have noticed that Git seems to detect changes to my bndrun file after resolving, even if the content of the file stays the same. After some head scratching I noticed that what's different is the line endings in the "-runbundles" section, they have seemingly been converted from CRLF to LF.
My project contains multiple bndrun files, so I have a utility script to resolve all of them at once. When I do this, Git always tells me that all of the bndrun files have changes to be committed, even if the difference is just in line endings.
Is there a way to tell the plugin to use the line endings of the current OS? Or is it intentional that they are always changed to unix style line endings, even if the bndrun file does not need to be updated in the first place?
Steps to reproduce:
gradlew resolve
, my bndrun file now looks like this:-runbundles: \ org.apache.felix.scr;version='[2.1.16,2.1.17)',\ org.osgi.util.promise;version='[1.1.1,1.1.2)',\ org.osgi.util.function;version='[1.1.0,1.1.1)'