Class AbstractAddThirdPartyMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AddThirdPartyMojo,AggregatorAddThirdPartyMojo
- Since:
- 1.0
- Author:
- tchemit dev@tchemit.fr
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to fill theexcludedLicensesparameter, from a simple string to split, or a list of string.static classClass to fill theincludedLicensesparameter, from a simple string to split, or a list of string. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIftruethe mojo will be executed for reactor projects having any packaging (includingpom); otherwise the mojo will be executed only for projects that do not have packagingpom.protected StringA URL returning a plain text file that contains include/exclude artifact filters in the following format:protected StringThe path of the bundled third party file to produce whengenerateBundleis on.protected Set<org.apache.maven.artifact.Artifact> The set of dependencies for the current project, used to locate license databases.protected booleanAttach the 'missing' file as an additional artifact so that it is deployed in the deploy phase.protected booleanFlag computed in theinit()method to know if there is something has to be generated.protected booleanFlag computed in theinit()method to know if a bundle version has to be generated.protected StringA regular expression (not glob pattern) used as filter to exclude artifacts that have matching artifactId.protected StringA regular expression (not glob pattern) used as filter to exclude artifacts that have matching groupId.To specify some licenses to exclude.protected StringA comma separated list of scopes to exclude: e.g.protected StringA comma separated list of types to exclude: e.g.protected booleanDeprecated.protected booleanA flag to fail the build if at least one dependency was blacklisted.protected booleanA flag to fail the build if at least one dependency was detected without a license.protected StringTemplate used to build the third-party file.protected booleanTo force generation of the third-party file even if everything is up to date.protected booleanA flag to copy a bundled version of the third-party file.protected StringA regular expression (not glob pattern) used as filter to include only artifacts that have matching artifactId.protected StringA regular expression (not glob pattern) used as filter to include only artifacts that have matching groupId.To specify some licenses to include.protected StringA comma separated list of scopes to include: e.g.protected StringA comma separated list of types to include.protected LicenseMapTo merge licenses in final file.protected StringDeprecated.prefer use nowlicenseMergesUrlprotected StringLocation of file with the merge licenses in order to be used by command line.protected FileThe file to write with a license information template for dependencies with unknown license.protected StringThe Url that holds the missing license dependency entries.protected StringTo resolve third party licenses from an artifact.protected FileDirectory where to generate files.protected StringA URL prepared either our ofoverrideFileoroverrideUrlor the default value.protected booleanA flag to sort artifact by name in the generated third-party file.protected StringFile where to write the third-party file.protected SortedSet<org.apache.maven.project.MavenProject> protected SortedPropertiesprotected booleanA flag to use the missing licenses file to consolidate the THID-PARTY file.protected booleanLoad files supplying information for missing third party licenses from repositories.Fields inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
projectHelperFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAddThirdPartyMojo(ThirdPartyTool thirdPartyTool, DependenciesTool dependenciesTool, org.apache.maven.project.MavenProjectHelper projectHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract SortedPropertiesCreates the unsafe mapping (says dependencies with no license given by their pom).protected ThirdPartyHelperprotected voidinit()Method to initialize the mojo before doing any concrete actions.Loads the dependencies of the project (asMavenProject, indexed by their gav.voidsetExcludedLicenses(String excludedLicenses) Fill theexcludedLicensesparameter from a simple string to split.voidsetIncludedLicenses(String includedLicenses) Fill theincludedLicensesparameter from a simple string to split.Methods inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
acceptPackaging, addResourceDir, afterExecute, checkEncoding, checkPackaging, doAction, execute, getEncoding, getProject, hasClassPath, isSkip, isVerbose, rejectPackaging, setEncoding, setVerbose, shouldSkipMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
outputDirectory
@Parameter(property="license.outputDirectory", defaultValue="${project.build.directory}/generated-sources/license", required=true) protected File outputDirectoryDirectory where to generate files.- Since:
- 1.0
-
deployMissingFile
@Parameter(property="license.deployMissingFile", defaultValue="true") protected boolean deployMissingFileAttach the 'missing' file as an additional artifact so that it is deployed in the deploy phase.- Since:
- 1.0
-
useRepositoryMissingFiles
@Parameter(property="license.useRepositoryMissingFiles", defaultValue="true") protected boolean useRepositoryMissingFilesLoad files supplying information for missing third party licenses from repositories. The plugin looks for Maven artifacts with coordinates of the form G:A:V:properties:third-party, where the group, artifact, and version are those for dependencies of your project, while the type is 'properties' and the classifier is 'third-party'.- Since:
- 1.0
-
acceptPomPackaging
@Parameter(property="license.acceptPomPackaging", defaultValue="false") protected boolean acceptPomPackagingIftruethe mojo will be executed for reactor projects having any packaging (includingpom); otherwise the mojo will be executed only for projects that do not have packagingpom.Since 1.18, when
acceptPomPackagingistrue,aggregate-add-third-partymojo is executed also for the Maven session root project - i.e. the one out whose directory the mojo was executed. Before 1.18, whenacceptPomPackagingwastrue,aggregate-add-third-partymojo was iterating over all modules in the reactor but the Maven session root project was skipped.- Since:
- 1.1
-
excludedScopes
@Parameter(property="license.excludedScopes", defaultValue="system") protected String excludedScopesA comma separated list of scopes to exclude: e.g.<excludedScopes>test,provided</excludedScopes>or-Dlicense.excludedScopes=test,provided.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is excluded its transitive dependencies are not automatically excluded. To enforce this behavior refer to
excludeTransitiveDependencies.- Since:
- 1.1
-
includedScopes
A comma separated list of scopes to include: e.g.<includedScopes>test,provided</includedScopes>or-Dlicense.includedScopes=test,provided.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is included also its transitive dependencies are included. To suppress this behavior refer to
includeTransitiveDependencies.- Since:
- 1.1
-
excludedTypes
A comma separated list of types to exclude: e.g.<excludedTypes>war,pom</excludedTypes>or-Dlicense.excludedTypes=was,pom.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is excluded its transitive dependencies are not automatically excluded. To enforce this behavior refer to
excludeTransitiveDependencies.- Since:
- 1.15
-
includedTypes
A comma separated list of types to include.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is included also its transitive dependencies are included. To suppress this behavior refer to
includeTransitiveDependencies.- Since:
- 1.15
-
excludedGroups
A regular expression (not glob pattern) used as filter to exclude artifacts that have matching groupId. Match could be also partial for example^org\.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is excluded its transitive dependencies are not automatically excluded. To enforce this behavior refer to
excludeTransitiveDependencies.- Since:
- 1.1
-
includedGroups
A regular expression (not glob pattern) used as filter to include only artifacts that have matching groupId.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is included also its transitive dependencies are included. To suppress this behavior refer to
includeTransitiveDependencies.- Since:
- 1.1
-
excludedArtifacts
A regular expression (not glob pattern) used as filter to exclude artifacts that have matching artifactId. Match could be also partial for example^org\.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is excluded its transitive dependencies are not automatically excluded. To enforce this behavior refer to
excludeTransitiveDependencies.- Since:
- 1.1
-
includedArtifacts
A regular expression (not glob pattern) used as filter to include only artifacts that have matching artifactId.This filter is applied on the list of direct dependencies (and their transitive dependencies) of the projects in the reactor.
By default if an artifact is included also its transitive dependencies are included. To suppress this behavior refer to
includeTransitiveDependencies.- Since:
- 1.1
-
thirdPartyFilename
@Parameter(property="license.thirdPartyFilename", defaultValue="THIRD-PARTY.txt", required=true) protected String thirdPartyFilenameFile where to write the third-party file.- Since:
- 1.0
-
useMissingFile
@Parameter(property="license.useMissingFile", defaultValue="false") protected boolean useMissingFileA flag to use the missing licenses file to consolidate the THID-PARTY file.- Since:
- 1.0
-
missingFile
@Parameter(property="license.missingFile", defaultValue="src/license/THIRD-PARTY.properties") protected File missingFileThe file to write with a license information template for dependencies with unknown license.- Since:
- 1.0
-
missingFileUrl
The Url that holds the missing license dependency entries. This is an extension tomissingFile. If set then the entries that will be found at this URL will be added additionally to the entries of the missing file.
NOTE:
the response of the URL endpoint must return content that matches the THIRD-PARTY.properties file!- Since:
- 1.15
-
missingLicensesFileArtifact
@Parameter(property="license.missingLicensesFileArtifact") protected String missingLicensesFileArtifactTo resolve third party licenses from an artifact.- Since:
- 1.14
-
resolvedOverrideUrl
A URL prepared either our ofoverrideFileoroverrideUrlor the default value.- See Also:
-
licenseMerges
To merge licenses in final file.Each entry represents a merge (first license is main license to keep), licenses are separated by
|.Example :
<licenseMerges> <licenseMerge>The Apache Software License|Version 2.0,Apache License, Version 2.0</licenseMerge> </licenseMerges> </pre> Note: This option will be overridden by
licenseMergesUrlif it is used by command line.- Since:
- 1.0
-
licenseMergesFile
Deprecated.prefer use nowlicenseMergesUrlThe file with the merge licenses in order to be used by command line. Note: This option overrideslicenseMerges.- Since:
- 1.15
-
licenseMergesUrl
Location of file with the merge licenses in order to be used by command line. Note: This option overrideslicenseMerges.- Since:
- 1.17
-
includedLicenses
@Parameter(property="license.includedLicenses") protected AbstractAddThirdPartyMojo.IncludedLicenses includedLicensesTo specify some licenses to include.If this parameter is filled and a license is not in this
whitelistthen build will fail when propertyfailOnBlacklistis true.Since version
1.4, there are three ways to fill this parameter :- A simple string (separated by
|), the way to use by property configuration:<includedLicenses>licenseA|licenseB</includedLicenses>
or-Dlicense.includedLicenses=licenseA|licenseB
- A list of string (can only be used in plugin configuration, not via property configuration)
<includedLicenses> <includedLicense>licenseA</includedLicense> <includedLicenses>licenseB</includedLicense> </includedLicenses>
- Since version
1.15
a URL that contains a set of license names at the target source (only a single URL is accepted as parameter)<includedLicenses>http://my.license.host.com/my-whitelist</includedLicenses>the license-list on the given URL is expected to be list with a line-break after every entry e.g.:- The Apache Software License, Version 2.0
- Apache License, Version 2.0
- Bouncy Castle Licence
- MIT License
- Since:
- 1.1
- A simple string (separated by
-
excludedLicenses
@Parameter(property="license.excludedLicenses") protected AbstractAddThirdPartyMojo.ExcludedLicenses excludedLicensesTo specify some licenses to exclude.If a such license is found then build will fail when property
failOnBlacklistis true.Since version
1.4, there are three ways to fill this parameter :- A simple string (separated by
|), the way to use by property configuration:<excludedLicenses>licenseA|licenseB</excludedLicenses>
or-Dlicense.excludedLicenses=licenseA|licenseB
- A list of string (can only be used in plugin configuration, not via property configuration)
<excludedLicenses> <excludedLicense>licenseA</excludedLicense> <excludedLicense>licenseB</excludedLicense> </excludedLicenses>
- Since version
1.15
a URL that contains a set of license names at the target source (only a single URL is accepted as parameter)<includedLicenses>http://my.license.host.com/my-blacklist</includedLicenses>
the license-list on the given URL is expected to be list with a line-break after every entry e.g.:- The Apache Software License, Version 2.0
- Apache License, Version 2.0
- Bouncy Castle Licence
- MIT License
- Since:
- 1.1
- A simple string (separated by
-
bundleThirdPartyPath
@Parameter(property="license.bundleThirdPartyPath", defaultValue="META-INF/${project.artifactId}-THIRD-PARTY.txt") protected String bundleThirdPartyPathThe path of the bundled third party file to produce whengenerateBundleis on.Note: This option is not available for
pommodule types.- Since:
- 1.0
-
generateBundle
@Parameter(property="license.generateBundle", defaultValue="false") protected boolean generateBundleA flag to copy a bundled version of the third-party file. This is useful to avoid for a final application collision name of third party file.The file will be copied at the
bundleThirdPartyPathlocation.- Since:
- 1.0
-
force
@Parameter(property="license.force", defaultValue="false") protected boolean forceTo force generation of the third-party file even if everything is up to date.- Since:
- 1.0
-
failIfWarning
@Deprecated @Parameter(property="license.failIfWarning", defaultValue="false") protected boolean failIfWarningDeprecated.since 1.14, use nowfailOnMissingorfailOnBlacklist.A flag to fail the build if at least one dependency was detected without a license.- Since:
- 1.0
-
failOnMissing
@Parameter(property="license.failOnMissing", defaultValue="false") protected boolean failOnMissingA flag to fail the build if at least one dependency was detected without a license.- Since:
- 1.14
-
failOnBlacklist
@Parameter(property="license.failOnBlacklist", defaultValue="false") protected boolean failOnBlacklistA flag to fail the build if at least one dependency was blacklisted.- Since:
- 1.14
-
sortArtifactByName
@Parameter(property="license.sortArtifactByName", defaultValue="false") protected boolean sortArtifactByNameA flag to sort artifact by name in the generated third-party file.If not then artifacts are sorted by
groupId:artifactId:version
- Since:
- 1.6
-
fileTemplate
@Parameter(property="license.fileTemplate", defaultValue="/org/codehaus/mojo/license/third-party-file.ftl") protected String fileTemplateTemplate used to build the third-party file.(This template uses freemarker).
Note: This property can either point to a file or a resource on the classpath. In case it points to a file and this plugin is used within a sub-module as part of a multi-module build, you need to make this path resolvable, e.g. by prepending
basedir.- Since:
- 1.1
-
dependencies
@Parameter(property="project.artifacts", required=true, readonly=true) protected Set<org.apache.maven.artifact.Artifact> dependenciesThe set of dependencies for the current project, used to locate license databases. -
projectDependencies
-
licenseMap
-
unsafeDependencies
-
unsafeMappings
-
doGenerate
protected boolean doGenerateFlag computed in theinit()method to know if there is something has to be generated. -
doGenerateBundle
protected boolean doGenerateBundleFlag computed in theinit()method to know if a bundle version has to be generated. -
artifactFiltersUrl
A URL returning a plain text file that contains include/exclude artifact filters in the following format:# this is a comment include gaPattern org\.my-org:my-artifact include gaPattern org\.other-org:other-artifact exclude gaPattern org\.yet-anther-org:.* include scope compile include scope test exclude scope system include type jar exclude type war- Since:
- 1.18
-
-
Constructor Details
-
AbstractAddThirdPartyMojo
protected AbstractAddThirdPartyMojo(ThirdPartyTool thirdPartyTool, DependenciesTool dependenciesTool, org.apache.maven.project.MavenProjectHelper projectHelper)
-
-
Method Details
-
loadDependencies
protected abstract SortedMap<String,org.apache.maven.project.MavenProject> loadDependencies() throws DependenciesToolExceptionLoads the dependencies of the project (asMavenProject, indexed by their gav.- Returns:
- the map of dependencies of the maven project indexed by their gav.
- Throws:
DependenciesToolException- if the dependencies could not be loaded
-
createUnsafeMapping
protected abstract 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.
- 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
-
init
Method to initialize the mojo before doing any concrete actions. Note: The method is invoked before theAbstractLicenseMojo.doAction()method.- Specified by:
initin classAbstractLicenseMojo- Throws:
Exception- if any
-
setIncludedLicenses
public void setIncludedLicenses(String includedLicenses) throws org.apache.maven.plugin.MojoExecutionException Fill theincludedLicensesparameter from a simple string to split.- Parameters:
includedLicenses- license to excludes separated by a|.- Throws:
org.apache.maven.plugin.MojoExecutionException
-
setExcludedLicenses
public void setExcludedLicenses(String excludedLicenses) throws org.apache.maven.plugin.MojoExecutionException Fill theexcludedLicensesparameter from a simple string to split.- Parameters:
excludedLicenses- license to excludes separated by a|.- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getHelper
-
failOnMissingorfailOnBlacklist.