Closed pranavvij closed 2 years ago
I'm getting the same error as well. When I run it in the command line via ./gradlew licenseDebugReport
it generates report with the correct dependencies. However, when I add it as task before preBuild
I get an empty report. Here is the configuration that generates an empty report:
afterEvaluate {
android.applicationVariants.all {
variant ->
def taskName ="license${variant.name.capitalize()}Report"
if (variant.respondsTo("getPreBuildProvider")) {
variant.preBuildProvider.configure { dependsOn(taskName) }
} else {
variant.preBuild.dependsOn(taskName)
}
}
}
@pranavvij I just tried your project. What is the error you are seeing?
git https://github.com/pranavvij/gradle-kotlin-plugin cd gradle-kotlin-plugin gradlew licenseDebugReport cat app/build/reports/licenses/licenseDebugReport.json
@jaredsburrows gradlew licenseDebugReport
works perfectly. There is no issue with that, but as soon as I make preBuild dependOn license
task. It gives an empty report. I think the main issue with that is probably the Androidx and jettifier
. Refer to the below build.gradle
which shows the illustration of the issue.
https://github.com/pranavvij/gradle-kotlin-plugin/blob/master/app/build.gradle#L42
Any more info on this? I am facing the same issue and depend on triggering the license task automatically in this way.
A workaround is to run the task manually via the command line, see https://github.com/jaredsburrows/gradle-license-plugin/issues/113#issuecomment-594366803.
You can setup yourself or run manually.
This works:
tasks.whenTaskAdded {
if (name == "assembleDebug") {
dependsOn("licenseDebugReport")
}
}
tasks.whenTaskAdded {
if (name == "assembleRelease") {
dependsOn("licenseReleaseReport")
}
}
After enabling Jetifier and Androidx into my project, the license report shows empty results. I tried printing the productFlavours in LicensePlugin, which gives an empty result. here is the POC which demos this behavior. Investigating too as to why this issue prevails.