Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

One of the tools that I maintain has recently been updated with new functionality and as a result we had to update its MANIFEST.MF file to reference additional jar files in its classpath. Unfortunately the number of referenced jar files went over a limit and during Maven build the following error started to crop up...
 Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar (default-jar) on project MyProject: Error assembling JAR: Unable to read manifest file (line too long) -> [Help 1]


The official documentation had the following note:
Line length:
No line may be longer than 72 bytes (not characters), in its UTF8-encoded form. If a value would make the initial line longer than this, it should be continued on extra lines (each starting with a single SPACE).


In my case, the line length was definitely over 72 bytes, so I proceeded to split each of the jar file dependencies out into its own line. My initial cut of the change had each new jar starting on a new line with a single space character at the beginning of the line. Unfortunately that produced garbage results - it appears that the single space character at the start of a line is a line continuation marker and is stripped when the full line is put together. This results in something like "dep-jar-1.jardep-jar-2.jardep-jar-3.jar..." being created.

Since we want each jar to be separate, a double space is required at the beginning of each line! This looks like the following...
 MANIFEST.MF
Manifest-Version: 1.0
Main-Class: net.igorkromin.MainClass
Class-Path: dep-jar-1.jar
dep-jar-2.jar
dep-jar-3.jar
dep-jar-4.jar
dep-jar-5.jar
dep-jar-6.jar
dep-jar-7.jar
dep-jar-8.jar
dep-jar-9.jar


With double spaces in place, everything worked as expected!



-i

Skip down to comments...
Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
 
comments powered by Disqus
Other posts you may like...