Hi,

This just appeared on the maven list. I though you may be interested Paul ;)

Specifically look down to the check.properties target. That looks to be what 
you want ?

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

Subject: [idea] Notion of required and optional properties
Date: Sun, 31 Mar 2002 11:09:20 +0100
From: "Vincent Massol" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>

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

----------------------------------------
Whatever you do will be insignificant, 
but it is very important that you do it. 
                              --Gandhi
----------------------------------------

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

Reply via email to