Class BuildSignaturesMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="build", configurator="override", requiresDependencyResolution=COMPILE, threadSafe=true) public class BuildSignaturesMojo extends org.apache.maven.plugin.AbstractMojo
Generates an API Signature from at least one of: the java runtime, the module dependencies and the module classes.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
classesDirectory
Where to find this modules classes.private java.lang.String
classifier
The classifier to add to the generated signatures.private java.lang.String[]
excludeClasses
Classes to exclude from generating signatures of.private java.lang.String[]
excludeDependencies
A list of artifact patterns to exclude.private java.lang.String[]
includeClasses
Classes to generate signatures of.private java.lang.String[]
includeDependencies
A list of artifact patterns to include.private boolean
includeJavaHome
Should the signatures from java home be included.private boolean
includeModuleClasses
Should the signatures from this module's classes be included..private java.lang.String
javaHome
The java home to generate the signatures of, if not specified only the signatures of dependencies will be included.private java.io.File[]
javaHomeClassPath
private java.lang.String
jbcpdArtifactId
The artifactId of the Java Boot Classpath Detector to use.private java.lang.String
jbcpdGroupId
The groupId of the Java Boot Classpath Detector to use.private JdkToolchain
jdk
The JDK Toolchain to use.private java.io.File
outputDirectory
Where to put the generated signatures.private java.util.List<org.apache.maven.artifact.Artifact>
pluginArtifacts
private org.apache.maven.project.MavenProject
project
The maven project.private org.apache.maven.project.MavenProjectHelper
projectHelper
private org.apache.maven.execution.MavenSession
session
The current build session instance.private java.lang.String
signaturesName
The name of the generated signatures.private boolean
skipIfNoJavaHome
Should no signatures be generated if no java home is available.private org.apache.maven.toolchain.ToolchainManager
toolchainManager
private org.apache.maven.toolchain.ToolchainManagerPrivate
toolchainManagerPrivate
-
Constructor Summary
Constructors Constructor Description BuildSignaturesMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
artifactId(org.apache.maven.artifact.Artifact artifact)
private boolean
detectJavaBootClasspath(java.lang.String javaExecutable)
private boolean
detectJavaClasspath(org.apache.maven.artifact.Artifact javaBootClasspathDetector, java.lang.String javaExecutable)
private void
displayJavaBootClasspath()
void
execute()
private java.io.InputStream[]
getBaseSignatures()
private org.apache.maven.toolchain.Toolchain
getJdkToolchain()
Gets thejdk
toolchain to use.private org.apache.maven.toolchain.Toolchain
getJdkToolchainFromConfiguration()
Gets thejdk
toolchain from this plugin's configuration.private org.apache.maven.toolchain.Toolchain
getJdkToolchainFromContext()
Gets the toolchain specified for the current context, e.g.private static java.io.File
getTargetFile(java.io.File basedir, java.lang.String finalName, java.lang.String classifier, java.lang.String type)
private org.apache.maven.toolchain.ToolchainPrivate[]
getToolchains(java.lang.String type)
private void
processJavaBootClasspath(SignatureBuilder builder)
private void
processModuleClasses(SignatureBuilder builder)
private void
processModuleDependencies(SignatureBuilder builder)
-
-
-
Field Detail
-
includeJavaHome
@Parameter(property="includeJavaHome", defaultValue="true") private boolean includeJavaHome
Should the signatures from java home be included.- Since:
- 1.3
-
skipIfNoJavaHome
@Parameter(property="skipIfNoJavaHome", defaultValue="false") private boolean skipIfNoJavaHome
Should no signatures be generated if no java home is available.- Since:
- 1.3
-
includeModuleClasses
@Parameter(property="includeJavaHome", defaultValue="true") private boolean includeModuleClasses
Should the signatures from this module's classes be included..- Since:
- 1.3
-
includeClasses
@Parameter private java.lang.String[] includeClasses
Classes to generate signatures of.- Since:
- 1.3
-
excludeClasses
@Parameter private java.lang.String[] excludeClasses
Classes to exclude from generating signatures of.- Since:
- 1.3
-
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.3
-
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.3
-
javaHome
@Parameter(property="javaHome") private java.lang.String javaHome
The java home to generate the signatures of, if not specified only the signatures of dependencies will be included. This parameter is overridden byjavaHomeClassPath
. This parameter overridesjdk
and any java home specified by maven-toolchains-plugin.- Since:
- 1.3
-
javaHomeClassPath
@Parameter private java.io.File[] javaHomeClassPath
Use this configuration option only if the automatic boot classpath detection does not work for the specificjavaHome
orjdk
. For example, the automatic boot classpath detection does not work with Sun Java 1.1. This parameter overridesjavaHome
,jdk
and the maven-toolchains-plugin.- Since:
- 1.3
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}", required=true) private java.io.File outputDirectory
Where to put the generated signatures.- Since:
- 1.3
-
classesDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true) private java.io.File classesDirectory
Where to find this modules classes.- Since:
- 1.3
-
signaturesName
@Parameter(defaultValue="${project.build.finalName}", required=true) private java.lang.String signaturesName
The name of the generated signatures.- Since:
- 1.3
-
classifier
@Parameter private java.lang.String classifier
The classifier to add to the generated signatures.- Since:
- 1.3
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
-
project
@Parameter(defaultValue="${project}", required=true, readonly=true) private org.apache.maven.project.MavenProject project
The maven project.
-
toolchainManager
@Component private org.apache.maven.toolchain.ToolchainManager toolchainManager
-
toolchainManagerPrivate
@Component private org.apache.maven.toolchain.ToolchainManagerPrivate toolchainManagerPrivate
-
session
@Parameter(defaultValue="${session}", required=true, readonly=true) private org.apache.maven.execution.MavenSession session
The current build session instance. This is used for toolchain manager API calls.
-
jdk
@Parameter private JdkToolchain jdk
The JDK Toolchain to use. This parameter can be overridden byjavaHome
orjavaHomeClassPath
. This parameter overrides any toolchain specified with maven-toolchains-plugin.- Since:
- 1.3
-
pluginArtifacts
@Parameter(defaultValue="${plugin.artifacts}", required=true, readonly=true) private java.util.List<org.apache.maven.artifact.Artifact> pluginArtifacts
-
jbcpdGroupId
@Parameter(defaultValue="${plugin.groupId}") private java.lang.String jbcpdGroupId
The groupId of the Java Boot Classpath Detector to use. The plugin's dependencies will be searched for a dependency of typejar
with this groupId and the artifactId specified injbcpdArtifactId
. The dependency should be a standalone executable jar file which outputs the java boot classpath as a single line separated usingFile.pathSeparatorChar
or else exits with a non-zero return code if it cannot determine the java boot classpath.- Since:
- 1.3
-
jbcpdArtifactId
@Parameter(defaultValue="java-boot-classpath-detector") private java.lang.String jbcpdArtifactId
The artifactId of the Java Boot Classpath Detector to use. The plugin's dependencies will be searched for a dependency of typejar
with this artifactId and the groupId specified injbcpdGroupId
. The dependency should be a standalone executable jar file which outputs the java boot classpath as a single line separated usingFile.pathSeparatorChar
or else exits with a non-zero return code if it cannot determine the java boot classpath.- Since:
- 1.3
-
-
Method Detail
-
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
-
detectJavaBootClasspath
private boolean detectJavaBootClasspath(java.lang.String javaExecutable) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
-
detectJavaClasspath
private boolean detectJavaClasspath(org.apache.maven.artifact.Artifact javaBootClasspathDetector, java.lang.String javaExecutable) throws org.codehaus.plexus.util.cli.CommandLineException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.codehaus.plexus.util.cli.CommandLineException
org.apache.maven.plugin.MojoFailureException
-
displayJavaBootClasspath
private void displayJavaBootClasspath()
-
processModuleDependencies
private void processModuleDependencies(SignatureBuilder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleClasses
private void processModuleClasses(SignatureBuilder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
processJavaBootClasspath
private void processJavaBootClasspath(SignatureBuilder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
getBaseSignatures
private java.io.InputStream[] getBaseSignatures() throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
-
getJdkToolchain
private org.apache.maven.toolchain.Toolchain getJdkToolchain() throws org.apache.maven.plugin.MojoExecutionException
Gets thejdk
toolchain to use.- Returns:
- the
jdk
toolchain to use ornull
if no toolchain is configured or if no toolchain can be found. - Throws:
org.apache.maven.plugin.MojoExecutionException
- if toolchains are misconfigured.
-
getJdkToolchainFromContext
private org.apache.maven.toolchain.Toolchain getJdkToolchainFromContext()
Gets the toolchain specified for the current context, e.g. specified via the maven-toolchain-plugin- Returns:
- the toolchain from the context or
null
if there is no such toolchain.
-
getJdkToolchainFromConfiguration
private org.apache.maven.toolchain.Toolchain getJdkToolchainFromConfiguration() throws org.apache.maven.plugin.MojoExecutionException
Gets thejdk
toolchain from this plugin's configuration.- Returns:
- the toolchain from this plugin's configuration, or
null
if no matching toolchain can be found. - Throws:
org.apache.maven.plugin.MojoExecutionException
- if the toolchains are configured incorrectly.
-
artifactId
static java.lang.String artifactId(org.apache.maven.artifact.Artifact artifact)
-
getToolchains
private org.apache.maven.toolchain.ToolchainPrivate[] getToolchains(java.lang.String type) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.toolchain.MisconfiguredToolchainException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.toolchain.MisconfiguredToolchainException
-
getTargetFile
private static java.io.File getTargetFile(java.io.File basedir, java.lang.String finalName, java.lang.String classifier, java.lang.String type)
-
-