I have an Ant script (version 1.5) to generate an executable JAR-file which
I use to deploy my Java application. The JAR-file has a manifest file
including a "Main-Class" tag to start the application as well as a "Class-
Path" tag to list the required libraries. However, if I inspect the
contents of the manifest file I see that Ant has inserted a CR-LF-SPACE
combination every 72 characters, thus corrupting the data. How can I create
a Class-Path entry in my JAR-manifest which is longer than 72 characters?
----------------
***Ant script***
----------------
<project name="Polysun4 BuildDeploy" default="jar">
<description>
Polysun 4:
Kompiliert das ganze Projekt, erzeugt alle Jar-Files und kopiert
das ganze ins Verzeichnis Deploy.
Folgende Pfade muessen gesetzt sein:
ANT_HOME = D:\jakarta-ant-1.5
JAVA_HOME = D:\j2sdk1.4.2_01
Path = ...;D:\jakarta-ant-1.5\bin\
</description>
<path id="classpath">
<pathelement location="lib/polysun/"/>
<pathelement location="lib/forms.jar"/>
<pathelement location="lib/hsqldb.jar"/>
<pathelement location="lib/itext.jar"/>
<pathelement location="lib/jcommon.jar"/>
<pathelement location="lib/jfreechart.jar"/>
<pathelement location="lib/jh.jar"/>
<pathelement location="lib/plastic.jar"/>
<pathelement location="lib/rreport.jar"/>
<pathelement location="trans/Trans.jar"/>
<pathelement location="trans/Trans_de.jar"/>
<pathelement location="trans/Trans_en.jar"/>
<pathelement location="trans/Trans_fr.jar"/>
<pathelement location="help/Help_de.jar"/>
<pathelement location="help/Help_en.jar"/>
<pathelement location="help/Help_fr.jar"/>
</path>
<property name="cp" refid="classpath"/>
<target name="jar" description="Alle Jar-Files erstellen">
<jar jarfile="./deploy/Polysun4/Polysun.jar" basedir="./classes/">
<manifest>
<attribute name="Main-Class" value="ch.spf.PS4Gui.PS4Gui"/>
<attribute name="Class-Path" value="${cp}"/>
</manifest>
</jar>
</target>
</project>
------------
***Result***
------------
Manifest-Version: 1.0
Created-By: Apache Ant 1.5
Main-Class: ch.spf.PS4Gui.PS4Gui
Class-Path: E:\polysun4\dev\polysun4Sources\lib\polysun;E:\polysun4\de
v\polysun4Sources\lib\forms.jar;E:\polysun4\dev\polysun4Sources\lib\h
sqldb.jar;E:\polysun4\dev\polysun4Sources\lib\itext.jar;E:\polysun4\d
ev\polysun4Sources\lib\jcommon.jar;E:\polysun4\dev\polysun4Sources\li
b\jfreechart.jar;E:\polysun4\dev\polysun4Sources\lib\jh.jar;E:\polysu
n4\dev\polysun4Sources\lib\plastic.jar;E:\polysun4\dev\polysun4Source
s\lib\rreport.jar;E:\polysun4\dev\polysun4Sources\trans\Trans.jar;E:\
polysun4\dev\polysun4Sources\trans\Trans_de.jar;E:\polysun4\dev\polys
un4Sources\trans\Trans_en.jar;E:\polysun4\dev\polysun4Sources\trans\T
rans_fr.jar;E:\polysun4\dev\polysun4Sources\help\Help_de.jar;E:\polys
un4\dev\polysun4Sources\help\Help_en.jar;E:\polysun4\dev\polysun4Sour
ces\help\Help_fr.jar
Richard Chrenko - 03 Jun 2004 11:15 GMT
The problem was actually a missing jar file reference, and the truncated
lines (which are apparently due to a peculiarity when viewing JAR-file
contents with a text editor) threw me way off track.
Sorry for the false alarm!
Pedro - 03 Jun 2004 21:29 GMT
> I have an Ant script (version 1.5) to generate an executable JAR-file
> which I use to deploy my Java application. The JAR-file has a manifest
[quoted text clipped - 4 lines]
> How can I create a Class-Path entry in my JAR-manifest which is longer
> than 72 characters?
It is not corrupted. Ant is supposed to do that. From the JAR File specifation:
<quote src="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html">
- 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).
</quote>
Regards,
Pedro