Stefano Zanella
08/22/2024, 8:17 AMproject.getPlugins().apply() within the plugin's apply method. At the same time, if I apply this custom plugin to more than a project I'm starting to get weird errors that seem to be related to having the plugin applied twice. What would be the most idiomatic approach here? Check if the plugin is already present before applying it or anything else?Vampire
08/22/2024, 8:30 AMproject.apply() (read the JavaDoc of getPlugins(), applying a plugin multiple times is the idiomatic way, because the 2nd and further attempts to apply the same plugin are no-ops. So whatever unspecified "weird errors" you have, it is quite unlikely that they are related to the pure multi-application.Vampire
08/22/2024, 8:31 AMproject.pluginManager.withPlugin, if your plugin requires that other plugin to be applied too, apply it.Stefano Zanella
08/22/2024, 8:31 AMStefano Zanella
08/22/2024, 8:39 AM`java-library`
id("my.custom.plugin")
alias(libs.plugins.protobuf)
alias(libs.plugins.python) // also applied in the custom plugin
I get this error
Cannot set the value of task ':grpc:stub:python:checkPython' property 'envService' of type ru.vyarus.gradle.plugin.python.service.EnvService using a provider of type ru.vyarus.gradle.plugin.python.service.EnvService.
Which already doesn't make much sense to me as an error. But even more puzzling, if I remove the protobuf plugin then everything works again 🤔Stefano Zanella
08/22/2024, 8:43 AMVampire
08/22/2024, 8:54 AMalias(libs.plugins.python) apply false to the root project and the issue will be gone.Stefano Zanella
08/22/2024, 8:55 AMVampire
08/22/2024, 8:57 AMbuildSrc dependency, ...Stefano Zanella
08/22/2024, 8:59 AMVampire
08/22/2024, 9:10 AMoh ok yeah that's not very intuitive but it definitely makes sense from a technical standpointhttps://github.com/gradle/gradle/issues/30274 :-)
I still don't know why the issue with enabling/disabling the protobuf plugin thoMaybe a red herring. Maybe the protobuf plugin breaks task configuration avoidance and it would have failed later anyway if you executed the "right" task. Maybe not, hard to say without stacktrace and analyzing what happens exactly why.
Stefano Zanella
08/22/2024, 9:11 AMStefano Zanella
08/22/2024, 12:14 PMimport org.gradle.api.Plugin;
import org.gradle.api.Project;
public class MyPlugin implements Plugin<Project> {
public void apply(Project project) {
project.getPlugins().apply(MyBasePlugin.class);
// define conventions
}
}
Maybe something to update with a more suitable call chain?Vampire
08/22/2024, 12:26 PMVampire
08/23/2024, 2:58 PMStefano Zanella
08/23/2024, 3:04 PMVampire
08/23/2024, 3:07 PMStefano Zanella
08/23/2024, 3:10 PM