see Running Static Analysis 1 for information on pointing to the data location). You can use multiple -resource switches to specify multiple resources. Code Block |
---|
-resource [pattern] |
Configure the jtest.resource property in the .properties file. Separate multiple resources with a comma: Code Block |
---|
jtest.resource=pattern1,pattern2 |
Ant and Maven PatternIf you use Ant or Maven, you can use the following pattern: Code Block |
---|
<resource>pattern</resource> |
You can use the <resources> element to define multiple resources Code Block |
---|
<resources>
<resource>pattern1</resource>
<resource>pattern2</resource>
</resources> |
Resource Pattern SyntaxResource patterns are matched to generated paths according to the following convention: Code Block |
---|
ProjectName/resource/inside/of/project/directory.extension
ProjectName/EXT/resource/inside/of/external/source/directories.extension |
The ProjectName value is generated according to following rules: - The Ant project name is taken from name property of project tag
- The Maven project name takes formofgroupId:artifactId
- The Gradle project name is takenfromgradle.settings file
- Project names configured in IDEs are fully maintained
You can customize the Maven and Gradle project names with theprojectNameTemplateparameter. For details, see the build system plug-in manuals: [INSTALL]/manuals/ plugins-manual.html. Generated paths include the EXT string if the specified scope includes external resources. For example, an analyzed project may include sourcefilesformanotherlocationthatarelinkedto the project. In the following example the Simple.java file is located within the Demo project, whereas the Money.java file has been added by linking and itslocationsisoutsideof the project: Code Block |
---|
Demo/src/main/java/examples/eval/Simple.java
Demo/EXT/examples/bank/Money.java |
You can use Ant-style wildcards and other parameters to refine patterns. The following table describes supported usage: Parameter | Description |
---|
? | Wildcard that matches one character (any character except path separators) | * | Wildcard that matches zero or more characters (not including path separators) | ** | Wildcard that matches zero or more path segments. | / | Separator for all operating systems | "[non-alphanumeric characters]" | Use quotation marks when resource paths contain spaces or other non-alphanumeric characters. |
If the -resource argument only contains one value, the value is matched against the project name and a wildcard (*) will be used. The following table shows examples of -resource switch usage. Expression | Result |
---|
-resource ProjectName/src | Analyzes every file in the selected directory and subdirectories (withoutwildcards, the complete name of the folder has to be specified). | -resource ProjectName/**/*.java | Analyzes every Java filefromselectedproject. | -resource **/src/main/java/my/company/*.java | Analyzes every Java file from the specific subdirectory of every projectincurrentbuild. | -resource ProjectName/src/main/java/my/company/File.java | Analyzes the single specified resource. | -resource c:/resource.lst | Analyzes the projects listed in the resource.lst file. Specify one project name per line:
ProjectName1
ProjectName2 Provide the path to the file as a value to the -resource argument. |
Fine-tuning the ScopeUse the -include and -exclude switches to apply additional filters to the scope. -include instructs Static Analysis Engine to test only the files that match the file system path; all other files are skipped.-exclude instructs Static Analysis Engine to test all files except for those that match the file system path.
If both switches are specified, then all files that match -include , but not those that match -exclude patterns are tested. Code Block |
---|
-include pattern
-exclude pattern |
Alternatively, you can specify the pattern in the .properties file with the following options: Code Block |
---|
jtest.include=pattern
jtest.exclude=pattern |
Ant and Maven PatternIf you use Ant or Maven, you can use the following pattern: Code Block |
---|
<include>pattern</include>
<exclude>pattern</exclude> |
Use Ant-style wildcards and other parameters to with the -include and -exclude filters. The following table describes their usage: Parameter | Description |
---|
? | Wildcard that matches one character (any character except path separators) | * | Wildcard that matches zero or more characters (not including path separators) | ** | Wildcard that matches zero or more path segments. | / | Separator | path: | Prefix for matching absolute disk path |
You can specify a file system path to a list file (*.lst) to include or exclude files in bulk. Each item in the *.lst file is treated as a separate entry. ExamplesUsage | Description |
---|
-include com/** | Tests everything in packages that begin with "com". | -include path:**/Bank.java | Tests only Bank.java files | -include path:C:/Project/src/** | Tests all subfiles and subdirectories of C:/Project/src | -include path:C:/Project/src/* | Tests all files in C:/Project/src, but not subdirectories | -include c:/include.lst | Tests all files listed in include.lst . Each line is treated as a single pattern. Example: If include.lst contains the following lines:
**/*Account
path:**/Bank.java It has the same effect as the following command:
-include **/*Account
-include path: **/Bank.java | -exclude **/internal/** | Tests everything except classes that have "internal" as part of the package name. |
Creating |