The right approach to work with Optional Plugin Dependencies

已回答

Hello,

 

I want to use optional plugin dependencies in the plugin. So far it's done like this

 

In plugin.xml

<depends optional="true" config-file="my-plugin-maven.xml">org.jetbrains.idea.maven</depends>

 

In my-plugin-maven.xml 

<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<projectService serviceImplementation="com.services.MavenService"/>
</extensions>
</idea-plugin>

 

In my code something like

class MyPluginStartupActivity : StartupActivity {

override fun runActivity(project: Project) {
val service: MavenService? = project.service()
service?.execute()
}
}

 

Is this the correct approach or is it better somehow differently?

 

Thank you!

 

Best regards,

Alex

 

0

Alexand, yes - your solution is fine and straightforward.

0

Thank you, Jakub! I will continue in this direction.

0

请先登录再写评论。