License Plugin
Overview¶
Build Tools for VMware Aria utilizes the license-maven-plugin as a production-ready solution for managing licenses. The plugin is activated during the project build phase if the license_data/licenses.properties file exists in the project's root directory. Upon activation, it generates a license file and a license header using the templates provided in the license_data/ folder.
Usage¶
Generating a Project with Custom Licensing¶
You must provide the following additional parameters when creating a new project:
licenseUrl- This parameter has a default value of
null. - When configured, the license URL is included in the new project's
pom.xmldescription. The content found at the URL is saved as a license template file and utilized during the project's build phase.
- This parameter has a default value of
licenseHeader- Valid values: Either raw text or a valid URL.
- If set: The provided text or the content from the URL is stored in a
license_headertemplate. The contents of this file are then used to populate the license header of each code file during the project's build phase. - If not set: The system defaults to using
"Copyright [yyyy] [name of copyright owner]"for thelicense_header.
licenseTechnicalPreview- If set: The default VMware Technical Preview license is applied to the generated project. When this flag is used, all previously mentioned properties (
licenseUrlandlicenseHeader) are ignored.
- If set: The default VMware Technical Preview license is applied to the generated project. When this flag is used, all previously mentioned properties (
Command-Line Examples¶
Standard Custom Licensing Example:
mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=com.vmware.pscoe.o11n.archetypes \
-DarchetypeArtifactId=package-actions-archetype \
-DarchetypeVersion=4.23.0 # (1)! \
-DgroupId=com.company.bu # (2)! \
-DartifactId=project.type # (3)! \
-DlicenseUrl=https://example.com/license \
-DlicenseHeader="Example License Header"
- This parameter is optional. The default value is 2.38.1. Note that archetype contents may change so it is recommended to use an up-to-date version.
- The
groupIdin Maven is a distinct identifier that is used as a base name of the company or group that creates the project. It acts as a namespace that ensures that project names don't clash with each other. It is recommended to choose agroupIdthat reflects your organization or main project. - The
artifactIdis a unique identifier for a specific project or module within a company or group project. It represents the name of the artifact that is generated by the project. It is recommended to choose anartifactIdthat reflects the specific project (and project type).
Technical Preview License Example:
mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=com.vmware.pscoe.o11n.archetypes \
-DarchetypeArtifactId=package-actions-archetype \
-DarchetypeVersion=4.23.0 # (1)! \
-DgroupId=com.company.bu # (2)! \
-DartifactId=project.type # (3)! \
-DlicenseTechnicalPreview
- This parameter is optional. The default value is 2.38.1. Note that archetype contents may change so it is recommended to use an up-to-date version.
- The
groupIdin Maven is a distinct identifier that is used as a base name of the company or group that creates the project. It acts as a namespace that ensures that project names don't clash with each other. It is recommended to choose agroupIdthat reflects your organization or main project. - The
artifactIdis a unique identifier for a specific project or module within a company or group project. It represents the name of the artifact that is generated by the project. It is recommended to choose anartifactIdthat reflects the specific project (and project type).
Generating Licenses Manually¶
If the maven-license-plugin is active, running mvn install automatically generates the license file and headers. You can also manually generate a third-party license list by executing mvn license:add-third-party -Dlicense.useMissingFile. For additional usage details, refer to the official MojoHaus documentation.
Output Examples¶
Generated Header in a .js File:
/*
* Example License
* %%
* Copyright (C) 2020 VMWARE
* %%
*/
/**
* Write a brief description of the purpose of the action.
* @param {number} x - describe each parameter as in JSDoc format.
* @param {number} y - you can use different vRO types.
* @returns {number} - describe the return type as well
*/
(function (x, y) {
return x + y;
});
Generated Content in pom.xml:
...
<description>
This package is licensed under https://example.com/license
</description>
...
<licenses>
<license>
<url>[https://example.com/license](https://example.com/license)</url>
</license>
</licenses>
...
Customizing the maven-license-plugin¶
You can customize the plugin's behavior by modifying its properties within the project's pom.xml. The default configuration values are as follows:
<properties>
<license.licenseName>_license</license.licenseName>
<license.encoding>UTF-8</license.encoding>
<license.licenseResolver>${project.baseUri}license_data</license.licenseResolver>
<license.licenceFile>${basedir}/LICENSE</license.licenceFile>
<license.thirdPartyFilename>THIRD-PARTY</license.thirdPartyFilename>
<license.useMissingFile>true</license.useMissingFile>
<license.organizationName>VMWARE</license.organizationName>
<license.excludedScopes>test</license.excludedScopes>
<license.excludedArtifacts>maven-surefire-plugin</license.excludedArtifacts>
<license.excludeTransitiveDependencies>true</license.excludeTransitiveDependencies>
<license.canUpdateCopyright>true</license.canUpdateCopyright>
<license.canUpdateDescription>true</license.canUpdateDescription>
<license.includes>**/*.js,**/*.ts</license.includes>
<license.excludes></license.excludes>
</properties>