【问题标题】:Gradle: get list of dependencies and licensesGradle:获取依赖项和许可证列表
【发布时间】:2021-07-27 06:52:13
【问题描述】:

我需要获取所有依赖项及其许可证的列表。

到目前为止,我已经尝试了几个插件,但它们处于各种不工作状态......

看来我最好的选择可能是生成 maven pom.xml 并调用 maven 许可证插件...

有什么建议吗?

【问题讨论】:

    标签: gradle


    【解决方案1】:

    问题

    问题是插件(hierynomus/license-gradle-plugin)默认采用无法解析的依赖配置。在 github 存储库中打开了一些问题。

    似乎最新的 Gradle 版本或这个插件版本破坏了一些东西。我希望尽快找到解决方案..

    这里是关于resolvable dependencies in Gradle documentation的话题

    解决方案

    以下是获取报告的解决方法。

    1. 应用插件
    2. 配置你想要的依赖类型 已生成报告。例如对于 Java 项目那些 配置可以是 compileClasspath 或 runtimeClasspath。

    下面的构建脚本示例(在 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'
    }
    

    执行后的报告应该位于 build/reports/licence

    【讨论】:

    • 非常感谢 - 我想我应该更坚持:)
    猜你喜欢
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多