ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Kohler <jkoh...@daforma.com>
Subject RE: adding class-path to manifest
Date Thu, 12 Apr 2001 14:06:35 GMT
I've developed a task that will create a jar from a 
set of 'root' classes, including all dependant classes
along with other arbitrary files.  

Moreover, you can specify the content of the manifest file
directly in the build.xml, e.g.:

<genjar jarfile="theJarFile.jar">
  <class name="foo.bar.Main" /> 
  <classfilter>
    <exclude name="org."/>
  </classfilter>
  <resource pkg="foo.bar">
    <fileset dir="images"/>
  </resource>
  <manifest>
    <attribute name="Class-Path" value="./xerces.jar" />
    <attribute name="Main-Class" value="foo.bar.Main" />
  </manifest>
</genjar>

This task will put in the jar, all files referenced
by foo.bar.Main except those in the 'org.' package.
Additionally it will include all files in the image
directory (changing their package to foo.bar).
And it creates a manifest with the 'Class-Path' and
'Main-Class' attributes.

I created this task because I do not like maintaining
a seperate manifest.

Source and docs are attached, hope it's useful.

John Kohler

> -----Original Message-----
> From: Marc Portier [mailto:Marc.Portier@the-ecorp.com]
> Sent: Thursday, April 12, 2001 3:59 AM
> To: ant-user@jakarta.apache.org
> Subject: RE: adding class-path to manifest
> 
> 
> have been looking into the ant code since my posting
> (quite impressed by the introspection architecture, learning a lot,
> wondering if there are any design docs or manuals saying more 
> about building
> your own ant tasks?)
> 
> in every case ant is sliding in a copy of some default 
> manifest file (see
> Jar.java in taskdefs package)
> for whenever anyone is omitting the manifest attribute
> 
> that default manifest file is in the ant.jar at
> "/org/apache/tools/ant/defaultManifest.mf"
> 
> by the way: the jar task is a subclass of the zip task... 
> don't have the
> impression it's using the JDK jar.
> 
> have to dig some more to understand if my bold statement 
> about sliding in a
> line or two still holds :-)
> 
> current (limited) understanding is that some nested 
> <manifest> element in
> the <jar> task would require some
> createManifest() method that get's called to configure the 
> task (have to
> read more, the xml driving the introspection is pretty absa 
> great stuff)
> 
> during the execute() of the task a manifest file could then 
> be created (as
> temp file) or probably better using some pipeIO the task 
> could write into
> the zip directly
> 
> hope I find some more time to actually try some out...
> any more ideas/hands welcome
> -marc=
> 
> > -----Original Message-----
> > From: Isaac Sparrow (Staff Engineer)
> > [mailto:isaac.sparrow@visicomp.com]
> > Sent: vrijdag 13 april 2001 11:27
> > To: ant-user@jakarta.apache.org
> > Subject: Re: adding class-path to manifest
> >
> >
> > Interesting question about the culprit adding the manifest
> > file. I would
> > *guess* that the underlying jdk is generating it. If you
> > manually create
> > a jar file, with out a manifest, you will find a directory 
> in that jar
> > (META-INF) containing a manifest file. If I remember correctly, I've
> > seen this behavior on Windows 98/NT and Linux while 
> manually creating
> > jar files.
> >
> > Thanks for further clarifying my comments on the jar task.
> >
> > --Isaac Sparrow
> >
> > Marc Portier wrote:
> > >
> > > taking this step by step:
> > > 1. you create your build file as suggested by Isaac
> > >  <jar
> > >     jarfile="NameofJartoCreate.jar"
> > >
> > >
> > basedir="wheretojarfrom_is_a_directory_that_holds_NO_Manifest.
> > mf_in_either_s
> > > ubdir"
> > >     manifest="yourManuallyEdited.mf"
> > >  />
> > > 2. you manually edit your own Manifest file, but you don't
> > put it in the
> > > basedir somewhere
> > >   _manually_ means you edit yourself the file to hold the line:
> > >     Class-Path: struts.jar
> > > 3. instead you put it and call it as denoted in the
> > manifest attribute of
> > > the jar task
> > >
> > > said all that I do understand what you're getting at, I think...
> > > the point is that you probably already have some ${cp}
> > property you're using
> > > in some <target name="testrun" />
> > > and you (well, we all, I guess) hate the idea that you
> > manually have to sync
> > > additional needed jars in both the build.xml and the infamous
> > > yourManuallyEdited.mf
> > > (by the way: the same holds for the Main-Class manifest
> > entry that doubles
> > > to the java classname="Main-Class" attribute, this for 
> the java -jar
> > > addicts)
> > >
> > > would be interesting to understand how the jar task now
> > generates it's own
> > > Manifest.mf... and have a look into how that could be
> > extended to maybe
> > > slide in a line or 2?  (maybe it's not even the jar task
> > doing it but the
> > > underlaying JDK utility?)... that, or a manifest-building
> > task preceeding
> > > the jar task?
> > >
> > > -marc=
> > > > -----Original Message-----
> > > > From: G.L. Grobe [mailto:gary@grobe.org]
> > > > Sent: donderdag 12 april 2001 0:59
> > > > To: ant-user@jakarta.apache.org
> > > > Subject: Re: adding class-path to manifest
> > > >
> > > >
> > > > So if NameofJartoCreate.jar is the jar i'm creating and it
> > > > depends on an
> > > > external jar called struts.jar, where is the file struts.jar
> > > > or it's path to
> > > > struts.jar being added? All I can see from here is that
> > I'd know what
> > > > manifest to use.
> > > >
> > > > <jar
> > > >     jarfile="NameofJartoCreate.jar"
> > > >     basedir="wheretojarfrom"
> > > >     manifest="nameofManifestfile"
> > > > />
> > > >
> > > > Thnxs for replying
> > > >
> > > > ----- Original Message -----
> > > > From: "Isaac Sparrow (Staff Engineer)"
> > <isaac.sparrow@visicomp.com>
> > > > To: <ant-user@jakarta.apache.org>
> > > > Sent: Wednesday, April 11, 2001 5:53 PM
> > > > Subject: Re: adding class-path to manifest
> > > >
> > > >
> > > > > "G.L. Grobe" wrote:
> > > > > >
> > > > > > Reposting for some help here.
> > > > > >
> > > > > > How do you tell Ant to add an external jar file to the
> > > > MANIFEST.MF that
> > > > > > my-ejb.jar file depends on? If I manually add the
> > > > MANIFEST.MF, it get's
> > > > > > ignored and Ant creates an empty one.
> > > > > >
> > > > > > I need this in the file (I think) as my ejb's are not
> > finding the
> > > > correct
> > > > > > paths to this jar.
> > > > > >
> > > > > > Class-Path: ../struts.jar
> > > > > >
> > > > > > Any help much appreciated.
> > > > >
> > > > > I have ant add a manifest I have created like this:
> > > > >
> > > > > <jar
> > > > >    jarfile="NameofJartoCreate.jar"
> > > > >    basedir="wheretojarfrom"
> > > > >    manifest="nameofManifestfile"
> > > > > />
> > > > >
> > > > >
> > > > > Hope this helps!
> > > > >
> > > > > --
> > > > > --Isaac Sparrow
> > > > > --------------------------
> > > > > Staff Engineer
> > > > > VisiComp, Inc.
> > > > >
> > > > > http://www.visicomp.com
> > > > >
> > > >
> >
> > --
> > --Isaac Sparrow
> > --------------------------
> > Staff Engineer
> > VisiComp, Inc.
> >
> > http://www.visicomp.com
> >
> 


Mime
View raw message