ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ylan Segal" <y...@digiworks.tv>
Subject RE: Echoing message
Date Thu, 11 Oct 2001 23:33:12 GMT
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
>
>
>


Mime
View raw message