cashapp / licensee

Gradle plugin which validates the licenses of your dependency graph match what you expect
https://cashapp.github.io/licensee/docs/1.x/
Apache License 2.0
626 stars 29 forks source link

Support for Gradle configuration caching #72

Closed jrodbx closed 1 year ago

jrodbx commented 2 years ago
Screen Shot 2021-12-08 at 9 18 40 PM

Looks like the recursive traversal of loadPomInfo is the root cause:

https://github.com/cashapp/licensee/blob/trunk/src/main/kotlin/app/cash/licensee/task.kt#L136

https://github.com/cashapp/licensee/blob/trunk/src/main/kotlin/app/cash/licensee/dependencyGraph.kt#L247

warting commented 2 years ago

+1 Would love to have this fixed.

JakeWharton commented 2 years ago

Pull requests are always welcomed!

hfhbd commented 2 years ago

I did try it, but I failed. First try was to get rid of the project property during TaskAction and use injection to get the properties.

internal open class LicenseeTask @Inject constructor(
  private val objects: ObjectFactory,
  private val dependencies: DependencyFactory,
  private val configurations: ConfigurationContainer,
): DefaultTask() {

With the current implementation we need to use a ConfigurationContainer to call detachedConfiguration to add a dependency to the pom file. But this container is not compatible with the configuration cache:

⌄ task:licensee📋 of type app.cash.licensee.LicenseeTask📋
⌄ fieldconfigurations📋 of app.cash.licensee.LicenseeTask📋
■⚠️cannot serialize object of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer📋, a subtype of org.gradle.api.artifacts.ConfigurationContainer📋, as these are not supported with the configuration cache.

And according to the docs, these types won't be supported: https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

These types fall into some categories as follows:
- Dependency management types

In all cases the reason these types are disallowed is that their state cannot easily be stored or recreated by the configuration cache.
rohilchodankar commented 1 year ago

We are seeing typeapp.cash.licensee.LicenseeTask: invocation of 'Task.project' at execution time is unsupported. error with Gradle 8.1, seems to work with Gradle 8.0.2. Anyone else seeing the issue?

hfhbd commented 1 year ago

While I think, this is an upstream issue, I fixed this in #189.

Just curious, how do you use licensee? KGP does not support 8.1 yet.