More goodness

----------  Forwarded Message  ----------

Subject: Re: [idea] Notion of required and optional properties
Date: Sun, 31 Mar 2002 08:34:45 -0500
From: "Erik Hatcher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>

One related note: Ant 1.5 supports if/unless on the <fail> task.  So you can
kill a build if required properties aren't set like this:

    <fail unless="build.dir">build.dir not set</fail>

This gives you better reporting of whats missing at least - but does require
Ant 1.5 (currently in alpha, available via nightly builds)

    Erik


----- Original Message -----
From: "Vincent Massol" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 31, 2002 5:09 AM
Subject: [idea] Notion of required and optional properties

> I don't know if you already have this in Maven but I would find it very
> useful. It is the notion of required Ant properties. In all my projects,
> I document the required Ant properties (and the optional ones) and I
> check in Ant the all required ones are set and valid (verify the file
> for file properties) before I let the script go on.
>
> Here is what I use (but I need to improve it to display an error message
> per invalid property and not a global one - because it is hard to know
> which property failed).
>
>     <!--
>        =============================================================
>          Display configurable properties values
>        =============================================================
>     -->
>     <target name="display.properties">
>
>         <echo message="--- ${project.name.text} ${project.version}
> ---"/>
>         <echo message=""/>
>         <echo message="java.class.path = ${java.class.path}"/>
>         <echo message=""/>
>         <echo message="java.home = ${java.home}"/>
>         <echo message="user.home = ${user.home}"/>
>         <echo message="ant.home = ${ant.home}"/>
>         <echo message=""/>
>         <echo message="j2ee.jar = ${j2ee.jar}"/>
>         <echo message="log4j.jar = ${log4j.jar}"/>
>         <echo message="commons.httpclient.jar =
> ${commons.httpclient.jar}"/>
>         <echo message="httpunit.jar = ${httpunit.jar}"/>
>         <echo message=""/>
>
>     </target>
>
>     <!--
>        ==============================================================
>          Verify that all mandatory properties have been set
>        ==============================================================
>     -->
>     <target name="check.properties" depends="display.properties">
>
>         <condition property="properties.ok">
>             <and>
>                 <available file="${j2ee.jar}"/>
>                 <available file="${log4j.jar}"/>
>                 <available file="${commons.httpclient.jar}"/>
>                 <available file="${httpunit.jar}"/>
>            </and>
>         </condition>
>
>         <fail message="Missing property or property pointing to an
> invalid file (check your build.properties file)"
>             unless="properties.ok"/>
>
>     </target>
>
>
>     <!--
>        =============================================================
>          Initialize the build. Must be called by all targets
>        =============================================================
>     -->
>     <target name="init"
>         depends="check.properties ">
> [...]
>
>
> Wouldn't' it be possible to define an element in the Maven project
> descriptor for required and optional properties and have a
> maven:check-properties target ?
>
> Note: I have also added this in scarab as an Enhancement (id is MAVE14)
> but I find it very hard to use ... especially when it comes to viewing
> an issue. It all appears in a small box. There must be another way but
> it is not intuitive at all !.
>
> Thanks
> -Vincent

-------------------------------------------------------

-- 
Cheers,

Pete

"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to