Search code examples
gradleandroid-gradle-pluginlicensinggradle-plugin

Got empty license reports with hierynomus' gradle license plugin


I'm making two android apps on a Gradle project and managing dependency licenses with Hierynomus' gradle license plugin. Then, I executed following commands:

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

But the generated license reports are empty.

{"dependencies":[]}

I tried to fix the problem with the documents below:

but I couldn't resolve the problem.

Next, I tried to execute the task with --refresh-dependencies and --rerun-tasks options. Sadly, the problem hadn't fixed.

Those are my build scripts:

// 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'
}

No doubt I expected dependencies license reports of my project were generated under ${PROJECT_ROOT}/build/reports/license/. I found the reports are generated, however, those were empty.

Thanks!


Solution

  • It seems to be a problem with version 0.15.0 Fix getting licenses on Android.

    For me, it worked with version 0.14.0 and some additional configurations:

    // 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)