struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mart...@apache.org>
Subject New PMD and Checkstyle tasks
Date Sun, 05 Jan 2003 07:20:07 GMT
I've added two new tasks to the main build.xml file to allow us to easily
run PMD and Checkstyle on the entire src/share source tree. Even if you
don't know what these tools are, read on.

PMD
---

PMD is a Java source code analyzer which can detect many, many different
kinds of problems, including unused imports, unused variables, etc., and
report them in different ways.

To run the PMD task, you need to first download PMD from here:

http://sourceforge.net/projects/pmd/

and set the pmd.jar property in your build.properties file with something
like this:

pmd.jar = /Java/pmd/lib/pmd-1.01.jar

Then you can invoke the task like this:

ant pmd

This will create an HTML output file named pmdreport.html in the Struts
root directory. The task is configured to report only unused imports,
duplicate imports, and unused variables and methods, but we can expand the
set of checks and/or use multiple targets for different sets of checks as
we gain more experience with it.

Checkstyle
----------

Checkstyle is a tool that checks source code against a defined set of
coding conventions. The default is to check against the Sun coding
conventions, and I've left the settings at the default for now.

To run the Checkstyle task, you need to first download Checkstyle from
here:

http://sourceforge.net/projects/checkstyle/

and set the checkstyle.jar property in your build.properties file with
something like this:

checkstyle.jar = /Java/checkstyle-2.4/checkstyle-all-2.4.jar

Then you can invoke the task like this:

ant -logfile checkstyle.log checkstyle

Right now, you *will* need to specify a log file, because Checkstyle is
reporting 9,884 errors! Note that I am *not* advocating that we start a
crusade to fix these before Struts 1.1 Final. In fact, I think that would
be counterproductive at this point.


Each of the tasks described above is conditional on the corresponding
property being set in your build.properties file. If the property is not
set, invoking the task simply does nothing.

At some point, it might be nice to have these tasks generate XML and run
the output through XSLT to generate customised HTML. However, if we move
to Maven (which I'd really like to do as soon as both 1.1 Final and Maven
are released), we may not need to worry about this.

--
Martin Cooper



--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message