![]() |
Ant Task to Read From Manifest
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 |
Re: Ant Task to Read From Manifest
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" <bremmi@yahoo.com> wrote in message news:2472a627.0401221252.2b9e2c42@posting.google.c om... > 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 |
Re: Ant Task to Read From Manifest
Tony Morris <dibblego@optusnet.com.au> 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. |
| All times are GMT. The time now is 11:54 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.