【问题标题】:Got empty license reports with hierynomus' gradle license plugin使用 hierynomus 的 gradle 许可证插件得到空的许可证报告
【发布时间】:2019-03-28 12:09:51
【问题描述】:

我正在一个 Gradle 项目上制作两个 Android 应用程序,并使用 Hierynomus 的 gradle license plugin 管理依赖项许可证。 然后,我执行了以下命令:

$ ./gradlew downloadLicenses
$ cat ./build/reports/license/dependency-license.json

但是生成的许可证报告是空的。

{"dependencies":[]}

我尝试通过以下文档解决问题:

但我无法解决问题。

接下来,我尝试使用--refresh-dependencies--rerun-tasks 选项执行任务。遗憾的是,问题并没有解决。

这些是我的构建脚本:

// build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.21'
    ext.kotlin_coroutine_version = '1.1.1'
    repositories {
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.12.1'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "http://dl.bintray.com/jetbrains/spek" }
    }

    apply plugin: 'com.github.ben-manes.versions'
    apply plugin: 'com.github.hierynomus.license'

    downloadLicenses {
        includeProjectDependencies = true
        dependencyConfiguration = 'implementation'
        ext.apacheTwo = license('Apache License, Version 2.0', 'https://opensource.org/licenses/Apache-2.0')
        ext.bsd = license('BSD License', 'https://opensource.org/licenses/bsd-license')
        aliases = [
            (apacheTwo): [
                'The Apache Software License, Version 2.0',
                'Apache 2',
                'Apache License Version 2.0',
                'Apache License, Version 2.0',
                'Apache License 2.0',
                license('Apache License', 'https://www.apache.org/licenses/LICENSE-2.0')
            ],
            (bsd): [
                'BSD',
                license('New BSD License', 'https://opensource.org/licenses/bsd-license')
            ]
        ]
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
// app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "xyz.tech-frodo.testFirebaseApp.console"
        minSdkVersion 26
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        lintConfig file("lint.xml")
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-firestore:18.1.0'
    implementation 'com.github.kittinunf.fuel:fuel:1.12.0'
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlin_coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-annotations:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
// client/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "xyz.tech-frodo.testFirebaseApp.client"
        minSdkVersion 27
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-firestore:18.1.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlin_coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
    implementation 'com.github.kittinunf.fuel:fuel:1.12.0'
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.maps:google-maps-services:0.9.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'org.jetbrains.spek:spek-api:1.1.5'
    testImplementation 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'
    testImplementation 'org.mockito:mockito-core:+'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.junit.platform:junit-platform-runner:1.1.0'
    testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

毫无疑问,我希望我的项目的依赖项许可证报告是在${PROJECT_ROOT}/build/reports/license/ 下生成的。我发现报告已生成,但是那些是空的。

谢谢!

【问题讨论】:

  • 曾经解决过这个问题吗?您是否向插件作者提交了报告?试试其他插件?
  • 是的,最后我无法解决问题。我在插件的仓库中打开了一个问题,但仍未解决。

标签: gradle android-gradle-plugin licensing gradle-plugin


【解决方案1】:

似乎是版本 0.15.0 Fix getting licenses on Android 的问题。

对我来说,它适用于 0.14.0 版和一些附加配置:

// buil.gradle root
plugins {
   id "com.github.hierynomus.license" version "0.14.0"
}

downloadLicenses {
   dependencyConfiguration = 'implementation'
   includeProjectDependencies = true
}

// build.gradle app
apply plugin: 'com.github.hierynomus.license'
configurations.implementation.setCanBeResolved(true)
configurations.api.setCanBeResolved(true)

【讨论】:

  • 谢谢。它对我有用。我有基于java的spring boot项目。经过大量的尝试和错误,它终于奏效了。但是configurations.api会导致构建错误。所以我删除了该配置.api 行,然后也删除了应用插件行,它仍然有效。我用的是 gradle 6.7 版本。
  • 同意上面的帖子(mohan),同样,必须删除“api”行....但是当其他建议不起作用时这有效...(赞赏)。我还能够让它与 Gradle 6.8 和 7.2 一起使用。
  • 另外,对于那些想要现代化的人......我还能够使用最新的 0.16.1 和 Gradle 7.2,它应该可以自己工作,但在添加上述添加之前没有(除了必须删除 api 行)
猜你喜欢
  • 2016-11-24
  • 2023-04-08
  • 2015-04-04
  • 1970-01-01
  • 1970-01-01
  • 2022-01-21
  • 1970-01-01
  • 1970-01-01
  • 2014-03-01
相关资源
最近更新 更多