You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Hertel, Oliver" <Ol...@Dresdner-Bank.com> on 2002/06/11 09:56:14 UTC

access to task description?

Hello,

is there a way to access the target description, maybe like this?

  <target name="build" description="Compiles main classes"
          depends="prepare">
    <echo message="${description}" />
  ...
  </target>

Thanks in advance.

Oliver Hertel

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


Ant DOM [Was: access to task description?]

Posted by Ernst de Haan <er...@nl.euro.net>.
> is there a way to access the target description, maybe like this?
>
>   <target name="build" description="Compiles main classes"
>           depends="prepare">
>     <echo message="${description}" />

Just thinking, perhaps a Document Object Model would be nice for Ant :-) Then 
you could have properties like:

   ant.project --> The current project
   ant.project.name --> The name of the current project
   ant.project.tasks --> All tasks in the current project
   ant.currenttask --> The current task
   ant.currenttask.name --> The name of the current task
   ant.currenttask.description --> The description of the current task
   :

This would be similar to the approach used in HTML (JavaScript/VBscript)
Some of these properties are currently already available as 'magic 
properties'.


Ernst

-- 
Ernst de Haan
EuroNet Internet B.V.

    "Come to me all who are weary and burdened
        and I will give you rest" -- Jesus Christ

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


Re: access to task description?

Posted by Diane Holt <ho...@yahoo.com>.
--- "Hertel, Oliver" <Ol...@Dresdner-Bank.com> wrote:
> is there a way to access the target description [...]?

You can either add the following to every target you want to have the
description printed out for:
    <script language="javascript"><![CDATA[
      desc = self.getOwningTarget().getDescription();
      if( desc != null ) {
        java.lang.System.out.println(desc);
      }
    ]]></script>

Or compile, jar, and taskdef the following:
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;

  public class PrintDesc extends Task {

      // The method executing the task
      // @param None Executes the task
      public void execute() throws BuildException {
          String desc = getOwningTarget().getDescription();
          if( desc != null ) {
              System.out.println(desc);
          }
      }
  }

and include a <printdesc/> in any target you want the description printed
out for.

(Maybe there's some more clever way, but it's the best I can come up with
while waiting for my coffee to brew :)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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