ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay Glanville" <dic...@nortelnetworks.com>
Subject RE: How do I get the log file name?
Date Thu, 07 Jun 2001 18:04:39 GMT
You might have a problem with this, but I'm not 100% sure.  You should
probably do some tests to prove me wrong.  The thing that might cause a
problem is that if the mailing task is in this build file, then the logging
task will still be writing to the log file (and thus, keep the logfile open)
at the same time that the mailer is trying to mail the log file off.

One way to get around this is to actually have two build files:
- one for the actual building
- one to wrap the first in, capture the logging, and perform the mailing.

For example, move all tasks out of build.xml (except the mailing task) into
file main.xml.  Put the following into build.xml:

<project name="MyProject" default="main" basedir=".">

	<property name="logfile" value="log" />

	<target name="main" depends="compile,mail">
	</target>

	<target name="compile">
		<ant antfile="main.xml"
			dir="."
			target="main"
			output="${logfile}"
		/>
	</target>

	<target name="mail">
		<!-- perform your mailing here! -->
	</target>
</project>

What will this do for you?  Basically, it separates the administration of
your build (logging and mailing) out of the actual building of your project.
Basically, main.xml focuses on building your project, while build.xml simply
observes, and notifies with the results.

Just another suggestion.

JDG



> -----Original Message-----
> From: Erik Hatcher [mailto:erikhatcher@earthlink.net]
> Sent: Thursday, June 07, 2001 1:10 PM
> To: ant-user
> Subject: Re: How do I get the log file name?
> 
> 
> You could always do this when you run Ant:
> 
>     ant -Dbuild.log=logfile -logfile logfile
> 
> and use the ${build.log} property to get the filename.  Just 
> make sure that
> the two "logfile" strings are always the same.   I took a 
> quick glance at
> Ant's source code and did not see anywhere where the log file 
> name is made
> available as a property (although I suppose it could be 
> hidnig somewhere I
> didn't look).
> 
>     Erik
> 
> ----- Original Message -----
> From: "O'Hara, Patrick" <patrick.ohara@workscape.com>
> To: <ant-user@jakarta.apache.org>
> Sent: Thursday, June 07, 2001 9:07 AM
> Subject: RE: How do I get the log file name?
> 
> 
> > I was hoping to use the mail task in Ant.  In Ant I know 
> that the build
> was
> > successful, and I must know what the log file name is 
> somewhere.  Is it in
> a
> > property?  What is the name?  I have everything else to use 
> the mail task
> > except the log file name.
> >
> > Patrick O'Hara
> > 262-408-3849
> > patrick.ohara@workscape.com
> >
> >
> >
> >
> > -----Original Message-----
> > From: Steve Donie [mailto:sdonie@zycor.lgc.com]
> > Sent: Thursday, June 07, 2001 10:02 AM
> > To: 'ant-user@jakarta.apache.org'
> > Subject: RE: How do I get the log file name?
> >
> >
> > You can also do this, which doesn't require a logger. I 
> have a build.bat
> > (Win2K) that calls Ant:
> >
> > .
> > .
> > .
> > call ant.bat -emacs -buildfile %DS_HOME%\tools\build.xml %DO_DS_LOG%
> > %*||goto FAILED
> >
> > :SUCCEEDED
> > echo Build.bat success
> > if not defined DO_DS_LOG goto BUILD_DONE
> > echo Build.bat sending mail
> > call ant.bat -emacs -DBuildResult=Success -buildfile
> > %DS_HOME%\tools\build.xml SendMail&goto BUILD_DONE
> >
> > :FAILED
> > echo Build.bat fail
> > if not defined DO_DS_LOG goto BUILD_DONE
> > echo Build.bat sending mail
> > call ant.bat -emacs -DBuildResult=Failed -buildfile
> > %DS_HOME%\tools\build.xml SendMail&goto BUILD_DONE
> >
> > :BUILD_DONE
> > .
> > .
> > .
> >
> >
> > DO_DS_LOG is set to -logfile=build.log for the nightly 
> build machine, and
> > not set on developers machines. The ||goto FAILED at the 
> end of the call
> to
> > ant.bat will go to the FAILED label if the build fails, or 
> fall through to
> > SUCCEEDED. In my build.xml, I have a target SendMail that 
> looks vaguely
> like
> > this. I actually create a smaller summary of the build called
> BuildMail.log
> > using the echo task, but you could also just mail out build.log.
> >
> >   <!--
> >        
> ===================================================================
> >                               Send mail out with results
> >        
> ===================================================================
> >        note that ${BuildResult} and the do-mail property 
> must have been
> set!
> >   -->
> >   <target name="SendMail" if="do-mail" description="Sends 
> mail with build
> > results if do-mail proerty is set. Used by automatic build.">
> > <mail from="TahoeBuild@lgc.com"
> >           tolist="${MailtoList}"
> >           subject="Results of Tahoe nightly build ${label}
> (${BuildResult})"
> >           files="BuildMail.log"
> >           mailhost="mailhost" />
> >   </target>
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: Erik Hatcher [mailto:erikhatcher@earthlink.net]
> > Sent: Thursday, June 07, 2001 9:00 AM
> > To: ant-user@jakarta.apache.org
> > Subject: Re: How do I get the log file name?
> >
> >
> > http://jakarta.apache.org/ant/faq.html#mail-logger
> >
> >
> > ----- Original Message -----
> > From: "O'Hara, Patrick" <patrick.ohara@workscape.com>
> > To: "Ant User Mailing List (E-mail)" <ant-user@jakarta.apache.org>
> > Sent: Thursday, June 07, 2001 6:48 AM
> > Subject: How do I get the log file name?
> >
> >
> > > I want my build to mail the log file to a list of people. 
>  I have looked
> > at
> > > the mail command and I am wondering how I get the file 
> name of the log
> > file?
> > >
> > > Patrick O'Hara
> > > Workscape, Inc
> > > N17 W24222 Riverwood Pl
> > > Waukesha, WI 53188-1162
> > > 262-408-3849
> > > 262-408-3840 Fax
> > > patrick.ohara@workscape.com
> > >  <<O'Hara, Patrick.vcf>>
> > >
> >
> 
> 

Mime
View raw message