Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: get list of dependencies and licenses

Tags:

gradle

I need to get a list of all dependencies and their licenses.

I’ve tried a couple of plugins thus far but they are in various states of not working…

  • hierynomus/license-gradle-plugin doesn’t appear to detect any dependencies.
  • dorkbox/Licensing fails with some cryptic Kotlin error.

It seems like my best option might be to generate the maven pom.xml and call the maven license plugin…

Any suggestions?

like image 743
nwb Avatar asked Sep 05 '25 03:09

nwb


1 Answers

Issue

The problem is that plugin (hierynomus/license-gradle-plugin) by default takes dependency configuration that is not resolvable. There are some issues opened in the github repository.

  • https://github.com/hierynomus/license-gradle-plugin/issues/182
  • https://github.com/hierynomus/license-gradle-plugin/issues/181
  • https://github.com/hierynomus/license-gradle-plugin/issues/174

It seems latest Gradle version or this plugin version broke something. I expect a solution soon..

Here is the topic about resolvable dependencies in Gradle documentation

Solution

A workaround to get your report is following.

  1. Apply the plugin
  2. Configure for which type of dependencies you want to have generated report. For example for Java project those configurations can be compileClasspath or runtimeClasspath.

Exmaple of the build script below (in Groovy)

/**
 * Apply licence report plugin.
 */
plugins {
  id "com.github.hierynomus.license-report" version"0.16.1"
}

/**
 * You will have to specify for which configuration dependencies should be resolved.
 * Note check in Gradle documentation about configuration types that can be resolved.
 * https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:resolvable-consumable-configs
 *
 * Following are resolvable by default:
 * - compileClasspath
 * - runtimeClasspath
 */
downloadLicenses {
  includeProjectDependencies = true
  dependencyConfiguration = 'runtimeClasspath'
  // or
  // dependencyConfiguration = 'compileClasspath'
}

After the execution reports should be located at build/reports/licence

enter image description here

like image 71
RenatoIvancic Avatar answered Sep 09 '25 17:09

RenatoIvancic