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, useRepositoryMissingFiles
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
ConstructorsConstructorDescriptionAddThirdPartyMojo
(ThirdPartyTool thirdPartyTool, DependenciesTool dependenciesTool) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Check if the project packaging is acceptable for the mojo.protected SortedProperties
Creates the unsafe mapping (says dependencies with no license given by their pom).protected void
doAction()
Do plugin action.boolean
boolean
boolean
isSkip()
When is sets totrue
, will skip execution.Loads the dependencies of the project (asMavenProject
, indexed by their gav.protected ResolvedProjectDependencies
Resolves the transitive and direct dependency sets for this project.protected boolean
Checks if the mojo execution should be skipped.Methods inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
getHelper, init, setExcludedLicenses, setIncludedLicenses
Methods inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
acceptPackaging, addResourceDir, afterExecute, checkEncoding, execute, getEncoding, getProject, hasClassPath, isVerbose, rejectPackaging, setEncoding, setVerbose
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator
isVerbose
-
Constructor Details
-
AddThirdPartyMojo
-
-
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:
isSkip
in classAbstractLicenseMojo
- Returns:
true
if 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:
checkPackaging
in classAbstractLicenseMojo
- Returns:
true
if can execute the goal for the packaging of the project,false
otherwise.
-
shouldSkip
protected boolean shouldSkip()Checks if the mojo execution should be skipped.- Overrides:
shouldSkip
in classAbstractLicenseMojo
- Returns:
true
if 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:
doAction
in 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:
loadDependencies
in 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:
createUnsafeMapping
in 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:
isIncludeTransitiveDependencies
in interfaceMavenProjectDependenciesConfigurator
- Returns:
true
if should include transitive dependencies,false
to include only direct dependencies.
-
isExcludeTransitiveDependencies
public boolean isExcludeTransitiveDependencies()- Specified by:
isExcludeTransitiveDependencies
in interfaceMavenProjectDependenciesConfigurator
- Returns:
true
if should exclude transitive dependencies from excluded artifacts, elsefalse
.
-
getArtifactFilters
- Specified by:
getArtifactFilters
in interfaceMavenProjectDependenciesConfigurator
- Returns:
ArtifactFilters
to apply when processing dependencies
-