ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rinehart, Raleigh" <raleigh.rineh...@ti.com>
Subject RE: Catch compile error with trycatch
Date Wed, 11 Feb 2009 15:31:50 GMT
> 
> 
> Hi
> 
> We are trying to catch our compile errors with Ant Contrim trycatch task
> but
> for some reason we cant it to catch any errors.
> 
> Im grateful for all ideas!!
> 
> this is our testscript:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="Copille-dbDef" default="cmp-def"
> xmlns:ac="antlib:net.sf.antcontrib">
> 
>   <path id="build.class.path">
> 	<fileset dir="${proj.externals.dir}/FND">
> 		<include name="**/*.jar"/>
> 	</fileset>
> 	<pathelement path="${proj.bin.dir}/${be.component}/bindbg"/>
> 	<pathelement path="${base.root}"/>
>   </path>
>   <target name="cmp-def" description="Compilling DB Def">
> 	<pathconvert property="build.classpath.prop"
> refid="build.class.path"
> targetos="windows" />
> 	<echo message="Current classpath: ${build.classpath.prop}"/>
> 
> 	<ac:for param="obj">
> 	     <path>
> 		<fileset dir="${proj.src.dir}/${be.component}/src/mvx/db/def">
> 			<include name="**/*.java"/>
> 		</fileset>
> 	     </path>
> 
> 	     <sequential>
> 		<ac:propertyregex override="yes"
> 		property="obj" input="@{obj}"
> 	             regexp="(.+\\)(.+\.java)"
> 	             replace="\2"
>                           casesensitive="false" />
> 
>              <ac:trycatch property="exception.message"
> reference="exception.ref">
> 		<ac:try>
> 		           <javac taskname="compile.def"
> 			sourcepath=""
> 			srcdir="${proj.src.dir}/${be.component}/src/mvx/db/def"
> 			destdir="${proj.bin.dir}/${be.component}/bindbg"
> 			includes="${obj}"
> 			classpathref="build.class.path"
> 			compiler="org.eclipse.jdt.core.JDTCompilerAdapter"
> 			target="1.6"
> 			source="1.6"
> 			debug="on"
> 			failonerror="false"
> 			fork="no"
> 		           />
> 		</ac:try>
> 		<ac:catch>
> 			<echo message="Compile error on: ${obj}  Error message:
> 
> ${exception.message}${line.separator}"
> 			  file="${ProjBaseDir}\Compille.error"
> 			  append="true" level="warning"
>                                        />
> 		</ac:catch>
> 	</ac:trycatch>
>     </sequential>
>   </ac:for>
> </target>
> </project>
> 

You have failonerror in your javac task set to false, so there is nothing to catch since the
error doesn't get propagated up.  It should work as you expect if you set failonerror=true.

If you don't want to do this then you can use the errorProperty attribute and use antcontrib's
<if> <then> tasks.

-raleigh


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


Mime
View raw message