You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Shackelford, John-Mason" <Sh...@ncs.com> on 2002/08/21 20:51:10 UTC
checking for required attributes
If I want to make sure that the build file doesn't actually execute if
required elements / attributes are not supplied is it an appropriate use of
Task.init() and Task.addConfiguredXXX to ensure that required fields are
populated?
I could not find any tasks that use this approach, which suggests that I am
wrong about this, but if we wait until after the parse phase is over to
check for missing attributes couldn't we be running a script that makes a
big mess because it fails mid execution due to an oversight. At best, it
wastes the user's time while a build that is bound to fail wends it way to
the fatal mistake.
Then again, perhaps I am being anal about this. I never have been terribly
put out by this behavior before.
Of course that is because I use a DTD. :p Which reminds me... will I find
good source that will tell me how to make my custom tasks contribute
accurate info to the auto generated DTD?
John-Mason Shackelford
Software Developer
NCS Pearson - Measurement Services
2510 North Dodge St.
Iowa City, IA 52245
319-354-9200x6214
shacjo@ncs.com
****************************************************************************
This email may contain confidential material.
If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.
****************************************************************************
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: checking for required attributes
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Shackelford, John-Mason wrote:
>
> If I want to make sure that the build file doesn't actually execute if
> required elements / attributes are not supplied is it an appropriate use of
> Task.init() and Task.addConfiguredXXX to ensure that required fields are
> populated?
I'd have to do a bit of trial-and-error on this issue myself, but you
can throw a BuildException from the adders/setters/creators. Many of
Ant's tasks have such complex rules for validation that its impossible
to check them until execute(), thats why you don't see any/many that do
it differently.
> I could not find any tasks that use this approach, which suggests that I am
> wrong about this, but if we wait until after the parse phase is over to
> check for missing attributes couldn't we be running a script that makes a
> big mess because it fails mid execution due to an oversight.
A big mess where? In your temporary 'build' directory? Thats what 'ant
clean' is for! :))
> Of course that is because I use a DTD. :p Which reminds me... will I find
> good source that will tell me how to make my custom tasks contribute
> accurate info to the auto generated DTD?
And how do you propose to make a DTD when you use DynamicConfigurator?
(if you are, that is) - I only made the whole DTD thing a lot tougher by
adding the DynamicConfigurator, unfortunately.
Personally, I don't use a DTD for build.xml - its too dynamic with
<taskdef>'s and all.
Erik
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>