Two Laptop Bag*
The moose likes Ant, Maven and Other Build Tools and the fly likes Trying to combine ant files into one run, and have java pull information from the Manifest. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Trying to combine ant files into one run, and have java pull information from the Manifest." Watch "Trying to combine ant files into one run, and have java pull information from the Manifest." New topic
Author

Trying to combine ant files into one run, and have java pull information from the Manifest.

Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
I'm trying to figure out the best way to explain what I'm looking for here, so please bare with me.


I am writing code that uses an external API from a third party, so I am including several external jars in my build. There are many versions and builds of these jars i need to support. I am working with java 1.5

For example my code needs to work with

Version 5.2 builds 12 and 207

as well as

Version 6.3 builds 022 and 200


Right now I have two Eclipse projects that are specifically coded against the appropriate version, and I have ant files that compile against the appropriate builds of the external jars.

With other builds and versions coming down the road, and things already confusing I want to simplify things, so I have one ANT file to run them all. I"m assuming this won't be too hard, and can be looked up elsewhere.

My issue is that when I run the code from the created jar, I'm printing out information:

External Product: V 5.2 build 12 Product version 1.1.7
Build date: ddMMyyyy

But these are strings that I am manually changing in my code, before I run the appropriate Ant file. Is there a way I can have this information put into the created manifest file, and then have Java read from the Manifest file, so I don't have to even think about it? What I would love to do is to put "V1.1.7" into my master Ant file, and it distributes that information to the other Ant files which then create the proper manifests, which THEN the java reads and spits out the right information to the user.

I will say that I am pretty much am not very experienced with Ant. I created my Ant build about 3 months ago as my first experience with Ant, and asides from copying the file I already created I haven't touched it since.

If anybody has any ideas, or if I'm not being clear in what I'm looking for let me know.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Looks like this http://ant.apache.org/manual/CoreTasks/manifest.html may help
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Let me see if I understand you correctly.

Your app includes a third-party JAR file. When your app starts, it prints out the version number of that third-party JAR file. You have two different version of your app (or two different apps) which use two different versions of the third-party JAR file. You would like the Ant build script to find out as automagically as possible which version of the third-party JAR you are building with. Is that the gist of it?

If so, is there a class that appears in one of the third-party JAR versions but not the other? If so you can use the available task, something like this, with the other version being the default:



In the above example, the com.some.package.ClassName class appears only in the 5.2 version of the third-party JAR file. If that class is in the build classpath, then the version is set to 5.2. If not, the default value of 6.3 is used.


JBoss In Action
 
 
subject: Trying to combine ant files into one run, and have java pull information from the Manifest.