Hi Ian,
I'm really doing my best to understand your point of view, but I regret to
say that I failed :) lol
Take a look at the following sample :
Let's say I want to force a user to specify a build directory on the
commandline in a build.dir property, what I want to do in my build file is :
- add a dependency to the the build target for checking if a build dirctory
was specified (I don't want to check it globally, because for other targets,
the build directory may not be necessary)
- in that dependent task I check if the user specified a build.dir
- if the user didn't specify a build.dir, I want the build to fail
Now the "Ant" way of doing this is :
<target name="build" depends="check-build-dir">
.....
</target>
<target name="check-build-dir" depends="input-build-dir">
<fail message="The build directory has not been specified."
unless="build.dir"/>
<!-- Ant also has tasks for checking if the directory exists and stuff,
but I won't mention them here -->
</target>
<target name="input-build-dir" unless="build.dir">
<input message="Build directory :" addproperty="build.dir" />
</target>
The Nant way of accomplishing this (without asking for user input, which is
not possible yet) :
<!-- add a property with default value "false" in order to prevent the build
from failing -->
<property name="build.dir.ok" value="false" readonly="false"
failonerror="true" />
<target name="build" depends="check-build-dir">
....
</target>
<target name="check-build-dir" unless="${build.dir.ok}">
<if propertyexists="build.dir">
<property name="build.dir.ok" value="true" readonly="false"
failonerror="true" />
</if>
<fail message="The build directory has not been specified."
failonerror="true" unless="${build.dir.ok}" />
</target>
If I want to to exactly the same in Ant then I can do it in just one line :
<target name="check-build-dir">
<fail message="The build directory has not been specified."
unless="build.dir"/>
</target>
Now I don't want to compare Ant and NAnt, but by choosing the name NAnt
you're looking for it, no ? :-)
Don't you agree that the Ant way of doing it is more intuitive and easier to
maintain ? And the Ant version is shorter, and still offers more
functionality (allows the user to input the build dir) ...
I hope you don't get all of this wrong, I really like NAnt ... And it has
potential, but I don't understand why you choose not to follow in the
footsteps of your big brother Ant ? Why not re-use the proven concepts of
Ant ?
In the end, if you don't want to be compatible with Ant (and if you don't
like the way Ant works), then why choose to name it NAnt ?
Please please please don't take this all negative, some criticism doesn't
hurt, does it.
I reallly think you should update the docs to correct these
misunderstandings. I would be glad to help you out on this, and other
things ...
Thanks,
Gert
----- Original Message -----
From: "Ian MacLean" <[EMAIL PROTECTED]>
To: "Gert Driesen" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, February 15, 2003 10:53 AM
Subject: Re: [nant-dev] serious BUGS in current CVS version !!
> Gert,
>
> > I've stumbled upon the following serious bugs in NAnt :
> >
> > when you want to execute a target (or task) only when a certain property
> > has been set, you must use the unless attribute, like this :
> >
> > <target name="retrieve-NET-1.0-SdkRoot" unless="build.net10.sdkroot">
> > <readregistry property="build.net10.sdkroot"
> > key="SOFTWARE\Microsoft\.NETFramework\sdkInstallRoot"
> > hive="LocalMachine" failonerror="true" />
> > </target>
>
> > in this case, the target should only be executed if the
> > "build.net10.sdkroot" was not already set (using the commandline or
> > anywhere else) or if it was set and its value couldn't be converted to a
> > boolean true value.
> >
> > However, it seems as if there are actually three bugs in the way the if
> > and unless attributes work in NAnt :
> >
> > 1. you can't directly specify a property name in the if and unless
> > attribute, you must use ${ ...}
> >
> > when I specify the property name directy (without ${...}) I get the
> > following error message :
> >
> > Cannot resolve to 'build.netcf10.sdkroot' to Boolean value.
>
> This seems reasonable to me. The ${} syntax is used to expand text in
> all attributes in the build file. It does no semantic checking at
> expansion time - it simply macro substitutes the actual property value.
> If the ${} syntax isn't used, how do you propose that we distinguish the
> property build.netcf10.sdkroot from the literal string
> "build.netcf10.sdkroot". The whole point of the ${} syntax is property
> expansion so I'm not sure why you'd expect to be able to reference
> properties without it.
>
> > The documentation clearly states :
> >
> > if = the name of the property that must be set in order for this target
> > to execute.
> > unless = the name of the property that must not be set in order for this
> > target to execute.
> >
> > this is different from the way Ant works, you should be able
> > to specify a property name directly in the if and unless attribute (not
> > using the ${....} syntax)
>
> > 2. when I specify the property name as ${propertyname}, I get the
> > following error :
> >
> > Property 'project.config' has not been set!
>
> OK then I read this differently - maybe the documentation is incorrect
> here. This seems to me to be the difference between null/undefined and
> boolean false. It should probably read :
>
> if = an expression that must evaluate to true in order for this target
> to execute.
>
> you don't have to specify a property value at all. using unless="true"
> works just fine although its not very useful. Probably the reason for
> the mis-definition is that in NAnt, expressions can only be defined by
> properties using ${} or literal strings. so for example you can't say
> unless = "${foo} ==2", you can only do ${foo} or the literals "true" or
> "false".
>
> by this definition its working as it should. Referencing an undefined
> property gives the appropriate error. To get the desired behaviour the
> property should be defined and set to either true or false.
>
>
> > The behaviour of the unless attribute should be :
> >
> > - check if the property exists
> > - if it doesn't exist, exeute the target or task
> I think the current behaviour is correct. In my opinion an undefined
> property shouldn't be treated the same as false.
>
> > - if the property does exist, try to convert the value of the
> > property to a boolean value
> yep
> > - if you can't convert it to a boolean value, consider the value to be
> > "true" so don't execute the target or task
> I disagree here. This check is valuable in catching property assignment
> errors - say if you intended to set a property to "true" but typed "tue"
> - in your scenario this would just cause the target to be skipped and
> the user would get no feedback that they had set the value incorrectly.
>
> > - if you can convert the value to a boolean, execute the task or target
> > when the value is FALSE, DON'T execute it when the value is TRUE
>
> I'm right with you here.
>
> > I'm pretty sure this is how it should work, and I'm pretty sure that's
> > how Ant works !
> Well I think thats open to discussion. I can't speak for how Ant works.
> There are a number of things we do differently to Ant.
>
> Full compatibility isn't necessarily a goal. If its the "right" thing to
> do - yes but not just because we want to do what Ant does.
>
>
> > 3. Apparently the if and unless attributes are evaluated before the
> > dependent targets are executed, this is another major BUG.
> >
> > The dependent targets should be executed before the unless or if are
> > evaluated.
> > This is how Ant does it, and this is how it should be done !
> >
>
> This one could be read either way. It seems to me that if you don't want
> a given target to build then you don't want its dependencies to build
> either - thats why you set the dependencies up that way in the first
> place - ie so that a target and its dependencies form an atomic unit of
> sorts.
>
> To turn off a whole chain of dependencies you would have to specify the
> 'unless' attribute for each target in the chain.
> Its certainly woth discussing but I wouldn't call it a showstopper.
>
> >
> > I think these are really show-stoppers, don't you agree ?
>
> I have to disagree. You've raised some valuable questions about how Nant
> executes targets and evaluates properties. However in my view the only
> real bug is lack of clarity in the documentation regarding the unless
> and if attributes. All these things have been that way since the if and
> unless attributes were introduced. I haven't had a problem with them
> being this way but maybe others have.
>
>
> Ian
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Nant-developers mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/nant-developers
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers