forbiddenapis:check

Full name:

de.thetaphi:forbiddenapis:1.8:check

Description:

Mojo to check if no project generated class files (compile scope) contain calls to forbidden APIs from the project classpath and a list of API signatures (either inline or as pointer to files or bundled signatures). At least one signature must be given, using any of the corresponding optional parameters.

This Mojo exists since version 1.2, replacing the old forbiddenapis:forbiddenapis goal. In most cases its enough to rename the goal on update, the older v1.0 properties are still available.

Attributes:

Optional Parameters

Name Type Since Description
bundledSignatures String[] 1.0 Specifies built-in signatures files (e.g., deprecated APIs for specific Java versions, unsafe method calls using default locale, default charset,...)
classesDirectory File 1.2 Directory with the class files to check.
Default value is: ${project.build.outputDirectory}.
excludes String[] 1.0 List of patterns matching class files to be excluded from checking.
failOnMissingClasses boolean 1.0 Fail the build, if a class referenced in the scanned code is missing. This requires that you pass the whole classpath including all dependencies to this Mojo (Maven does this by default).
Default value is: true.
failOnUnresolvableSignatures boolean 1.4 Fail the build if a signature is not resolving. If this parameter is set to to false, then such signatures are silently ignored. This is useful in multi-module Maven projects where only some modules have the dependency to which the signature file(s) apply.
Default value is: true.
failOnUnsupportedJava boolean 1.0 Fail the build, if the bundled ASM library cannot read the class file format of the runtime library or the runtime library cannot be discovered.
Default value is: false.
includes String[] 1.0 List of patterns matching all class files to be parsed from the classesDirectory. Can be changed to e.g. exclude several files (using excludes). The default is a single include with pattern '**/*.class'
internalRuntimeForbidden boolean 1.0 Forbids calls to classes from the internal java runtime (like sun.misc.Unsafe)
Default value is: false.
signatures String 1.0 Gives a multiline list of signatures, inline in the pom.xml. Use an XML CDATA section to do that! The signatures are resolved against the compile classpath.
signaturesFiles File[] 1.0 Lists all files, which contain signatures and comments for forbidden API calls. The signatures are resolved against the compile classpath.
skip boolean 1.6 Skip entire check. Most useful on the command line via "-Dforbiddenapis.skip=true".
Default value is: false.
User property is: forbiddenapis.skip.
suppressAnnotations String[] 1.8 List of a custom Java annotations (full class names) that are used in the checked code to suppress errors. Those annotations must have at least RetentionPolicy.CLASS. They can be applied to classes, their methods, or fields. By default, @de.thetaphi.forbiddenapis.SuppressForbidden can always be used, but needs the forbidden-apis.jar file in classpath of compiled project, which may not be wanted. Instead of a full class name, a glob pattern may be used (e.g., **.SuppressForbidden).
targetVersion String 1.0 The default compiler target version used to expand references to bundled JDK signatures. E.g., if you use "jdk-deprecated", it will expand to this version. This setting should be identical to the target version used in the compiler plugin.
Default value is: ${maven.compiler.target}.

Parameter Details

bundledSignatures:

Specifies built-in signatures files (e.g., deprecated APIs for specific Java versions, unsafe method calls using default locale, default charset,...)

classesDirectory:

Directory with the class files to check.

excludes:

List of patterns matching class files to be excluded from checking.

failOnMissingClasses:

Fail the build, if a class referenced in the scanned code is missing. This requires that you pass the whole classpath including all dependencies to this Mojo (Maven does this by default).

failOnUnresolvableSignatures:

Fail the build if a signature is not resolving. If this parameter is set to to false, then such signatures are silently ignored. This is useful in multi-module Maven projects where only some modules have the dependency to which the signature file(s) apply.

failOnUnsupportedJava:

Fail the build, if the bundled ASM library cannot read the class file format of the runtime library or the runtime library cannot be discovered.

includes:

List of patterns matching all class files to be parsed from the classesDirectory. Can be changed to e.g. exclude several files (using excludes). The default is a single include with pattern '**/*.class'

internalRuntimeForbidden:

Forbids calls to classes from the internal java runtime (like sun.misc.Unsafe)

signatures:

Gives a multiline list of signatures, inline in the pom.xml. Use an XML CDATA section to do that! The signatures are resolved against the compile classpath.

signaturesFiles:

Lists all files, which contain signatures and comments for forbidden API calls. The signatures are resolved against the compile classpath.

skip:

Skip entire check. Most useful on the command line via "-Dforbiddenapis.skip=true".

suppressAnnotations:

List of a custom Java annotations (full class names) that are used in the checked code to suppress errors. Those annotations must have at least RetentionPolicy.CLASS. They can be applied to classes, their methods, or fields. By default, @de.thetaphi.forbiddenapis.SuppressForbidden can always be used, but needs the forbidden-apis.jar file in classpath of compiled project, which may not be wanted. Instead of a full class name, a glob pattern may be used (e.g., **.SuppressForbidden).

targetVersion:

The default compiler target version used to expand references to bundled JDK signatures. E.g., if you use "jdk-deprecated", it will expand to this version. This setting should be identical to the target version used in the compiler plugin.