I'm not very well up on ant, trying to learn a few things about it this afternoon.

Is it possible to read in values from the command-line ant call? The scenario I have in mind is this: I want to make a generic build file that would have targets for the basics (init, compile, clean, make_jar). I'd like to be able to do something like:

ant jarfile "Hello.jar" "Hello"

and use "Hello.jar" as the name of the generated jar file and "Hello" as the name of the main class in the manifest.

I don't see any way to do this in the ant documentation - the <arg> tag doesn't seem like much help here - but maybe I'm missing something. I can see how I'd do it with a properties file, but not from the command like. Any ideas, or is this impossible in ant?

(obviously I could write a quick bit of perl to configure the generic build file for each project, but I want to see what I can do with ant itself)

If I understand correctly what you are after, pass relevant properties as command line arguments. For example, -Dsrc=Hello (details really depend on your ant file).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.