@@ -51,3 +51,63 @@ Optionally, run this command with `--global` to apply this configuration globall
5151* Go-related tasks are automatically linked to ` test ` , ` assemble ` , ` check ` , and ` build ` tasks
5252* A configuration ` goBinaries ` is created, and it can be used to depend on the Go binaries like
5353 ` implementation(projects(":go-subprojcet", "goBinaries")) `
54+
55+ ## Generating license files for a plugin
56+
57+ The ` license-file-generator ` plugin generates license files for third-party runtime dependencies and bundles them into the plugin's resources folder.
58+
59+ ### Setup
60+
61+ Apply the plugin to the subproject that packages the plugin (usually ` sonar-<language>-plugin ` ):
62+ ``` kotlin
63+ plugins {
64+ id(" org.sonarsource.cloud-native.license-file-generator" )
65+ }
66+ ```
67+
68+ ### Configuration
69+
70+ The plugin exposes a ` licenseGenerationConfig ` extension with the following options:
71+
72+ | Property | Type | Default | Description |
73+ | ------------------------------| ---------------------| -----------------------------------------------------------------| --------------------------------------------------------------------------|
74+ | ` projectLicenseFile ` | ` File ` | ` ../LICENSE.txt ` (one level above the plugin project directory) | The project's own license file. |
75+ | ` dependencyLicenseOverrides ` | ` Map<String, File> ` | empty | Per-dependency license file overrides. Keys use the ` group:name ` format. |
76+
77+ Example configuration (Groovy DSL):
78+ ``` groovy
79+ licenseGenerationConfig {
80+ projectLicenseFile.set(file("../LICENSE.txt"))
81+ dependencyLicenseOverrides.put("com.salesforce:apex-jorje-lsp-minimized", file("../build-logic/common/gradle-modules/src/main/resources/licenses/BSD-3.txt"))
82+ }
83+ ```
84+
85+ Example configuration (Kotlin DSL):
86+ ``` kotlin
87+ licenseGenerationConfig {
88+ projectLicenseFile.set(file(" ../LICENSE.txt" ))
89+ dependencyLicenseOverrides.put(" com.salesforce:apex-jorje-lsp-minimized" , file(" ../build-logic/common/gradle-modules/src/main/resources/licenses/BSD-3.txt" ))
90+ }
91+ ```
92+
93+ Use ` dependencyLicenseOverrides ` when the plugin cannot automatically resolve the correct license for a dependency (e.g., the dependency jar does not include a license file and its POM license title is not recognized).
94+
95+ ### Available bundled license files
96+
97+ The following license files are bundled in this module and can be referenced in overrides:
98+ ` 0BSD.txt ` , ` Apache-2.0.txt ` , ` BSD-2.txt ` , ` BSD-3.txt ` , ` GNU-LGPL-3.txt ` , ` Go.txt ` , ` lgpl-2.1.txt ` , ` MIT.txt `
99+
100+ ### Tasks
101+
102+ | Task | Description |
103+ | ----------------------------| ---------------------------------------------------------------------------------------------------------------|
104+ | ` generateLicenseReport ` | Generates license files into the build directory. |
105+ | ` generateLicenseResources ` | Copies generated license files to ` src/main/resources/licenses/ ` . Run this to update committed license files. |
106+ | ` validateLicenseFiles ` | Validates that committed license files match the generated ones. Runs as part of ` check ` . |
107+
108+ ### Workflow
109+
110+ 1 . Apply the plugin and configure ` licenseGenerationConfig ` if needed
111+ 2 . Run ` ./gradlew generateLicenseResources ` to generate and copy license files into ` src/main/resources/licenses/ `
112+ 3 . Commit the generated files
113+ 4 . The ` check ` task will automatically validate that committed license files are up-to-date via ` validateLicenseFiles `
0 commit comments