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

License report task creation fails for androidTest + variant

Open fejd opened this issue 3 years ago • 2 comments

I wanted to try out the useVariantSpecificAssetDirs flag (set to true) together with the ignoredPatterns feature so I updated to 0.9.1-SNAPSHOT. I ran into an issue when building though:

What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:licenseVariant1ReleaseAndroidTestReport'.
   > AndroidSourceSet with name 'variant1ReleaseAndroidTest' not found.

In the app module's build.gradle I do:

project.afterEvaluate {
    tasks.forEach({  <--- Triggers the exception
       // Do stuff
    })
}

Partial stacktrace:

Caused by: org.gradle.api.UnknownDomainObjectException: AndroidSourceSet with name 'variant1ReleaseAndroidTest' not found.
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.createNotFoundException(DefaultNamedDomainObjectCollection.java:504)
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333)
	at com.jaredsburrows.license.ProjectAndroidKt.configureVariant$lambda-7$lambda-6(projectAndroid.kt:99)

I have three androidTest source sets:

androidTest androidTestVariant1 androidTestVariant2

No debug/release specific source sets though. So far I've, unsuccessfully, tried to disable the creation of the androidTest related license tasks.

fejd avatar Aug 15 '22 15:08 fejd

Do you have an example repo or the actual build.gradle* file?

jaredsburrows avatar Sep 15 '22 20:09 jaredsburrows

Sorry for the late response, here's an example project:

LicenseReportAssetVariant.zip

fejd avatar Oct 11 '22 08:10 fejd

When removing, project.afterEvaluate the error goes away. I am not sure if this is directly related to the license plugin.

jaredsburrows avatar Jan 29 '24 23:01 jaredsburrows

Feel free to comment or update this. Closing for now.

jaredsburrows avatar Jan 30 '24 01:01 jaredsburrows