Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Ant Task to Read From Manifest (http://www.velocityreviews.com/forums/t130623-ant-task-to-read-from-manifest.html)

RyanC 01-22-2004 08:52 PM

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

Tony Morris 01-22-2004 10:35 PM

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




Oscar Kind 01-23-2004 12:17 AM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57