guziks / warp4j

Turn JAR (java archive) into self-contained executable in a single command
13 stars 4 forks source link

Fails on ktlint with shell script header #2

Open jayvdb opened 2 years ago

jayvdb commented 2 years ago

Processing https://github.com/pinterest/ktlint/releases/download/0.45.2/ktlint fails because it has a shell script before the zip file.

$ mv ktlint ktlint.jar
$ warp4j ktlint.jar
Error: File "ktlint.jar" is not a java archive
jayvdb commented 2 years ago

The reason is warp4j uses file, and expects the output to contain either "Java" or "Zip", and it doesnt do that for these files.

% file /tmp/ktlint
/tmp/ktlint: POSIX shell script executable (binary data)
% /usr/local/Cellar/file-formula/5.41/bin/file /tmp/ktlint
/tmp/ktlint: POSIX shell script executable (binary data)

Searching for "jar" in https://bugs.astron.com/view_all_bug_page.php reveals nothing of interest, so I created https://bugs.astron.com/view.php?id=342 about this issue. Probably still want a local workaround.

There is already a check if the extension is ".jar", but it is only used if file mentions "Zip" or "Java". Perhaps the file check can be loosened to also include "POSIX shell script executable (binary data)", which hints that it is more than a normal shell script. e.g. on my macos brew collection, only one (1) of 245 scripts in /usr/local/bin/ gets flagged as (binary data).

% file /usr/local/bin/* | grep POSIX | wc -l
     245
% file /usr/local/bin/* | grep POSIX | grep binary
/usr/local/bin/rcs2log:                             POSIX shell script executable (binary data)
jayvdb commented 2 years ago

Once that is bypassed, I can get a working warped ktlint with warp4j --macos --java-version 15 --no-optimize ktlint.jar