For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2006 > A simple question about istrue of Ant.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author A simple question about istrue of Ant.
George3 via JavaKB.com

2006-02-25, 3:57 am

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

--
Message posted via http://www.javakb.com
Roedy Green

2006-02-25, 3:57 am

On Sat, 25 Feb 2006 07:56:05 GMT, "George3 via JavaKB.com"
<u19006@uwe> wrote, quoted or indirectly quoted someone who said :

><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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Rhino

2006-02-25, 6:59 pm


"Roedy Green" <my_email_is_posted_on_my_website@munged.invalid> wrote in
message news:8590025clj8rbdru3rei4p7s704jmtkmpq@
4ax.com...
> On Sat, 25 Feb 2006 07:56:05 GMT, "George3 via JavaKB.com"
> <u19006@uwe> wrote, quoted or indirectly quoted someone who said :
>
>
> 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


Rhino

2006-02-25, 6:59 pm


"George3 via JavaKB.com" <u19006@uwe> wrote in message
news:5c65b23356f02@uwe...
> 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
> --------------------
>
>

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


Roedy Green

2006-02-25, 6:59 pm

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
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Rhino

2006-02-26, 7:02 pm


"Roedy Green" <my_email_is_posted_on_my_website@munged.invalid> wrote in
message news:i2p102d237k0mu0dm6pdn8o4483k2cd7g1@
4ax.com...
> On Sat, 25 Feb 2006 09:31:56 -0500, "Rhino"
> <no.offline.contact.please@nospam.com> wrote, quoted or indirectly
> quoted someone who said :
>
>
> 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

2006-02-26, 7:02 pm

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.
..



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

2006-02-27, 7:09 pm

Roedy,


Roedy Green wrote:
>
>without reading the manual are you sure that is "istrue" rather than
>"iftrue"
>
>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

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.as...-setup/200602/1
George3 via JavaKB.com

2006-02-27, 7:09 pm

Rhino,


I fully agree with you! :-)

Rhino wrote:
>[quoted text clipped - 3 lines]
>
>"istrue", not "iftrue", is the correct spelling; this is very clear from the
>manual.
>
>
>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



regards,
George

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.as...-setup/200602/1
George3 via JavaKB.com

2006-02-27, 7:09 pm

Roedy,


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


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


regards,
George

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.as...-setup/200602/1
George3 via JavaKB.com

2006-02-27, 9:58 pm

Rhino,


Rhino wrote:
>[quoted text clipped - 64 lines]
>
>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


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


regards,
George

--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.as...-setup/200602/1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com