Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2006

Tip: Looking for answers? Try searching our database.

A simple question about istrue of Ant.

Thread view: 
George3 - 25 Feb 2006 07:56 GMT
Hello everyone,

I have written the folllowing scripts, just want to output "Foo is true."
when the property foo is set to true. But when using Eclipse to run the
simple script, there are something wrong. Could anyone help to check what is
the wrong with my shell scripts?

Source codes,

--------------------
<project default="Trivial">
<target name="Trivial">
<echo>Target trivial is running.</echo>
<property name="foo" value="true" />
<istrue value="${foo}" />
<then>
<echo> Foo is true. </echo>
</then>
</target>

</project>
--------------------

Error messages,
--------------------
Buildfile: C:\Documents and Settings\Admin\TestBuild.xml
Trivial:
[echo] Target trivial is running.
BUILD FAILED: C:\Documents and Settings\Admin\TestBuild.xml:5: Could not
create task or type of type: istrue.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'istrue'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
Total time: 391 milliseconds
--------------------

thanks in advance,
George
Roedy Green - 25 Feb 2006 09:35 GMT
><istrue value="${foo}" />
><then>
><echo> Foo is true. </echo>
></then>

without reading the manual are you sure that is "istrue" rather than
"iftrue"

It amzasing how ANT XML contorts familiar logic syntax.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Rhino - 25 Feb 2006 14:31 GMT
>><istrue value="${foo}" />
>><then>
[quoted text clipped - 3 lines]
> without reading the manual are you sure that is "istrue" rather than
> "iftrue"

"istrue", not "iftrue", is the correct spelling; this is very clear from the
manual.

> It amzasing how ANT XML contorts familiar logic syntax.

I won't deny that Ant's handling of conditionals is decidedly awkward and
counterintuitive. Nevertheless, you could have taken 3 seconds to check the
manual, like I did, before suggesting that the statement was misspelled.

--
Rhino
Roedy Green - 25 Feb 2006 23:12 GMT
On Sat, 25 Feb 2006 09:31:56 -0500, "Rhino"
<no.offline.contact.please@nospam.com> wrote, quoted or indirectly
quoted someone who said :

>I won't deny that Ant's handling of conditionals is decidedly awkward and
>counterintuitive. Nevertheless, you could have taken 3 seconds to check the
>manual, like I did, before suggesting that the statement was misspelled.
See http://mindprod.com/jgloss/newsgroups.html#GIFTHORSE
and http://mindprod.com/jgloss/newsgroups.html#ENTITLEMENT
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Rhino - 26 Feb 2006 13:42 GMT
> On Sat, 25 Feb 2006 09:31:56 -0500, "Rhino"
> <no.offline.contact.please@nospam.com> wrote, quoted or indirectly
[quoted text clipped - 7 lines]
> See http://mindprod.com/jgloss/newsgroups.html#GIFTHORSE
> and http://mindprod.com/jgloss/newsgroups.html#ENTITLEMENT

These "rebuttals" would have more weight if I were the original poster
complaining about your answer; I'm not. I'm just saying that speculating
that it was a typo may well waste more of the poster's time than it would
have taken you to confirm that it wasn't misspelled.

--
Rhino
Roedy Green - 26 Feb 2006 18:12 GMT
On Sun, 26 Feb 2006 08:42:22 -0500, "Rhino"
<no.offline.contact.please@nospam.com> wrote, quoted or indirectly
quoted someone who said :

>These "rebuttals" would have more weight if I were the original poster
>complaining about your answer; I'm not. I'm just saying that speculating
>that it was a typo may well waste more of the poster's time than it would
>have taken you to confirm that it wasn't misspelled.

You know well the ANT manuals are hardest to find anything in of any
manuals you would routinely use in a day.  It was much easier for you
to check that.  You might not even need to open the page since it was
fresh in your mind. You could have the spot bookmarked.  I, on the
other hand would have to go digging for it, then still not be sure if
there were both iftrue and istrue commands buried in there somewhere.

The onus is always on the questioner to do any legwork.  I did not
send you on a goose chase. I just offered you one possible thing to
double check if you were stuck.

In the last while, I wrote GrowingArrayList, UTF8Encoder, UTF8Decoder,
TestOnTheFly, TestCollisionProbability, TestHebrew, TestImAlive,
TeshHashMap, UTF8...   all at the indirect request of people in this
newsgroup to help them solve their problems. It is not that I am
unwilling to do you much bigger favours than looking up a command in
the ANT manual, it is just I am only willing to do them as favours,
not as sacrificial offerings to the gods.
.

.  
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

George3 - 27 Feb 2006 14:58 GMT
Roedy,

>On Sun, 26 Feb 2006 08:42:22 -0500, "Rhino"
><no.offline.contact.please@nospam.com> wrote, quoted or indirectly
[quoted text clipped - 26 lines]
>
>.  

You both are good guys here. Take it easy. You are both more famous than me. :
-)

regards,
George
George3 - 27 Feb 2006 14:54 GMT
Rhino,

I fully agree with you! :-)

>>><istrue value="${foo}" />
>>><then>
[quoted text clipped - 13 lines]
>--
>Rhino

regards,
George
George3 - 27 Feb 2006 14:53 GMT
Roedy,

>><istrue value="${foo}" />
>><then>
[quoted text clipped - 5 lines]
>
>It amzasing how ANT XML contorts familiar logic syntax.

I think in Ant, we should use "istrue" other than "iftrue" in the manual.

regards,
George
Rhino - 25 Feb 2006 14:41 GMT
> Hello everyone,
>
[quoted text clipped - 64 lines]
> Total time: 391 milliseconds
> --------------------

The <istrue> condition needs to be a sub-part of a <condition>; the way you
have written it makes Ant think it is a target.

Here is an example that I found when I was first learning how to use
conditions; perhaps it will be helpful to you in understanding how to use
conditions:

================================================================
<?xml version="1.0"?>

<project name="Flow.Of.Control" default="simple-if" basedir=".">

<property name="client.only" value="false"/>

<target name="simple-if">

<condition property="client-not-proc">

<istrue value="${client.only}"/>

</condition>

<antcall target="outer.then"/>

<antcall target="outer.else"/>

</target>

<target name="outer.then" if="client-not-proc">

<echo>client-only = TRUE</echo>

</target>

<target name="outer.else" unless="client-not-proc">

<echo>client-only = FALSE</echo>

</target>

</project>

================================================================

If you put different echo statements at each branching point in this example
and then play with different values of the properties, you should be able to
see how the conditionals work.

The explanations in the Ant manual are, unfortunately, not very good in many
cases. I have often been frustrated by the code fragments that are supposed
to show you how to do something but actually confuse you more than help you
because they are not complete, self-contained examples. You think that they
are complete examples but they are often just one or two lines taken out of
context.

It can be helpful to do searches in the Ant archives to find more complete
examples than the ones in the manual. A searchable copy of the Ant archives
can be seen at
http://marc.theaimsgroup.com/?l=ant-user&r=1&w=2

--
Rhino
George3 - 28 Feb 2006 02:47 GMT
Rhino,

>> Hello everyone,
>>
[quoted text clipped - 64 lines]
>--
>Rhino

I have read through the Demo. It gives me some hints. Thanks a lot!

regards,
George


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.