You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by tek1 <te...@pobox.com> on 2003/01/10 18:46:15 UTC

displaying project name before target name in output

is there any way to tell ant to display the project name before target name 
in the output?

normally, ant displays as follows (while running):


init:

clean:

build:



but is there a way to make it print <project-name>.<target-name> as follows 
(where <project-name>="myprj")?


myprj.init:

myprj.clean:

myprj.build:



reason being is that i'm calling targets in other build.xml files and when 
the called target executes, there's no way to distinguish which target name 
is associated with which build.xml file.  it is possible to use the echo 
task at the start of each target, but obviously not the optimal way.

thank you.




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


Re: displaying project name before target name in output

Posted by tek1 <te...@pobox.com>.
hi erik.

got it working.  thank you very much again.

have an awesome weekend!  :)



At 14:41 03/01/10 -0500, you wrote:
>On Friday, January 10, 2003, at 02:12  PM, tek1 wrote:
>>when i want to use this new logging class, then am i correct to assume 
>>that upon each ant execution, i need to specify it as follows?
>>
>>         > ant -logger NewLogger <target>
>
>Yes, you need to specify the logger on every ant invocation, but....
>
>>if so, is there a way to specify the logger to be used in something 
>>like an ant.properties file, such that ant can be executed as normal, 
>>without explicity specifying "-logger NewLogger" each time?  if not, no problem.
>
>set the environment variable ANT_ARGS to be "-logger NewLogger"
>
>>out of curiosity, have any other people requested the ability to change 
>>the target name lines (i.e. "init: ")?  if so, then a suggestion for a 
>>future feature is to adopt a junit-style syntax (i.e. "%P.%T" which would 
>>print <projectName>.<targetName>; and other %... options) and specify 
>>these in a ant-log.properties file or something?
>>just an idea.
>
>Thats an interesting idea.  Actually the format you'd want is 
>MessageFormat-style: "{0}.{1}...".  Patches welcome!  :)
>
>>thanks again for the great advice to solving my problem!
>
>My pleasure.  Be sure to bundle your logger in a JAR and put it in 
>ANT_HOME/lib - that will be the best way to ensure its available.
>
>         Erik
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>


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


Re: displaying project name before target name in output

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
On Friday, January 10, 2003, at 02:12  PM, tek1 wrote:
> when i want to use this new logging class, then am i correct to assume 
> that upon each ant execution, i need to specify it as follows?
>
>         > ant -logger NewLogger <target>

Yes, you need to specify the logger on every ant invocation, but....

> if so, is there a way to specify the logger to be used in something 
> like an ant.properties file, such that ant can be executed as normal, 
> without explicity specifying "-logger NewLogger" each time?  if not, 
> no problem.

set the environment variable ANT_ARGS to be "-logger NewLogger"

> out of curiosity, have any other people requested the ability to 
> change the target name lines (i.e. "init: ")?  if so, then a 
> suggestion for a future feature is to adopt a junit-style syntax (i.e. 
> "%P.%T" which would print <projectName>.<targetName>; and other %... 
> options) and specify these in a ant-log.properties file or something?  
> just an idea.

Thats an interesting idea.  Actually the format you'd want is 
MessageFormat-style: "{0}.{1}...".  Patches welcome!  :)

> thanks again for the great advice to solving my problem!

My pleasure.  Be sure to bundle your logger in a JAR and put it in 
ANT_HOME/lib - that will be the best way to ensure its available.

	Erik


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


Re: displaying project name before target name in output

Posted by tek1 <te...@pobox.com>.
thank you for your reply erik.

it looks fairly straight-forward to create a new logger class (i.e. 
"NewLogger") that extends DefaultLogger and overrides the 
targetStarted(BuildEvent event) method as follows:

     public void targetStarted(BuildEvent event) {
         if (Project.MSG_INFO <= msgOutputLevel) {
             String msg = StringUtils.LINE_SEP
                 + event.getProject().getName() + "."
                 + event.getTarget().getName() + ":";
             printMessage(msg, out, event.getPriority());
             log(msg);
         }
     }


when i want to use this new logging class, then am i correct to assume that 
upon each ant execution, i need to specify it as follows?

         > ant -logger NewLogger <target>


if so, is there a way to specify the logger to be used in something like an 
ant.properties file, such that ant can be executed as normal, without 
explicity specifying "-logger NewLogger" each time?  if not, no problem.

out of curiosity, have any other people requested the ability to change the 
target name lines (i.e. "init: ")?  if so, then a suggestion for a future 
feature is to adopt a junit-style syntax (i.e. "%P.%T" which would print 
<projectName>.<targetName>; and other %... options) and specify these in a 
ant-log.properties file or something?  just an idea.

thanks again for the great advice to solving my problem!



At 13:03 03/01/10 -0500, you wrote:
>You could write a custom BuildLogger implementation that would do this, no 
>problem.  Would be fairly easy.  Have a look at the DefaultLogger built 
>into Ant for inspiration.
>
>         Erik


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


Re: displaying project name before target name in output

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
You could write a custom BuildLogger implementation that would do this, 
no problem.  Would be fairly easy.  Have a look at the DefaultLogger 
built into Ant for inspiration.

	Erik


On Friday, January 10, 2003, at 12:46  PM, tek1 wrote:
> is there any way to tell ant to display the project name before target 
> name in the output?
>
> normally, ant displays as follows (while running):
>
>
> init:
>
> clean:
>
> build:
>
>
>
> but is there a way to make it print <project-name>.<target-name> as 
> follows (where <project-name>="myprj")?
>
>
> myprj.init:
>
> myprj.clean:
>
> myprj.build:
>
>
>
> reason being is that i'm calling targets in other build.xml files and 
> when the called target executes, there's no way to distinguish which 
> target name is associated with which build.xml file.  it is possible 
> to use the echo task at the start of each target, but obviously not 
> the optimal way.
>
> thank you.
>
>
>
>
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>


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