Class CheckSignatureMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.animal_sniffer.maven.CheckSignatureMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="check", defaultPhase=PROCESS_TEST_CLASSES, requiresDependencyResolution=TEST, threadSafe=true) public class CheckSignatureMojo extends org.apache.maven.plugin.AbstractMojo
Checks the classes compiled by this module.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]
annotations
Annotation names to consider to ignore annotated methods, classes or fields.protected boolean
checkTestClasses
Should test classes be checked.(package private) static java.util.Map<java.io.File,java.util.Map<java.lang.String,Clazz>>
classes
private java.lang.String[]
excludeDependencies
A list of artifact patterns to exclude.protected boolean
failOnError
Should signature check failures throw an error?protected boolean
ignoreDependencies
Should dependencies be ignored.protected java.lang.String[]
ignores
Class names to ignore signatures for (wildcards accepted).private java.lang.String[]
includeDependencies
A list of artifact patterns to include.protected java.io.File
outputDirectory
The directory for compiled classes.protected org.apache.maven.project.MavenProject
project
private org.eclipse.aether.RepositorySystem
repositorySystem
private org.eclipse.aether.RepositorySystemSession
repositorySystemSession
protected Signature
signature
Signature module to use.protected boolean
skip
Should signature checking be skipped?protected java.io.File
testOutputDirectory
The directory for compiled test classes.
-
Constructor Summary
Constructors Constructor Description CheckSignatureMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
apply(ClassFileVisitor v)
private java.util.Set<java.lang.String>
buildPackageList()
List of packages defined in the application.private java.util.List<java.io.File>
buildSourcePathList()
void
execute()
private static org.apache.maven.model.Dependency
findMatchingDependency(Signature signature, java.util.List<org.apache.maven.model.Dependency> dependencies)
private static java.util.Map<java.lang.String,Clazz>
loadClasses(java.io.File f)
private java.io.File
resolveFileForArtifact(org.eclipse.aether.artifact.Artifact artifact)
void
setSignature(java.lang.String signatureId)
-
-
-
Field Detail
-
outputDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true, readonly=true) protected java.io.File outputDirectory
The directory for compiled classes.
-
testOutputDirectory
@Parameter(defaultValue="${project.build.testOutputDirectory}", required=true, readonly=true) protected java.io.File testOutputDirectory
The directory for compiled test classes.- Since:
- 1.19
-
checkTestClasses
@Parameter(property="animal.sniffer.checkTestClasses", defaultValue="false") protected boolean checkTestClasses
Should test classes be checked.- Since:
- 1.19
-
signature
@Parameter(required=true, property="animal.sniffer.signature") protected Signature signature
Signature module to use.
-
ignores
@Parameter protected java.lang.String[] ignores
Class names to ignore signatures for (wildcards accepted).
-
annotations
@Parameter protected java.lang.String[] annotations
Annotation names to consider to ignore annotated methods, classes or fields.By default 'org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement' and 'org.jvnet.animal_sniffer.IgnoreJRERequirement' are used.
-
ignoreDependencies
@Parameter(defaultValue="true") protected boolean ignoreDependencies
Should dependencies be ignored.
-
includeDependencies
@Parameter private java.lang.String[] includeDependencies
A list of artifact patterns to include. Patterns can include*
as a wildcard match for any whole segment, valid patterns are:groupId:artifactId
groupId:artifactId:type
groupId:artifactId:type:version
groupId:artifactId:type:classifier
groupId:artifactId:type:classifier:version
- Since:
- 1.12
-
excludeDependencies
@Parameter private java.lang.String[] excludeDependencies
A list of artifact patterns to exclude. Patterns can include*
as a wildcard match for any whole segment, valid patterns are:groupId:artifactId
groupId:artifactId:type
groupId:artifactId:type:version
groupId:artifactId:type:classifier
groupId:artifactId:type:classifier:version
- Since:
- 1.12
-
skip
@Parameter(defaultValue="false", property="animal.sniffer.skip") protected boolean skip
Should signature checking be skipped?
-
failOnError
@Parameter(defaultValue="true", property="animal.sniffer.failOnError") protected boolean failOnError
Should signature check failures throw an error?
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
-
repositorySystemSession
@Parameter(defaultValue="${repositorySystemSession}", readonly=true) private org.eclipse.aether.RepositorySystemSession repositorySystemSession
-
repositorySystem
@Component private org.eclipse.aether.RepositorySystem repositorySystem
-
classes
static java.util.Map<java.io.File,java.util.Map<java.lang.String,Clazz>> classes
-
-
Method Detail
-
setSignature
public void setSignature(java.lang.String signatureId)
- Parameters:
signatureId
- A fully-qualified path to a signature jar. This allows users to set a signature for command-line invocations, such as:mvn org.codehaus.mojo:animal-sniffer-maven-plugin:1.15:check -Dsignature=org.codehaus.mojo.signature:java17:1.0
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
resolveFileForArtifact
private java.io.File resolveFileForArtifact(org.eclipse.aether.artifact.Artifact artifact) throws org.eclipse.aether.resolution.ArtifactResolutionException, org.apache.maven.plugin.MojoExecutionException
- Throws:
org.eclipse.aether.resolution.ArtifactResolutionException
org.apache.maven.plugin.MojoExecutionException
-
loadClasses
private static java.util.Map<java.lang.String,Clazz> loadClasses(java.io.File f) throws java.io.IOException
- Throws:
java.io.IOException
-
findMatchingDependency
private static org.apache.maven.model.Dependency findMatchingDependency(Signature signature, java.util.List<org.apache.maven.model.Dependency> dependencies)
-
buildPackageList
private java.util.Set<java.lang.String> buildPackageList() throws java.io.IOException
List of packages defined in the application.- Throws:
java.io.IOException
-
apply
private void apply(ClassFileVisitor v) throws java.io.IOException
- Throws:
java.io.IOException
-
buildSourcePathList
private java.util.List<java.io.File> buildSourcePathList()
-
-