You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "ALI,HANEEF (HP-Cupertino,ex1)" <ha...@hp.com> on 2001/10/12 01:20:54 UTC

Echoing message

Hi,

I want to warn the user that some thing is missing.How to do it easily.?

Eg:
 <available property="junit.present" 
 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"
             classpathref="classpath" />

if the property junit.present is not set I want to warn the user that
junit.jar is not
in classpath.

We can do this by having a separate target, but there are many such warning
message and
i don't want to create a target for each and every message

Thanks
Haneef
 

RE: Echoing message

Posted by Ylan Segal <yl...@digiworks.tv>.
> Just FYI: Stefan added an <isset> element to the <condition> task, so you
> can directly test if a property is simply set (not sure if it's going to
> be available with 1.4.1 or if it's only for 1.5).
>
Great! That is exactly what I needed in the first place (but your workaround
does work pretty well Diane).

Ylan


RE: Echoing message

Posted by Diane Holt <ho...@yahoo.com>.
--- Ylan Segal <yl...@digiworks.tv> wrote:
> You can check for the presence of properties and make a target that
> displays help for the user if not all properties are set. Enclosed is
> part of my build file where I use this behavior:
[snip]

Just FYI: Stefan added an <isset> element to the <condition> task, so you
can directly test if a property is simply set (not sure if it's going to
be available with 1.4.1 or if it's only for 1.5).

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

RE: Echoing message

Posted by Ylan Segal <yl...@digiworks.tv>.
You can check for the presence of properties and make a target that displays
help for the user if not all properties are set. Enclosed is part of my
build file where I use this behavior:

...
<target name="check" description="Checks weather project is ready for
building">
	<tstamp/>
	<echo message="Build started: ${DSTAMP}"/>
	<property name="check.src.home" value="$${src.home}"/>
	<property name="check.compile.to" value="$${compile.to}"/>
	<property name="check.dist.home" value="$${dist.home}"/>
	<property name="check.javadoc.home" value="$${javadoc.home"/>
	<property name="check.doccheck.home" value="$${doccheck.home}"/>
	<property name="check.packages" value="$${packages}"/>
	<property name="check.lib.home" value="$${lib.home}"/>
	<property name="check.extlibs.home" value="$${extlibs.home}"/>
	<condition property="missing.properties">
		<or>
			<equals arg1="${check.src.home}" arg2="${src.home}"/>
			<equals arg1="${check.compile.to}" arg2="${compile.to}"/>
			<equals arg1="${check.dist.home}" arg2="${dist.home}"/>
			<equals arg1="${check.javadoc.home}" arg2="${javadoc.home}"/>
			<equals arg1="${check.doccheck.home}" arg2="${docheck.home}"/>
			<equals arg1="${check.packages}" arg2="${packages}"/>
			<equals arg1="${check.lib.home}" arg2="${lib.home}"/>
			<equals arg1="${check.extlibs.home}" arg2="${extlibs.home}"/>

		</or>
	</condition>
	<antcall target="help"/>
</target>

<!-- Gives intructions on how to proceed if check is not succesful -->
<target name="help" if="missing.properties">
	<echo>
	Not all needed properties are set!!!
	This build file needs a build.properies file to set the following
properties:
		src.home - The source code (.java files) home.
		compile.to - Where the classes are compiled to.
		dist.home - The directory where distribution files are created.
		javadoc.home - The directory for the javadoc html.
		doccheck.home - The directory for the DocCheck html
		packages - the packages to compile, it accepts * (ie tv.*)
		lib.home - Directory where needed jar's are stored.
		extlibs.hom - Directory where needed jar's are copied from.

	Other properties can also be set in this file (like build.compiler, etc).
	</echo>
	<fail message="Not all needed properties are set!!!"/>
</target>
...
Then I make all other targets depend on check.. the build will not work
unless all properties are set as I want them to..
In your case, you are checking for classnames, but I think you can make it
work in the same way.

> -----Original Message-----
> From: ALI,HANEEF (HP-Cupertino,ex1) [mailto:haneef_ali@hp.com]
> Sent: Thursday, October 11, 2001 5:21 PM
> To: ant-user@jakarta.apache.org
> Subject: Echoing message
>
>
> Hi,
>
> I want to warn the user that some thing is missing.How to do it easily.?
>
> Eg:
>  <available property="junit.present"
>
> classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"
>              classpathref="classpath" />
>
> if the property junit.present is not set I want to warn the user that
> junit.jar is not
> in classpath.
>
> We can do this by having a separate target, but there are many
> such warning
> message and
> i don't want to create a target for each and every message
>
> Thanks
> Haneef
>
>
>