Optional dependency on bazel plugin

Answered

Hi, I am developing a plugin that builds the project for user in case a feature is invoked. For gradle/maven, I am using ProjectTaskManager to get a module build task, and then I run it like this

ProjectTaskManager.getInstance(project).run(task).onSuccess

Now, my code is doing nothing in case there's a bazel project. So, I wanted to add a dependency on bazel for intelliJ plugin - https://plugins.jetbrains.com/plugin/8609-bazel-for-intellij on my plugin.

But this dependency is optional, as there's no need for it in case its a gradle/maven project. 

So, in my build.gradle I have added this

intellij {
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(listOf("com.google.idea.bazel.ijwb:2023.05.02.0.1-api-version-223") + properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
}

And in my plugin.xml, I have added this - 

<depends optional="true" config-file="">com.google.idea.bazel.ijwb</depends>

Since, I am not implementing any extension points, I wasn't sure what to put in the config-file, so I just put empty string, and it passed, but I am not really sure what it does.

And after building, I am able to import classes from the bazel plugin into my code. 

Basically I am doing these 2 calls from my plugin in case its a bazel project

BlazeSyncManager.getInstance(project)
.incrementalProjectSync( /* reason= */"IncrementalSyncProjectAction")
BlazeBuildService.getInstance(project).buildProject();

After this when I run buildPlugin for my plugin, it passes. But when I execute the flow that is responsible for the calls above, it throws NoClassDefFoundError. 

Any suggestions on how to achieve this functionality?

0
2 comments

Hi,

What is the exact NoClassDefFoundError? What is the stacktrace?

0

The NoClassDefFoundError is for these class

BlazeSyncManager
BlazeBuildService

I got it resolved by just creating an empty optionalConfig file and pointing the config-file parameter to that.

0

Please sign in to leave a comment.