Package org.codehaus.mojo.license
Class AddThirdPartyMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.license.AbstractLicenseMojo
org.codehaus.mojo.license.AbstractAddThirdPartyMojo
org.codehaus.mojo.license.AddThirdPartyMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo,MavenProjectDependenciesConfigurator
@Mojo(name="add-third-party",
requiresDependencyResolution=TEST,
defaultPhase=GENERATE_RESOURCES,
threadSafe=true)
public class AddThirdPartyMojo
extends AbstractAddThirdPartyMojo
implements MavenProjectDependenciesConfigurator
Goal to generate the third-party license file.
This file contains a list of the dependencies and their licenses. Each dependency and its license is displayed on a single line in the format
(<license-name>) <project-name> <groupId>:<artifactId>:<version> - <project-url>The directory containing the license database file is added to the classpath as an additional resource.
- Since:
- 1.0
- Author:
- tchemit dev@tchemit.fr
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
AbstractAddThirdPartyMojo.ExcludedLicenses, AbstractAddThirdPartyMojo.IncludedLicenses -
Field Summary
Fields inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
acceptPomPackaging, artifactFiltersUrl, bundleThirdPartyPath, dependencies, deployMissingFile, doGenerate, doGenerateBundle, excludedArtifacts, excludedGroups, excludedLicenses, excludedScopes, excludedTypes, failIfWarning, failOnBlacklist, failOnMissing, fileTemplate, force, generateBundle, includedArtifacts, includedGroups, includedLicenses, includedScopes, includedTypes, licenseMap, licenseMerges, licenseMergesFile, licenseMergesUrl, missingFile, missingFileUrl, missingLicensesFileArtifact, outputDirectory, projectDependencies, resolvedOverrideUrl, sortArtifactByName, thirdPartyFilename, unsafeDependencies, unsafeMappings, useMissingFile, useRepositoryMissingFilesFields inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
projectHelperFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionAddThirdPartyMojo(ThirdPartyTool thirdPartyTool, DependenciesTool dependenciesTool, org.apache.maven.project.MavenProjectHelper projectHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCheck if the project packaging is acceptable for the mojo.protected SortedPropertiesCreates the unsafe mapping (says dependencies with no license given by their pom).protected voiddoAction()Do plugin action.booleanbooleanbooleanisSkip()When is sets totrue, will skip execution.Loads the dependencies of the project (asMavenProject, indexed by their gav.protected ResolvedProjectDependenciesResolves the transitive and direct dependency sets for this project.protected booleanChecks if the mojo execution should be skipped.Methods inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
getHelper, init, setExcludedLicenses, setIncludedLicensesMethods inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
acceptPackaging, addResourceDir, afterExecute, checkEncoding, execute, getEncoding, getProject, hasClassPath, isVerbose, rejectPackaging, setEncoding, setVerboseMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator
isVerbose
-
Constructor Details
-
AddThirdPartyMojo
@Inject public AddThirdPartyMojo(ThirdPartyTool thirdPartyTool, DependenciesTool dependenciesTool, org.apache.maven.project.MavenProjectHelper projectHelper)
-
-
Method Details
-
isSkip
public boolean isSkip()When is sets totrue, will skip execution. This will take effect in at the very begin of theAbstractLicenseMojo.execute()before any initialisation of goal.- Specified by:
isSkipin classAbstractLicenseMojo- Returns:
trueif goal will not be executed
-
checkPackaging
protected boolean checkPackaging()Check if the project packaging is acceptable for the mojo. By default, accept all packaging types. Note: This method is the first instruction to be executed in theAbstractLicenseMojo.execute(). Tip: There is two method to simplify the packaging check :AbstractLicenseMojo.acceptPackaging(String...)andAbstractLicenseMojo.rejectPackaging(String...)- Overrides:
checkPackagingin classAbstractLicenseMojo- Returns:
trueif can execute the goal for the packaging of the project,falseotherwise.
-
shouldSkip
protected boolean shouldSkip()Checks if the mojo execution should be skipped.- Overrides:
shouldSkipin classAbstractLicenseMojo- Returns:
trueif the mojo should not be executed.
-
doAction
Do plugin action. The methodAbstractLicenseMojo.execute()invoke this method only and only if :AbstractLicenseMojo.checkPackaging()returnstrue.- method
AbstractLicenseMojo.init()returnstrue.
- Specified by:
doActionin classAbstractLicenseMojo- Throws:
Exception- if any
-
loadDependencies
protected SortedMap<String,org.apache.maven.project.MavenProject> loadDependencies() throws DependenciesToolExceptionLoads the dependencies of the project (asMavenProject, indexed by their gav.- Specified by:
loadDependenciesin classAbstractAddThirdPartyMojo- Returns:
- the map of dependencies of the maven project indexed by their gav.
- Throws:
DependenciesToolException- if the dependencies could not be loaded
-
resolveDependencyArtifacts
Resolves the transitive and direct dependency sets for this project.- Returns:
- The set of all dependencies, and the set of only direct dependency artifacts.
- Throws:
DependenciesToolException- if the dependencies could not be resolved
-
createUnsafeMapping
protected SortedProperties createUnsafeMapping() throws org.apache.maven.project.ProjectBuildingException, IOException, ThirdPartyToolException, org.apache.maven.plugin.MojoExecutionException, DependenciesToolExceptionCreates the unsafe mapping (says dependencies with no license given by their pom).Can come from loaded missing file or from dependencies with no license at all.
- Specified by:
createUnsafeMappingin classAbstractAddThirdPartyMojo- Returns:
- the map of usafe mapping indexed by their gav.
- Throws:
org.apache.maven.project.ProjectBuildingException- if could not create maven project for some dependenciesIOException- if could not load missing fileThirdPartyToolException- for third party tool errorDependenciesToolException- if the dependencies could not be loadedorg.apache.maven.plugin.MojoExecutionException
-
isIncludeTransitiveDependencies
public boolean isIncludeTransitiveDependencies()- Specified by:
isIncludeTransitiveDependenciesin interfaceMavenProjectDependenciesConfigurator- Returns:
trueif should include transitive dependencies,falseto include only direct dependencies.
-
isExcludeTransitiveDependencies
public boolean isExcludeTransitiveDependencies()- Specified by:
isExcludeTransitiveDependenciesin interfaceMavenProjectDependenciesConfigurator- Returns:
trueif should exclude transitive dependencies from excluded artifacts, elsefalse.
-
getArtifactFilters
- Specified by:
getArtifactFiltersin interfaceMavenProjectDependenciesConfigurator- Returns:
ArtifactFiltersto apply when processing dependencies
-