ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: Manifest.MF - classpath is in wrong format when generated programmatically.
Date Mon, 29 Jun 2009 14:39:22 GMT
Just curious: Why don't you use the <manifest> task and the
<manifestClassPath> task?

On Mon, Jun 29, 2009 at 3:02 AM, Garima Bathla<garima.bathla@gmail.com> wrote:
> 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 learn 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 (jar name hhh.jar
> is split over 2 lines).  How can I *generate class-path *in the correct
> format? How do I set the String? Please note I am generating the classpath
> programatically ( by extending the task and passing in the properties)
>
> 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. Is it is a bug?
>
> Regards,
> Garima.
>



-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message