mikepenz / AboutLibraries

AboutLibraries automatically collects all dependencies and licenses of any gradle project (Kotlin MultiPlatform), and provides easy to integrate UI components for Android and Compose-jb environments
http://mikepenz.github.io/AboutLibraries/
Apache License 2.0
3.66k stars 423 forks source link

Sort additional licenses under configPath #856

Closed rocka closed 1 year ago

rocka commented 1 year ago

About this issue

This issue counts for reproducible builds too (see #784 for more explanation). For what I'm working on (https://github.com/fcitx5-android/fcitx5-android to be exact), we have several native library dependencies so we use configPath property and put their licenses in app/licenses/libraries directory. The problem is, every time we run the build in a new environment, the order of licenses in generated json file varies.

After some investigation, I found that additional licenses are read by [listFiles()](https://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles()), and there is no guarantee of string order:

https://github.com/mikepenz/AboutLibraries/blob/f84b96d454b430679e7263b8d0ab24778cc07789/plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/parser/LicenseReader.kt#L11-L15

In my perspective, simply

licensesDir.listFiles()?.sortedBy { it.name }

would fix this issue. It would be nice if we can have this feature to further improve reproducibility, or at least have it as an option.

Details

mikepenz commented 1 year ago

@rocka that's a great suggestion, we probably should do that for the whole list of libraries prior to writing them out to the json.