hierynomus / license-gradle-plugin

Manage your license(s)
http://www.javadude.nl
Other
409 stars 114 forks source link

downloadLicenses fails in gradle 3.4.1 #134

Closed serba closed 7 years ago

serba commented 7 years ago

We recently upgraded our project to gradle 3.4.1 and downloadLicenses started failing with the following exception:

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'source' for object of type org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency.
    at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:88)
    at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
    at org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency_Decorated.getProperty(Unknown Source)
    at nl.javadude.gradle.plugins.license.LicenseResolver$_provideFileDependencies_closure8.doCall(LicenseResolver.groovy:164)
    at nl.javadude.gradle.plugins.license.LicenseResolver.provideFileDependencies(LicenseResolver.groovy:162)
    at nl.javadude.gradle.plugins.license.LicenseResolver$_provideLicenseMap4Dependencies_closure2.doCall(LicenseResolver.groovy:84)
    at nl.javadude.gradle.plugins.license.LicenseResolver.provideLicenseMap4Dependencies(LicenseResolver.groovy:48)
    at nl.javadude.gradle.plugins.license.LicenseResolver$provideLicenseMap4Dependencies.call(Unknown Source)
    at nl.javadude.gradle.plugins.license.DownloadLicenses$_downloadLicenses_closure1.doCall(DownloadLicenses.groovy:103)
    at nl.javadude.gradle.plugins.license.DownloadLicenses$_downloadLicenses_closure1.doCall(DownloadLicenses.groovy)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at nl.javadude.gradle.plugins.license.DownloadLicenses.downloadLicenses(DownloadLicenses.groovy:113)

I noticed that DefaultSelfResolvingDependency.java had getSource method in gradle 2.14 and it’s not there in gradle 3.4.1. It looks like that was changed in 3.3 (see https://github.com/gradle/gradle/commit/9e20cfed5d4ee5d516fa41b7198d17342f847559).

Should license-gradle-plugin call FileCollectionDependency.files or even FileCollectionDependency.resolve instead of FileCollectionDependency.source in LicenseResolver.groovy#L164 ?

yduman commented 7 years ago

same issue here

hierynomus commented 7 years ago

Thanks for reporting this. I will have a look at this asap

ejohansson commented 7 years ago

The proposed solution seems worked out for me. Created a pull request #135

hierynomus commented 7 years ago

Thanks @ejohansson! I've merged the PR, and will release a new version shortly (ie. this week)

imrimt commented 6 years ago

Running into this issue again when I have this line in my project

project.dependencies {
    compile files("path/to/resources")
}

I'm on Gradle 4.10.

robinson-calderon commented 4 years ago

@imrimt to solve the problem you just need to change the compile to implementation

implementation(files('./src/main/resources/myjar.jar'))