caoccao/Javet

Package Size Increase Due to Inclusion of Linux .so Files in Windows JAR

Opened this issue · 4 comments

Hello,
您好,

I've recently encountered an issue where the compiled JAR size for my project has significantly increased after referencing the Javet Windows JAR. Upon investigation, I noticed that the Javet JAR file includes Linux .so files.
我最近在引用Javet Windows JAR后,发现我的项目编译后的JAR大小显著增加。经过调查,我注意到Javet JAR文件中包含了Linux .so文件。

While I understand that these files are necessary for cross-platform compatibility, their presence in a Windows-specific JAR seems to contribute to the bloated package size. This is particularly concerning for projects where minimizing the distribution size is crucial.
虽然我理解这些文件对于跨平台兼容性是必要的,但它们出现在专为Windows设计的JAR中似乎导致了包体积的膨胀。对于那些需要最小化分发大小的项目来说,这一点尤其令人关注。

Is there a possibility to exclude the Linux .so files from the Windows JAR? Any guidance on how to handle this situation would be greatly appreciated.
是否有可能从Windows JAR中排除Linux .so文件?对于如何处理这种情况,如果能提供任何指导,我将不胜感激。

Thank you for your attention to this matter.
感谢您对此事项的关注。

image

image

Thank you for raising the concern. You may simply delete those binaries from the jar file.

e.g. In 7zip, execute 7z d jar_file '*.so'.

Thank you for your prompt response. While I understand the manual deletion of binaries is a workaround, it could be cumbersome for some users. Would it be possible to consider offering separate JAR files like javet-windows and javet-linux? This would allow users to download the specific file for their operating system without the need to manually remove unnecessary binaries, potentially making Javet more user-friendly across different platforms.

Here are the reasons for not doing that.

  1. A simple exclusion rule in the Gradle script can easily exclude the particular resources during the packaging.
  2. Putting more than one reference together will cause duplicated classes in the same package. An exclusion rule needs to be put in the Gradle script.
  3. The permutation of these options will explode (Node.js vs. V8, Linux vs. MacOS vs. Windows, x86_64 vs. arm64). I don't have the mental power to manage all of them from release to release.

Hope these make sense.

Got and thank you.