It's all about the answers!

Ask a question

Static Analysis - ECJ


Nicholas Tones (111) | asked Feb 26 '08, 12:14 p.m.
I am attempting to run ammended versions of the various build.xml files to run static analysis on a simple web app. I am encountering a problem with the ECJ task and it appears to stem from the fact that only the jar files located within the WEB-INF\lib folder of my app are included in the ECJ task classpath. The web app has dependencies on J2EE.jar, etc. As a result I am getting lots of "HttpServletResponse cannot be resolved to a type" errors.
Can anyone tell me how to include external jars in the ECJ task classpath?
The ant xml (ecj.xml) file being used to run the analysis taks is that which is distributed with the static-analysis package includes the lines

<target name="invokeEcj">
<delete file="${resultFile}" />

<echo message="Running static analysis (ECJ) on ${analysis.sources.dirs}" />
<echo message="with ECJ installed at ${ecjJar}" />

<java resultproperty="ecjReturnCode"
fork="true"
classpath="${ecjJar}"
classname="org.eclipse.jdt.internal.compiler.batch.Main">
<jvmarg value="-Xmx256M" />
<arg value="-1.5" />
<arg value="-cp" />
<arg value="${analysis.classpath}" />
<arg value="-d" />
<arg value="none" />
<arg value="-time"/>
<arg value="-proceedOnError"/>
<arg value="-log" />
<arg value="${resultFile}" />
<arg value="-warn:+javadoc,null,unused,uselessTypeCheck,paramAssign,emptyBlock,nls" />
<arg line="${analysis.sources.dirs}" />
</java>

<echo message="ECJ returned code ${ecjReturnCode}" />
<echo message="ECJ result file at: ${resultFile}" />

</target>

Which is called by analysis.xml


target name="analysis" >
<fileset dir="${analysisLibraryRoot}" id="analysis.all.jars" >
<include name="**/*.jar" />
</fileset>
<pathconvert pathsep="${path.separator}" property="analysis.classpath" refid="analysis.all.jars" setonempty="false" />
<!-- set classpath to default value if it was not set just above -->
<property name="analysis.classpath" value="." />

<!-- Invoke all staticAnalysis.xml files in the workspace's projects. -->
<subant failonerror="true" inheritall="true">
<fileset dir="${analysisRoot}"
includes="*/staticAnalysis.xml" />
</subant>
</target>

Thanks in advance,
Nick

Be the first one to answer this question!


Register or to post your answer.