ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: refid still not behaving as expected in 1.7.0
Date Thu, 30 Aug 2007 10:43:23 GMT
You can write your own isreference implementation -
    <script language="beanshell">
      import org.apache.tools.ant.*;
      import org.apache.tools.ant.taskdefs.condition.Condition;
      public class IsItAReference extends ProjectComponent implements
Condition {
          private String r;
          public void setRefId(String r) {
             this.r = r;
          }
          public boolean eval() {
             if (r == null) {
              return false;
             }
             return getProject().getReferences().get(r) != null;
          }
      }
      project.addDataTypeDefinition("isitareference", IsItAReference.class);
    </script>

<project name="x" default="x">
  <import file="define-my-types.xml"/>
  <target name="y">
    <path id="ref.not-here" path="."/>
  </target>

  <target name="x">

    <path id="ref.here" path="."/>
    <condition property="here">
      <isitareference refid="ref.here"/>
    </condition>
    <echo>${here}</echo>

    <condition property="not-here">
      <isitareference refid="ref.not-here"/>
    </condition>
    <echo>${not-here}</echo>
  </target>

</project>

Peter

On 8/30/07, George Czernuszka <george.czernuszka@nscgroup.co.uk> wrote:
>
> Thanks, Peter.
>
> It's a shame 1.7.0 doesn't do what it is described as doing, as that sounds
> just what I need.
>
> Is there any way to do what I DO want to do, which is to check whether an id
> has been set?
>
> George
>
> > -----Original Message-----
> > From: Peter Reilly [mailto:peter.kitt.reilly@gmail.com]
> > Sent: 30 August 2007 10:35
> > To: Ant Users List
> > Subject: Re: refid still not behaving as expected in 1.7.0
> >
> > The behavior as described in the WHATSNEW is what was
> > initially was done. However this broke too many builds - with
> > references to out-of-band ids. So the code was modified to
> > store all the out-of-band ids and if the reference could not
> > be found, to look up that and if found to use that reference
> > and to output a long message.
> >
> > In ant 1.8.0, this out-of-band resolution will probably be
> > removed. One could change the <isreference> implementation to
> > report false for out-of-band references, but I do not think
> > that is a good idea.
> >
> > Peter
> >
> > On 8/30/07, Kevin Jackson <foamdino@gmail.com> wrote:
> > > Hi
> > >
> > > > One of the significant changes in 1.7.0 was, apparently:
> > > >
> > > > " * Defer reference process. Bugzilla 36955, 34458, 37688.
> > > > However, my version of ANT 1.7.0 (binary download) seems
> > to behave in the 'old' way. I have looked in WHATSNEW under
> > SVN, and can see no suggestion that there was a problem. So,
> > my question, how can I get 'isreference' to "properly"
> > identify whether a path, for example, has been set at the
> > point where the condition is tested.
> > > >
> > > > See build file and test results. I was expecting the output to be:
> > > >      [echo] test.path setting = false
> > >
> > > I've just tested this with svn trunk compiled today
> > (1.7.1alpha) and I
> > > get the same behaviour - an 'unexecuted' target containing
> > the ref and
> > > an executed target using the ref and the ref set:
> > >
> > > kev@ubuntu-dev:~/workspace/ant-core-trunk$ ant -f test-id.xml
> > > Buildfile: test-id.xml
> > >      [echo] Apache Ant version 1.7.1alpha compiled on August 30 2007
> > >
> > > test:
> > > Warning: Reference test.path has not been set at runtime, but was
> > > found during build file parsing, attempting to resolve. Future
> > > versions of Ant may support  referencing ids defined in
> > non-executed targets.
> > >      [echo] test.path setting = true
> > >
> > > BUILD SUCCESSFUL
> > > Total time: 0 seconds
> > > kev@ubuntu-dev:~/workspace/ant-core-trunk$
> > >
> > > Kev
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For
> > additional
> > > commands, e-mail: user-help@ant.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For
> > additional commands, e-mail: user-help@ant.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message