license-gradle-plugin icon indicating copy to clipboard operation
license-gradle-plugin copied to clipboard

Report is empty (Android)

Open st-f opened this issue 6 years ago • 12 comments

I can't see an empty message, just empty table headers. I'm using :

buildscript {
   dependencies {
        classpath 'com.github.hierynomus:license-gradle-plugin:0.15.0'
    }
}

plugins {
    id "com.github.hierynomus.license" version "0.15.0"
}

allprojects {
    apply plugin: 'com.github.hierynomus.license'
}

downloadLicenses {
    includeProjectDependencies = true
    dependencyConfiguration = 'implementation'
}

in build.gradle and ./gradlew downloadLicenses to run it.

Related: #104, #113

st-f avatar Feb 14 '19 01:02 st-f

See https://github.com/hierynomus/license-gradle-plugin/issues/113#issuecomment-471787647

asarkar avatar Mar 11 '19 23:03 asarkar

@asarkar that does not solve this issue.

emilaleborn avatar Mar 12 '19 10:03 emilaleborn

@cezium It does, I’m using it. Can you post a MCVE?

asarkar avatar Mar 13 '19 10:03 asarkar

@asarkar

DependencyTest.zip

unzip DependencyTest.zip 
cd DependencyTest/
 ./gradlew downloadLicenses
 cat app/build/reports/license/dependency-license.json 

Should not be an empty report

emilaleborn avatar Mar 13 '19 12:03 emilaleborn

@cezium Your project doesn't apply the license plugin or my suggestion.

asarkar avatar Mar 13 '19 18:03 asarkar

@cezium Your project doesn't apply the license plugin or my suggestion.

It uses the plugin syntax for Gradle 2.1 and above. Look in app/build.gradle @asarkar

emilaleborn avatar Mar 14 '19 12:03 emilaleborn

The problem appears on my project the same as @cezium and @st-f 's project. I tried to resolve the matter following the approach suggested those sources:

Unfortunately, however, the issue is still unresolved. Can you help me?

my build scripts are here: [HELP] BUILD SCRIPTS OF MY GRADLE PROJECT - GitHub Gist

frodo821 avatar Mar 29 '19 09:03 frodo821

Has anybody figured this out? I'm also getting empty report; just the header.

kofikofi avatar Apr 30 '19 01:04 kofikofi

We use a multi module build with Gradle:

Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_212 (Oracle Corporation 25.212-b03)
OS:           Linux 4.15.0-50-generic amd64

When executing the :downloadLicences I get only an empty report. Tried to apply dependencyConfiguration = 'compileClasspath' did not change anything.

EDIT: It seems the plugin must now be manually applied to all submodules? Is this the correct behavior? If I apply it to a sub module then it will generate the reports. But I remember that once it worked even when applied to the root module.

tfelix avatar May 24 '19 15:05 tfelix

I am still seeing this same behavior. Has anybody got this to work? here is my gradle file:

buildscript { ext.kotlin_version = '1.3.50' ext.app_base_version = '1.3' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.3' classpath 'io.sentry:sentry-android-gradle-plugin:1.7.30'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

plugins { id "com.github.hierynomus.license-report" version "0.15.0" }

allprojects { repositories { google() jcenter() maven { url "https://jitpack.io" } } apply plugin: 'com.github.hierynomus.license' }

downloadLicenses { includeProjectDependencies = true dependencyConfiguration = 'implementation' }

task clean(type: Delete) { delete rootProject.buildDir }

scotzark avatar Mar 26 '20 14:03 scotzark

Using releaseRuntimeClasspath works.

This can help debugging:

class TestLicenseTask extends DefaultTask {
    @TaskAction
    def greet() {
        project.configurations.findAll {
            isResolvable(it)
        }.each { cfg ->
            if (project.configurations.any { it.name == cfg.name && isResolvable(it) }) {
                def configuration = project.configurations.getByName(cfg.name)
                println "${cfg.name}:"
                configuration.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact d ->
                    String dependencyDesc = "$d.moduleVersion.id.group:$d.moduleVersion.id.name:$d.moduleVersion.id.version".toString()
                    println " - $dependencyDesc"
                }
            }
        }
    }

    static boolean isResolvable(Configuration conf) {
        return conf.metaClass.respondsTo(conf, "isCanBeResolved") ? conf.isCanBeResolved() : true
    }
}

// Create a task using the task type
task testLicense(type: TestLicenseTask)

cromefire avatar Apr 13 '20 18:04 cromefire

I came across a fantastic solution here that perfectly addresses the issue. To summarize, the necessary modification was to replace dependencyConfiguration with the appropriate variant, which, in this case, is debug. Additionally, it was crucial to append the suffix RuntimeClasspath to the string, resulting in debugRuntimeClasspath. I hope this information proves to be helpful.

Here's the updated code snippet:

downloadLicenses {
    includeProjectDependencies = true
    dependencyConfiguration = "debugRuntimeClasspath"
    // or
    // dependencyConfiguration = 'compileClasspath'
} 

dzuluaga avatar Jul 14 '23 19:07 dzuluaga