CodeNarc can be run from the command-line as a Java application. The org.codenarc.CodeNarc class provides the application entry-point.
Usage: java org.codenarc.CodeNarc [OPTIONS] where OPTIONS are zero or more command-line parameters of the form "-NAME[=VALUE]"
All command-line parameters are optional. If no parameters are supplied, CodeNarc runs from the current directory with reasonable defaults, as described below.
|-basedir=DIR||The base (root) directory for the source code to be analyzed.
Defaults to the current directory (".").
|-includes=PATTERNS||The comma-separated list of Ant-style file patterns specifying
files that must be included. Defaults to "**/*.groovy".
|-excludes=PATTERNS||The comma-separated list of Ant-style file patterns specifying
files that must be excluded. No files are excluded when omitted.
|-rulesetfiles=FILENAMES||The path to the Groovy or XML RuleSet definition files, relative
to the classpath. This can be a single file path, or multiple paths
separated by commas. Defaults to "rulesets/basic.xml".
|-report=REPORT-TYPE[:FILENAME]||The definition of the report to produce. The option value is of
the form TYPE[:FILENAME], where TYPE is one of the
predefined type names: "html", "xml", "text", "console" or else the fully-qualified
class name of a class (accessible on the classpath) that implements
the org.codenarc.report.ReportWriter interface. And
FILENAME is the filename (with optional path) of the output
report filename. If the report filename is omitted, the default
filename for the report type is used ("CodeNarcReport.html" for
"html" and "CodeNarcXmlReport.xml" for "xml"). If no report
option is specified, default to a single "html" report with the
|-title=REPORT TITLE||The title description for this analysis; used in the output
report(s), if provided.
|-help||Display the command-line help. If present, this must be the
only command-line parameter.
Make sure that the following are included your CLASSPATH:
Here is an example BAT file for running CodeNarc on Windows.
@set GROOVY_JAR="%GROOVY_HOME%/embeddable/groovy-all-1.5.6.jar" @java -classpath %GROOVY_JAR%;lib/CodeNarc-0.5.jar;lib/log4j-1.2.14.jar;lib org.codenarc.CodeNarc %*