You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ky...@panix.com on 2002/06/27 15:02:15 UTC

Target/flag inconsistency resolution




I want ant to ignore the value of a certain flag whenever a particular
target is being built.  E.g., consider this:

  <target name="baz" depends="dist">
  // yadda-yadda-yadda
  </target>

  <target name="dist" depends="foo">
  // yadda-yadda-yadda
  </target>

  <target name="foo" unless="nofoo">
  // but the value of nofoo should be ignored if we are in the
  // process of building baz!
  // yadda-yadda-yadda
  </target>

When I execute plain old "ant" I get foo first and then dist; and when
I execute "ant -Dnofoo=true", I get just dist.  This is fine.  But if
I execute "ant baz -Dnofoo=1", I want to ignore the -Dnofoo=1 flag and
build foo anyway.  In other words the target baz is inconsistent with
a non-null nofoo, and this inconsistency should be resolved in favor
of unsetting nofoo.  How can I implement this?

Thanks!

kynn

P.S. Please Cc: me in replies.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Target/flag inconsistency resolution

Posted by Geoff Meakin <ge...@isocra.com>.
Here's one way to do it

  <target name="baz" depends="bazselect,dist">
  // yadda-yadda-yadda
  </target>

  <target name="dist" depends="foo">
  // yadda-yadda-yadda
  </target>

  <target name="foo" unless="foohandler" depends="checkfoo">
  // but the value of nofoo should be ignored if we are in the
  // process of building baz!
  // yadda-yadda-yadda
  </target>

  <target name="checkfoo">
    <condition property="foohandler" value="true">
      <and>
        <not><equals arg1="${nofoo}" arg2="$${nofoo}"/></not>
        <equals arg1="${bazselected}" arg2="$${bazselected}"/>
      </and>
    </condition>
  </target>

  <target name="bazselect">
    <property name="bazselected" value="true"/>
  </target>

thus bazselected only gets set to true if baz is called,
and bazselected prevents foohandler from being true, which in turn means foo
is executed.
Note you could swap some of the unless, <not> logic to make it a bit simpler
perhaps

Cheers
-Geoff


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>