Intellij 2020: java.lang.AssertionError: ID with name <name> requested for <plugin name> plugin but registered with another plugin <plugin name>

已回答

I have developed a custom Intellij plugin which depends on another open source plugin already installed in Intellij. My plugin reuses 2 classes/services in runtime initialized for the open source plugin.

It worked correctly in Intellij 2019 and below.

However, in Intellij 2020+, I'm getting the following error:

com.intellij.diagnostic.PluginException: Cannot create class org.zalando.intellij.swagger.index.swagger.SwaggerFileIndex [Plugin: org.zalando.intellij.swagger]

Caused by: java.lang.AssertionError: ID with name 'SwaggerFileIndex' requested for plugin org.zalando.intellij.swagger but registered for custom plugin

Is this a new Assertion rule specified for Intellij 2020, that plugins can't reuse objects initialized for other plugins?

Is there a solution/workaround for this?

Thanks

评论操作 固定链接

Could you please post a snippet of your code accessing "SwaggerFileIndex"?

1
评论操作 固定链接

My plugin depends on the opensource plugin: org.zalando.swagger. 

My plugin.xml contains:

<depends>org.zalando.intellij.swagger</depends>

I have a class which uses the swaggerIndexService of the opensource plugin: org.zalando.swagger.

My code->

final SwaggerFileType fileType = swaggerIndexService.getFileType(parameters).orElse(null);

 

Github link for org.zalando.intellij.swagger.index.swagger.SwaggerIndexService:

https://github.com/zalando/intellij-swagger/blob/master/src/main/java/org/zalando/intellij/swagger/index/swagger/SwaggerIndexService.java

 

SwaggerIndexService uses the SwaggerFileIndex.

Github link for org.zalando.intellij.swagger.index.swagger.SwaggerFileIndex: https://github.com/zalando/intellij-swagger/blob/master/src/main/java/org/zalando/intellij/swagger/index/swagger/SwaggerFileIndex.java

 

Please let me know if you need any other information.

Thanks

0
评论操作 固定链接

Thanks for the information. Could you please post your relevant part of Gradle setup that defines dependency on Swagger plugin? Please double-check the version of Swagger plugin you're compiling against is the same at IDE runtime and it is not accidentally packaged within your plugin distribution.

0
评论操作 固定链接

Hi Yann,

In build.gradle:

dependencies {
compile('org.zalando.intellij:intellij-swagger:1.0.28'){
...

The Swagger version is correct, 1.0.28

 

Thanks

0
评论操作 固定链接

Alright, that is most likely the problem.

Dependencies on other plugins must be defined inside "intellij"-block, not as regular Gradle dependency.

Please see https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#gradle for more details.

0
评论操作 固定链接

The dependancy plugin intellij-swagger plugin resides in at

<custom maven repo>.com.xxx.xxx.intellij-swagger

I followed https://github.com/JetBrains/gradle-intellij-plugin#configuration

intellij {
type 'IC'
plugins 'yaml','com.xxx.xxx.intellij-swagger:1.0.28'
pluginName '<custom plugin>'
updateSinceUntilBuild false
version '2017.3.2'
intellijRepo '<custom repo>'
pluginsRepo '<custom repo url>'
}

When I specify the custom maven repo url directly, it looks for the plugin at 

<custom repo url>/com/jetbrains/plugins/intellij-swagger-1.0.28

However I dont want "com/jetbrains/plugins" to get looked at instead as I want to search at <custom repo url>/com/xxx/xxx/swagger-intellij

I tried following configs to no avail

pluginRepo { maven(custom maven url) }

pluginRepo { custom(custom XML url) }

How do I configure a customized maven repo url and com.xxx.xxx.intellij-swagger correctly?

0
评论操作 固定链接

Hi Yann,

Thanks for your response. I went through the link, however it doesn't help me.

I have already configured

respositories { 

   maven { url <custom url>

}

 

You mentioned I need to include this dependency plugin in the intellij{ plugins } section instead of the dependencies section to resolve the issue I was facing at the beginning at this thread.

I want to include the dependency plugin "intellij-swagger" in the intellij { plugins } section to be picked up from a custom repo with a custom groupID (com.xxx.xxx) NOT com.jetbrains.plugins 

How can I do the same?

Thanks.

0
评论操作 固定链接

Custom repository refers to Custom Repository for plugins https://plugins.jetbrains.com/docs/intellij/update-plugins-format.html, not Maven repository. Why can't you use regular plugin hosted on Marketplace https://plugins.jetbrains.com/plugin/11115-swagger-zalando-extensions-as dependency directly?

0
评论操作 固定链接

Yes, at the place where I work, we have a Custom repository for plugins. We can not directly access the plugin on the jetbrains marketplace.

0
评论操作 固定链接

Can I include the dependency plugin "intellij-swagger" in the intellij { plugins } section to be picked up from a custom repo with a custom groupID (com.xxx.xxx) NOT com.jetbrains.plugins 

0
评论操作 固定链接

The ID specified for custom plugin repository is the same as the plugin's ID. This has nothing to do with Maven coordinates.

0
评论操作 固定链接

Sorry.

This is my configuration.

intellij {
type 'IC'
plugins 'yaml','intellij-swagger:1.0.28'
pluginName '<custom plugin>'
updateSinceUntilBuild false
version '2017.3.2'
intellijRepo '<custom repo>'
pluginsRepo '<custom plugin repo>'
}

When I run the build, I get the following error-

Could not find com.jetbrains.plugins:intellij-swagger:1.0.28
Searched in the following locations:
- <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.jar
- <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.pom

But the intellij swagger is available at <custom plugin repo>/intellij-swagger/intellij-swagger-1.0.28.jar NOT <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.jar

How do I change it accordingly?

0
评论操作 固定链接

Hi Yann Cebron. Could you please help me out^

0
评论操作 固定链接

Sorry for delay.

 

Could you please try with "custom" inside pluginsRepo property?

intellij {
type 'IC'
plugins 'yaml','intellij-swagger:1.0.28'
pluginName '<custom plugin>'
updateSinceUntilBuild false
version '2017.3.2'
intellijRepo '<custom repo>'
pluginsRepo {
custom("path-to-plugin.xml")
}
}
0
评论操作 固定链接

No, using the custom tag with path to plugin.xml did not work as I had mentioned a couple of comments earlier.

Anyways, we are trying to remove the dependency on the Swagger plugin. So I won't be following up on this issue further.

Thank you for your help, closing this thread.

0

请先登录再写评论。