-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document prependShellScript
(was: Assembly JAR produces invalid zip listing)
#580
Comments
Some additional information:
which would seem to indicate that the issue is caused by a difference in the way the jars are produced. As noted above, there is a difference in the way the jars are produced. |
This happens because mill prepends a shell script to the assembly jar which means it is executable. Ie you can run If you run Most tools which operate on zip files ignore this data (maybe with a warning). If is causing problems you can add: def prependShellScript = "" to your build, which will prevent the script being prepended. |
Thanks, @ajrnz. That fixed it. |
Is this already documented somewhere? |
Not that I know of |
I'll reopen as a marker, that we should document |
prependShellScript
(was: Assembly JAR produces invalid zip listing)
Makes sense, @lefou. Thanks. |
Bumping this issue because I just ran into it. Thanks for the investigation @fitzn! Documenting it is straightforward, but maybe we should consider changing this behavior? I'm not sure the benefits of being able to execute the jar directly is worth the subtle problems this can cause. |
I've hit this issue too, but only once in the last 3 years of using Mill, and worked around it as described above. I use the executable jars regularly, so we should definitely keep them, though it would be nice if we could figure out what's causing the invalid zips and just fixing it |
See also issue #528 and the comments (towards the end). #528 (comment) and #528 (comment) Since then we got some fixes applied to os-lib and mill. Could you please comment here, if this issue is still present? And if, can you please post your reproducer so that I can convert it into a test case? Thanks! |
Going to call this fixed, as a dupe of the other ticket. Feel free to open a new issue if you still see problems |
@lihaoyi This issue was about documentation in the end. Is this now documented? I yes, please also add the appropriate milestone of the release that fixed it. |
A jar is simply a zip file, but manipulating the mill assembly jar with some Unix-like utilities produces different, incorrect output when compared to that of a "normal" jar produced by the Java
jar
command. See the following example for details on these differences.Consider a simple project:
This project compiles without issue and produces an assembly jar that executes without issue:
Furthermore, the assembly jar file's contents appear to be well-formed:
However, the following commands show that the generated jar does not behave as expected when we use the
jar xvf
command. Additionally, it cannot be manipulated by thezip -d
command, both of which work for "normal" jars produced by thejar
command.One command that does work with the mill assembly jar is the regular
unzip
command. We'll use that command to unzip the jar contents, as demonstrated below:Note the warning error:
Finally, if we create a "normal" jar using the
jar
utility and the exact same files that we just unpacked from the mill assembly jar (including the manifest), the resulting jar can be manipulated by thejar xvf
(omitted below) andzip -d
commands without issue.If we compare the
original.jar
andnormal.jar
file sizes, the mill assembly jar is 239 bytes larger, which is close to the 193 bytes difference stated in the warning:Giving the warning noted above:
The assembly jar creation process is the likely culprit for the issue. Given that the
normal.jar
used the exact sameMANIFEST.MF
file as the mill assembly jar, I think it's safe to assume that the issue with the mill assembly jar is not related to the contents of the manifest file or any of the Java files in the archive.Looking at the assembly and regular jar creation logic in mill's Jvm.scala, there are differences in how the two methods produce their files, specifically around the use of
JarOutputStream
. My guess is the error lies somewhere in these differences.If I can provide any more information about this issue, please let me know. Thank you for taking a look and, in general, for providing this very useful project.
The text was updated successfully, but these errors were encountered: