Chapter 10. JSCC - Commandline Version

JStyle Command Line Style Checker (abbreviated as JSCC in this help), a command line utility, provides a convenient way of running JStyle in batch mode. The input for this utility can be a JStyle project file (created using the UI version) or a set of Java files. This utility supports both comment and metrics report generation.

Usage

JSCC [options] <JStyle Project File> <[directories] [files]>

The following table lists the options that can be provided.

Options Description
-cp (or

–classpath)

Uses the specified classpath.

Syntax: -cp <classpath>

Example:

jscc -cp c:\classes myproj.jst

The classpath is a semi-colon separated string. If the classpath has spaces make sure that it is enclosed within quotes in your command line.

Note that the runtime Jar (based on the registry settings) is appended to the classpath you have specified. To override it, specify the rt.jar you want to use as part of the classpath.

If the classpath is not specified (using this option), the environment variable CLASSPATH is used for a project that is newly created. Already existing projects use the classpath set in the project file if it is not specified (using this option). For existing projects to use the CLASSPATH environment variable, the classpath can be set as follows:

jscc -cp %CLASSPATH% myproj.jst

-r Include all java files in the directories following this option recursively.

Syntax: -r <dir name>

Example:

jscc –r c:\jdk1.3.1\src\java\lang

will include all the Java files in the ..src\java\lang directory and all its subdirectories.

-nr Include all java files in the directories following this option (but not in sub folders).

Syntax: -nr <dir name>

Example:

jscc –nr c:\jdk1.3.1\src\java\lang

will include all the Java files in the ..src\java\lang directory but not in the subdirectories ..src\java\lang\reflect and ..src\java\lang\ref.

-x Exclude Java files in the directories (also sub folders) and files that follow the option. This option is a convenient way of excluding some of the subdirectories under a previously included directory.

Syntax: -x <[dir name][file name]>

Example:

jscc –r c:\jdk1.3.1\src\java\lang –x c:\jdk1.3.1\src\java\lang\reflect

will include all the Java files in the ..src\java\lang directory and its subdirectories but not in the directory ..src\java\lang\reflect. That is all files that are directly under lang directory are included along with files under lang\ref but not under lang\reflect .

-nx Exclude Java files in the directories, but not in its sub directories.

This option is a convenient way of excluding files only under specific subdirectory (of previously included directory) while still retaining files under deeper folders.

Syntax: -nx <[dir name][file name]>

Example:

jscc -r c:\jdk1.3.1\src\lang -nx c:\jdk1.3.1\src\lang

will include all the Java files in the ..src\java\lang\ref and ..src\java\lang\reflect directories but not those in ..src\java\lang directory.

-o Specify the output directory for the output report files. If this option is not specified, the current directory is used as the output directory (if required).

Syntax: -o <outputdir>

Example:

jscc –r .\src\java\lang –o c:\temp

generates all the reports under c:\temp directory.

-m Generates metric reports in html format. The files will be generated in the output directory if specified or else the current directory.
-t Generate metric reports in text format in the file specified. Note that this option does not use the output directory.

Syntax: -t <filename>

-nc Do not generate comment reports. By default comment reports in HTML format are generated.
-p Generates the report specified in the specified format.

Syntax : -p[:printer|pdf|html|rtf] reportname

The output format can be one of :

printer - Generates the report and sends it to the default printer (register in the machine). This is the default option. If the format is not specified the report is sent to the printer. If you are running in JStyle in batch mode without user intervention, make sure that you have a default printer registered in your machine before using this option.

pdf - Generates the report in PDF format. The output file name is ReportName.pdf.

html - Generates the report in HTML format. The output file name is ReportName.html.

rtf - Generates the report in RTF format. The output file name is ReportName.rtf.

The report is generated in the output directory specified using –o option, except in case of printer format where it is not applicable.

Note: JStyle ships with predefined set of reports. You can also extend it by writing your own reports. The report name you specify with this option is the name of the report specified using the JStyle user interface.

Example:

jscc –r .\src\java\lang –p:pdf "All Comments"

This command generates the report with name All Comments in pdf format in the output directory. The output file name would be All Comments.pdf.

If the report name has spaces in between, make sure that you enclose it within quotes.

-e Executes the specified script file.

Syntax : -e scriptFilename

Example:

jscc –r .\src\java –e myscript.jms

This command is useful for executing standalone script files. What happens when the script is executed depends on what the script contains. The script may choose to produce some output say, in a file or may write output to the console.

The order of execution:

Parsing and comment generation

Execute script files (-e option)

Execute reports (-p option)

Note that the scripts are executed ahead of the reports irrespective of the order in which they are specified in the command line.

-s Save the command line options as JStyle project file.

Syntax: -s <filepath>

This option has been deprecated. If a JStyle project file is specified then it is updated by default. If you do not want your project file to be updated use the –d option.

<JStyle Project File> A JStyle Project file (should exist) to be used. All the settings (files, classpath) are used from the project file. If you also specify directories and files in the command line (for instance using –r or –nr option) only those files specified in the command line are used (project files are ignored). But all the settings from the project file are used.

Specifying both the project file and Java files to be used in the command line is useful in cases where you have an existing project and you want to update the files in the project while retaining all its settings.

Note that the JStyle project file may be updated based on your command line. For instance, if you had specified project files or classpath in the command line along with an existing project as shown below, your project will be updated.

jscc -cp c:\classes myproj.jst

If you do not want your project file to be updated use the –d option.

-d Do not modify the specified project file. This option applies if you have specified a project file that already exists.

Example

jscc -r d:\java\com\mmsindia myproj.jst

jscc -o .\html -m -nr "c:\My Documents\com\mmsindia\agents" agents.jst

jscc myproj.jst

jscc -r c:\java\demo

jscc –p:pdf JStyleComments myproj.jst

Contents     Top    Previous    Next


Copyright © Man Machine Systems 1997-2003.
All Rights Reserved.
We acknowledge all trademarks.