Ant Task to Read From Manifest

Discussion in 'Java' started by RyanC, Jan 22, 2004.

  1. RyanC

    RyanC Guest

    I want to have Ant read version information from my manifest files and
    append the version to the end of the jar files it creates. I know I
    could easily just define the versions at the top of the build script
    but they are already maintained in the manifests, so its easier to
    leave them there.

    I understand how to define my own Ant Task and pass information to it,
    but I don't see how I can receive data back from the Ant task.

    Something like (pseudocode):

    import org.apache.tools.ant.Task

    public class GetVersionInfo extends Task {
    String filename;
    String version;
    public void execute() {
    version = readVersionFromFile(filename);
    }

    public void setManifestFileName(String filename) {
    this.filename = filename;
    }

    public String getVersion() .....
    }

    I don't see how this would/could work, or what the task would look
    like. How is it done? Thanks :)

    RyanC
     
    RyanC, Jan 22, 2004
    #1
    1. Advertising

  2. RyanC

    Tony Morris Guest

    I haven't written an Ant task for a while, but I looked at some of my old
    stuff where I've done that, and I simply set a system property.

    I also can't remember why I did that - i.e. did I read it somewhere ? did I
    just make it up ?
    You may want to consult the Apache Ant source for other tasks that set
    properties (maybe that's what I did ?)

    --
    Tony Morris
    (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    Software Engineer
    IBM Australia - Tivoli Security Software
    (2003 VTR1000F)


    "RyanC" <> wrote in message
    news:...
    > I want to have Ant read version information from my manifest files and
    > append the version to the end of the jar files it creates. I know I
    > could easily just define the versions at the top of the build script
    > but they are already maintained in the manifests, so its easier to
    > leave them there.
    >
    > I understand how to define my own Ant Task and pass information to it,
    > but I don't see how I can receive data back from the Ant task.
    >
    > Something like (pseudocode):
    >
    > import org.apache.tools.ant.Task
    >
    > public class GetVersionInfo extends Task {
    > String filename;
    > String version;
    > public void execute() {
    > version = readVersionFromFile(filename);
    > }
    >
    > public void setManifestFileName(String filename) {
    > this.filename = filename;
    > }
    >
    > public String getVersion() .....
    > }
    >
    > I don't see how this would/could work, or what the task would look
    > like. How is it done? Thanks :)
    >
    > RyanC
     
    Tony Morris, Jan 22, 2004
    #2
    1. Advertising

  3. RyanC

    Oscar Kind Guest

    Tony Morris <> wrote:
    > I haven't written an Ant task for a while, but I looked at some of my old
    > stuff where I've done that, and I simply set a system property.
    >
    > I also can't remember why I did that - i.e. did I read it somewhere ? did I
    > just make it up ?
    > You may want to consult the Apache Ant source for other tasks that set
    > properties (maybe that's what I did ?)


    IIRC, your task can communicate with ANT in two ways:
    - Throw a buildException or not. ANT uses this to determine wether the
    task has failed or not.
    - Set a system property. This is te only way to communicate different
    types of success to ANT.

    Additionally, there are several log options. These are only of use to tell
    the user what is going on. AFAIK, ANT ignores it.


    Oscar

    --
    No trees were harmed in creating this message.
    However, a large number of electrons were terribly inconvenienced.
     
    Oscar Kind, Jan 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juergen Weber

    Ant generating Classpath manifest entry

    Juergen Weber, Nov 4, 2003, in forum: Java
    Replies:
    0
    Views:
    2,481
    Juergen Weber
    Nov 4, 2003
  2. Karsten Wutzke

    More memory: Ant and manifest

    Karsten Wutzke, Mar 4, 2004, in forum: Java
    Replies:
    2
    Views:
    767
    Karsten Wutzke
    Mar 5, 2004
  3. Victor
    Replies:
    0
    Views:
    8,873
    Victor
    Sep 1, 2004
  4. krabhi
    Replies:
    1
    Views:
    9,376
    Marco Meschieri
    Aug 9, 2006
  5. teggy
    Replies:
    0
    Views:
    829
    teggy
    May 29, 2007
Loading...

Share This Page