This Gradle plugin provides tasks to generate a file with the licenses used from the project's dependencies.
Kotlin
plugins {
id("com.cmgapps.licenses") version "4.8.0"
}
Groovy
plugins {
id 'com.cmgapps.licenses' version '4.8.0'
}
Kotlin
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.cmgapps:gradle-licenses-plugin:4.8.0")
}
}
apply(plugin = "com.cmgapps.licenses")
Groovy
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.cmgapps:gradle-licenses-plugin:4.8.0'
}
}
apply plugin: 'com.cmgapps.licenses'
Applying the plugin will create tasks to generate the license report
For "java"
and "java-library"
licenseReport
For "com.android.application"
, "com.android.library"
, "com.android.feature"
and "com.android.dynamic-feature"
license<variant>Report
For "org.jetbrains.kotlin.multiplatform"
licenseMultiplatformReport
collects licenses from all targetslicenseMultiplatform<target>Report
collects licenses fromcommon
and the specified<target>
Example:
licenses {
reports {
html.enabled = false // html is enabled by default
xml {
enabled = true
destination = file("$buildDir/reports/licenses.xml")
}
}
}
The plugin can output different formats.
-
HTML
generates a formatted HTML website-
Styling
For an HTML report you can define custom stylesheet using a
File
orString
:licenses { reports { html.stylesheet("body {background: #FAFAFA}") } }
or
licenses { reports { html.stylesheet(file("$projectDir/styles/licenses.css")) } }
-
On the default CSS style Dark Mode for supported browsers is also enabled by default. It adds a
<meta name="color-scheme" content="dark light">
and a custom css theme.It can be disabled via
licenses { reports { html.useDarkMode.set(false) } }
-
-
JSON
generates a JSON file -
XML
generates a valid XML version 1.0 file -
Text
generates a plain text report file -
Mardown
generates a Markdown file -
Custom
add your own reporter as a lambda functionKotlin
licenses { custom { enabled = true destination = buildDir.resolve("reports").resolve("licenses.txt") generate { list -> list.map { it.name }.joinToString() } } }
Groovy
licenses { custom { enabled = true destination = file("$buildDir/reports/licenses/licenses.txt") generate { list -> list.collect { it.name }.join(', ') } } }
For multi-project build, you can add projects you want to collect license information from in the main project.
Kotlin
licenses {
additionalProjects(":module2", ":module3")
}
Groovy
licenses {
additionalProjects ':module2', ':module3'
}
Copyright (c) 2018. Christian Grach <[email protected]>
SPDX-License-Identifier: Apache-2.0