autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.82k stars 120 forks source link

Add support for project isolation #1317

Open NikolayMetchev opened 2 days ago

NikolayMetchev commented 2 days ago

Is your feature request related to a problem? Please describe. I would like to use project isolation in our build and use the dependency analysis gradle plugin Project isolation is described here: https://docs.gradle.org/current/userguide/isolated_projects.html

Describe the solution you'd like Make the necessary changes to make this plugin compliant.

Describe alternatives you've considered None available

Additional context Here is the first problem encountered when I tried to use project isolation:

- [error] Project `:buildSrc` cannot access `Project.plugins` functionality on another project `:`
    - plugin 'com.autonomousapps.dependency-analysis'
        - Exception at `com.autonomousapps.services.InMemoryCache$Companion.serviceHoldingBuild(InMemoryCache.kt:76)`
org.gradle.api.InvalidUserCodeException: Project ':buildSrc' cannot access 'Project.plugins' functionality on another project ':'
    at org.gradle.internal.cc.impl.ProblemReportingCrossProjectModelAccess$ProblemReportingProject_Decorated.getPlugins(Unknown Source)
    at com.autonomousapps.services.InMemoryCache$Companion.serviceHoldingBuild(InMemoryCache.kt:76)
    at com.autonomousapps.services.InMemoryCache$Companion.register$dependency_analysis_gradle_plugin(InMemoryCache.kt:90)
    at com.autonomousapps.internal.analyzer.JvmAnalyzer$registerFindDeclaredProcsTask$1.invoke(JvmProjectAnalyzer.kt:72)
    at com.autonomousapps.internal.analyzer.JvmAnalyzer$registerFindDeclaredProcsTask$1.invoke(JvmProjectAnalyzer.kt:71)
    at com.autonomousapps.internal.analyzer.JvmAnalyzer$inlined$sam$i$org_gradle_api_Action$0.execute(TaskContainerExtensions.kt)
    at java.base/java.lang.Iterable.forEach(Iterable.java:74)
    at com.intellij.gradle.toolingExtension.impl.model.warmUp.GradleTaskWarmUpService.lambda$buildAll$2(GradleTaskWarmUpService.java:34)
    at com.intellij.gradle.toolingExtension.impl.util.GradleResultUtil.lambda$runOrRetryOnce$0(GradleResultUtil.java:34)
    at com.intellij.gradle.toolingExtension.impl.util.GradleResultUtil.runOrRetryOnce(GradleResultUtil.java:16)
    at com.intellij.gradle.toolingExtension.impl.util.GradleResultUtil.runOrRetryOnce(GradleResultUtil.java:33)
    at com.intellij.gradle.toolingExtension.impl.model.warmUp.GradleTaskWarmUpService.buildAll(GradleTaskWarmUpService.java:33)
    at com.intellij.gradle.toolingExtension.impl.modelBuilder.ExtraModelBuilder.buildServiceModel(ExtraModelBuilder.java:87)
    at com.intellij.gradle.toolingExtension.impl.modelBuilder.ExtraModelBuilder.buildAll(ExtraModelBuilder.java:67)
    at com.intellij.gradle.toolingExtension.impl.modelBuilder.ExtraModelBuilder.buildAll(ExtraModelBuilder.java:47)
autonomousapps commented 15 hours ago

This plugin does already support Isolated Projects (Gradle itself has confirmed this, as they use the plugin in their own builds). Do you have a minimal reproducer?

NikolayMetchev commented 2 hours ago

Ok. this bug is really strange. It only reproduces in Idea. If you run gradle on its own everything is fine. I have attached a project that when you open in Idea should fail. deps-bug.zip