Ant Task to Read From Manifest

R

RyanC

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
 
T

Tony Morris

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)
 
O

Oscar Kind

Tony Morris said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top