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.AbstractMojoGenerates 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.FileclassesDirectoryWhere to find this modules classes.private java.lang.StringclassifierThe classifier to add to the generated signatures.private java.lang.String[]excludeClassesClasses to exclude from generating signatures of.private java.lang.String[]excludeDependenciesA list of artifact patterns to exclude.private java.lang.String[]includeClassesClasses to generate signatures of.private java.lang.String[]includeDependenciesA list of artifact patterns to include.private booleanincludeJavaHomeShould the signatures from java home be included.private booleanincludeModuleClassesShould the signatures from this module's classes be included..private java.lang.StringjavaHomeThe java home to generate the signatures of, if not specified only the signatures of dependencies will be included.private java.io.File[]javaHomeClassPathprivate java.lang.StringjbcpdArtifactIdThe artifactId of the Java Boot Classpath Detector to use.private java.lang.StringjbcpdGroupIdThe groupId of the Java Boot Classpath Detector to use.private JdkToolchainjdkThe JDK Toolchain to use.private java.io.FileoutputDirectoryWhere to put the generated signatures.private java.util.List<org.apache.maven.artifact.Artifact>pluginArtifactsprivate org.apache.maven.project.MavenProjectprojectThe maven project.private org.apache.maven.project.MavenProjectHelperprojectHelperprivate org.apache.maven.execution.MavenSessionsessionThe current build session instance.private java.lang.StringsignaturesNameThe name of the generated signatures.private booleanskipIfNoJavaHomeShould no signatures be generated if no java home is available.private org.apache.maven.toolchain.ToolchainManagertoolchainManagerprivate org.apache.maven.toolchain.ToolchainManagerPrivatetoolchainManagerPrivate
-
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.StringartifactId(org.apache.maven.artifact.Artifact artifact)private booleandetectJavaBootClasspath(java.lang.String javaExecutable)private booleandetectJavaClasspath(org.apache.maven.artifact.Artifact javaBootClasspathDetector, java.lang.String javaExecutable)private voiddisplayJavaBootClasspath()voidexecute()private java.io.InputStream[]getBaseSignatures()private org.apache.maven.toolchain.ToolchaingetJdkToolchain()Gets thejdktoolchain to use.private org.apache.maven.toolchain.ToolchaingetJdkToolchainFromConfiguration()Gets thejdktoolchain from this plugin's configuration.private org.apache.maven.toolchain.ToolchaingetJdkToolchainFromContext()Gets the toolchain specified for the current context, e.g.private static java.io.FilegetTargetFile(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 voidprocessJavaBootClasspath(SignatureBuilder builder)private voidprocessModuleClasses(SignatureBuilder builder)private voidprocessModuleDependencies(SignatureBuilder builder)
-
-
-
Field Detail
-
includeJavaHome
@Parameter(property="includeJavaHome", defaultValue="true") private boolean includeJavaHomeShould the signatures from java home be included.- Since:
- 1.3
-
skipIfNoJavaHome
@Parameter(property="skipIfNoJavaHome", defaultValue="false") private boolean skipIfNoJavaHomeShould no signatures be generated if no java home is available.- Since:
- 1.3
-
includeModuleClasses
@Parameter(property="includeJavaHome", defaultValue="true") private boolean includeModuleClassesShould 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:artifactIdgroupId:artifactId:typegroupId:artifactId:type:versiongroupId:artifactId:type:classifiergroupId: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:artifactIdgroupId:artifactId:typegroupId:artifactId:type:versiongroupId:artifactId:type:classifiergroupId: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 overridesjdkand 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 specificjavaHomeorjdk. For example, the automatic boot classpath detection does not work with Sun Java 1.1. This parameter overridesjavaHome,jdkand the maven-toolchains-plugin.- Since:
- 1.3
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}", required=true) private java.io.File outputDirectoryWhere to put the generated signatures.- Since:
- 1.3
-
classesDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true) private java.io.File classesDirectoryWhere to find this modules classes.- Since:
- 1.3
-
signaturesName
@Parameter(defaultValue="${project.build.finalName}", required=true) private java.lang.String signaturesNameThe 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 projectThe 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 sessionThe 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 byjavaHomeorjavaHomeClassPath. 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 jbcpdGroupIdThe groupId of the Java Boot Classpath Detector to use. The plugin's dependencies will be searched for a dependency of typejarwith 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.pathSeparatorCharor 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 typejarwith 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.pathSeparatorCharor 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.MojoExecutionExceptionorg.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.MojoFailureExceptionorg.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.CommandLineExceptionorg.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.MojoExecutionExceptionGets thejdktoolchain to use.- Returns:
- the
jdktoolchain to use ornullif 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
nullif there is no such toolchain.
-
getJdkToolchainFromConfiguration
private org.apache.maven.toolchain.Toolchain getJdkToolchainFromConfiguration() throws org.apache.maven.plugin.MojoExecutionExceptionGets thejdktoolchain from this plugin's configuration.- Returns:
- the toolchain from this plugin's configuration, or
nullif 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.MojoExecutionExceptionorg.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)
-
-