Detect Package (detectPackage)

<detectPackage> Element

The detectPackage rule is used to detect Java packages.

Table 1. <detectPackage> Element Attributes
Attribute Name Type Required Description
names String Yes

The fully qualified package names. If providing multiple, use a comma separated list. Add .* to the package to match all sub-packages. Add just * to the package name to match that package as well as all sub-packages.

useAppProvidedLibraries Boolean No

Indicates whether or not to check for the application providing the package itself. If it is provided, then the rule will not flag. Defaults to false.

skipScanForUsage Boolean No

Indicates whether or not to check for usage of the package. If true, will only flag class definitions in the specified package, not usages of those classes in other packages. Use this when you want to check for an implementation provided by the application. Defaults to false.

validateBundleImports Boolean No

Indicates whether or not to validate the bundle imports. Defaults to false.

excludeClassNames String No

The fully qualified package names. If providing multiple use a comma separated list. List of class names to exclude from the results for the packages specified by the names attribute.

excludePackageNames String No

The fully qualified package names. If providing multiple use a comma separated list. List of package names to exclude from the results. Use this to exclude certain sub-packages. Add .* to the package to match all sub-packages. Add just * to the package name to match that package as well as all sub-packages.

excludeReferences Regex No

Exclude references to the package from the specified file in the application. Specify using a regex.

providedPackages String No

The fully qualified package names. List of package names to flag if provided by the application. If specifying multiple, use a comma separated list.

detectProvidedAndUsed Boolean No

Indicates only to flag if both the packages listed in names are used by the application and the package names listed in providedPackages are provided by the application.

flagOnce Boolean No

Indicates whether to flag once per archive. Defaults to false.

flagOncePerFile Boolean No

Indicates whether to flag once per file. Defaults to false.

hideResult Boolean No

Indicates whether results flagged by this rule should be hidden in the report. This attribute only hides results when used with rules under the <and> or <or> tags. Defaults to false.

For example, to detect the java.sql package and all its sub-packages, specify:


<detectPackage names="java.sql*" />