microsoft / build-server-for-gradle

An implementation of the Build Server Protocol for Gradle
MIT License
49 stars 8 forks source link

A problem occurred evaluating project ':buildSrc'. > Could not find method implementation() for arguments #193

Open jdneo opened 1 week ago

jdneo commented 1 week ago

A problem occurred evaluating project ':buildSrc'.

Could not find method implementation() for arguments [org.ow2.asm:asm:9.7] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Steps to repro

  1. Open the project https://github.com/MinecraftForge/MinecraftForge
  2. The error is thrown here: https://github.com/microsoft/build-server-for-gradle/blob/395b97757da8d0d82bc2c68c4aca4331bea4e584/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java#L125
Arthurm1 commented 1 week ago

Maybe I should remove getEditableBuilds and just use getIncludedBuilds here... https://github.com/microsoft/build-server-for-gradle/blob/395b97757da8d0d82bc2c68c4aca4331bea4e584/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java#L66

Gradle must do something funny with the buildSrc project as the buildSrc/build.gradle file is not valid on its own. It would need something like plugins { id 'groovy' } otherwise implementation() is invalid as it says in the error message.

jdneo commented 1 week ago

I got the similar answer from Gradle.

I'll check how it looks like in IDEA tomorrow

jdneo commented 1 week ago

I saw this: https://github.com/JetBrains/intellij-community/blob/66775ae4916b2ad4d6ce6b2a2db7456bd354e836/plugins/gradle/tooling-extension-impl/src/com/intellij/gradle/toolingExtension/impl/modelAction/GradleModelFetchAction.java#L217-L233

But this project is 8.7

Arthurm1 commented 1 week ago

I'll have a look into it next week. If you need to fix it quickly then changing to getIncludedBuilds will exclude buildSrc.

Arthurm1 commented 6 days ago

It's complex to follow but I think Intellij using this as their init.gradle.

So Groovy (and sometimes java) plugins are applied which means that the implementation/compile/api keywords are understood independently of the project.

jdneo commented 6 days ago

I've discussed this issue with Gradle as well, and find this: https://github.com/gradle/gradle/blob/master/platforms/extensibility/plugin-development/src/main/java/org/gradle/initialization/buildsrc/GroovyBuildSrcProjectConfigurationAction.java#L29

Maybe those plugins will be applied when running from command line but not the case when running from TAPI.

Need to debug to see if the assumption is correct.