ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garima Bathla <garima.bat...@gmail.com>
Subject Re: Manifest.MF - classpath is in wrong format when generated programmatically.
Date Mon, 29 Jun 2009 16:23:11 GMT
Avlesh,

Thanks, your reply does makes a lot of sense - and honestly what you
suggested I have already tried , the problem with that logic though is that
java -jar command ignores class-path which contains more than one space
character

so e.g.

Class-Path: aaa.jar ssssssssssssss ..(till 71 characters)
  bbb.jar


where s - space character till 71 characters

This is invalid class-path to java -jar command and it is ignored.

I do think this is a bug, not because Manifest.class implementation is not
following the specification, but as a result of following the specification
it is causing the functionality to break; Class-Path that is set if it
cannot be read - is being set incorrectly , hence I call it a bug.

On Mon, Jun 29, 2009 at 12:58 AM, Avlesh Singh <avlesh@gmail.com> wrote:

> Here is what the jar specification has to say on manifest's class-path
> attribute -
>
> The value of this attribute specifies the relative URLs of the extensions
> or
> > libraries that this application or extension needs. URLs are separated by
> > one or more spaces. The application or extension class loader uses the
> value
> > of this attribute to construct its internal search path.
>
>
> And this is the specification on the max_line_length attribute in the
> manifest:
>
> 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).
> >
>
> Bottomline, none of the ANT's implementation is buggy. It is just following
> the specs.
>
> *Solution (IMHO)*
> The solution possibly is to manually check your class-path-attribute string
> for the length 72. If your jar file name is getting splitted because of
> this
> length limit, add extra spaces (which is file according to the specs) until
> the 72nd character. Add your jar file name thereafter. This would not cause
> splits within your file names.
>
> I am curious to know if the above solution works.
> Good luck.
>
> Cheers
> Avlesh
>
> On Mon, Jun 29, 2009 at 12:32 PM, 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.
> >
>

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