ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garima Bathla <garima.bat...@gmail.com>
Subject Manifest Classpath ( programmatically generated but messedup).
Date Mon, 22 Jun 2009 05:33:12 GMT
Dear Fellow memebers,

I really need help , I have been stuck with same problem for few days now.

Problem:
As we all know, manifest file syntax is very sensitive ( sensitive to
spaces, # of characters in a line, \n character). And I have learnt it very
hard way that if Class-Path in a jar is not set as per the standards it will
be silently ignored.

I am in the process of generating MANIFEST.MF file programmatically by
Extending Jar Task; I am almost there, but the class-path that Jar task
prints in the Manifest file isn't formatted correctly.

*Code snippet:*
*String formattedManifestClassPath = "aaa.jar bbb.jar ccc.jar ddd.jar
eee.jar fff.jar ggg.jar hhh.jar iii.jar jjj.jar kkk.jar lll.jar mmm.jar
nnn.jar ooo.jar ppp.jar qqq.jar rrr.jar sss.jar ttt.jar uuu.jar vvv.jar
www.jar xxx.jar yyy.jar zzz.jar";*
**
*Manifest.Attribute classpathAttribute = new
Manifest.Attribute(Manifest.ATTRIBUTE_CLASSPATH,
formattedManifestClassPath);

*
*manifest.addConfiguredAttribute(classpathAttribute);*

Now the problem is that the Class-Path in MANIFEST.MF file is generated as

*Class-Path: aaa.jar bbb.jar ccc.jar ddd.jar eee.jar fff.jar ggg.jar hh*
* h.jar iii.jar jjj.jar kkk.jar lll.jar mmm.jar nnn.jar ooo.jar ppp.jar*
*  qqq.jar rrr.jar sss.jar ttt.jar uuu.jar vvv.jar www.jar xxx.jar yyy.*
* jar zzz.jar*
* *
So if I run

"java -jar generated.jar"

Class-Path is being ignored, because it is not well formed.  How can I
generate class-path in the correct format? How do I set the String?

I have tried inserting \n ( new line character after every jar entery), but
ManifestClasspath is still not correct as Jar task inserts a new line
character after every 71st character.

formattedManifestClassPath = "aaa.jar \n bbb.jar \n ccc.jar \n ddd.jar \n
eee.jar \n fff.jar \n ggg.jar \n hhh.jar \n iii.jar \n jjj.jar \n kkk.jar \n
lll.jar \n mmm.jar \n nnn.jar \n ooo.jar \n ppp.jar \n qqq.jar \n rrr.jar \n
sss.jar \n ttt.jar \n uuu.jar \n vvv.jar \n www.jar \n xxx.jar \n yyy.jar \n
zzz.jar";

Any pointers if you know will be very helpful.

Regards,
Garima.



**
**
* *

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message