# Custom java plugin : duplicate language

**URL:** <https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122>\
**Category:** Plugin Development\
**Tags:** custom\_plugin\
**Created:** [June 24, 2019, 9:11pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122 "2019-06-24T21:11:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![qualitesys](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/qualitesys/32/12317_2.png) [@qualitesys](https://community.sonarsource.com/u/qualitesys)\
**Post date:** [June 24, 2019, 9:11pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122/1 "2019-06-24T21:11:58Z")

</div>

Hello  
I write several custon plugins on the same java code template for multiple languages.  
The plugins related to new languages (Powerbuilder, Aspx, etc) are working fine.  
As soon as I load the java or the php custom plugin, I get the following error “java.lang.IllegalArgumentException: Multiple entries with same key: php=PHP and php=Php”

Is it possible to add custom plugins to already existing languages in the SonarQube server, and how ?

Thanks for your help

PS: tested for SQV7.6, it worked well to SonarV4.2

---

<div class="post-metadata">

**Author:** ![felipebz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/felipebz/32/32739_2.png) [@felipebz](https://community.sonarsource.com/u/felipebz)\
**Post date:** [June 24, 2019, 11:03pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122/2 "2019-06-24T23:03:39Z")

</div>

Hi.

Please check what is the pluginKey of your custom plugin (in the pom.xml) and the name of your custom reposity. It should be different than “php”. See the example:

- `pluginKey` is “php-custom”:

> <https://github.com/SonarSource/sonar-custom-rules-examples/blob/72af24771d391b04520304feeb7d9c4b37a47dba/php-custom-rules/pom.xml#L46-L57>

- the `repositoryKey` is “custom”:

> <https://github.com/SonarSource/sonar-custom-rules-examples/blob/master/php-custom-rules/src/main/java/org/sonar/samples/php/MyPhpRules.java#L40-L48>

---

<div class="post-metadata">

**Author:** ![qualitesys](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/qualitesys/32/12317_2.png) [@qualitesys](https://community.sonarsource.com/u/qualitesys)\
**Post date:** [June 25, 2019, 8:37pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122/3 "2019-06-25T20:37:38Z")

</div>

Thanks Felipe

It appears that my pluginKey is qcr4php for example, so no problem with this.  
Unfortunately, the problem seams related to the fact that two plugins must not define the same language (php or java, etc) see [1]  
I don’t really understand this. Since in the QualityProfile view one can choose the default profile, it should be possible to create 2 plugins for those languages, then select the default one.

Can SonarSource confirm that a custom plugin cannot provide analysers for languages SonarSource delivers, and since which SQ versions ?  
By the way, it was not the case in old versions (4.2 for example)

Thanks for your help

[1] : [https://stackoverflow.com/questions/35310698/sonarqube-background-tasks-failing-with-multiple-entries-with-same-key](https://stackoverflow.com/questions/35310698/sonarqube-background-tasks-failing-with-multiple-entries-with-same-key)

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 25, 2019, 8:48pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122/4 "2019-06-25T20:48:18Z")

</div>

Greetings,

Only one plugin can _declare_ a language. The implicit convention is to declare a language only if the plugin handle all “language related” features, like highlighting, core measures, cpd, …

Multiple plugins can contribute rules for a language. A plugin does not have to declare a language to contribute rules for a language.

Does that help?

Best regards,

Colin

---

<div class="post-metadata">

**Author:** ![qualitesys](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/qualitesys/32/12317_2.png) [@qualitesys](https://community.sonarsource.com/u/qualitesys)\
**Post date:** [June 25, 2019, 9:15pm UTC](https://community.sonarsource.com/t/custom-java-plugin-duplicate-language/11122/5 "2019-06-25T21:15:55Z")

</div>

Thanks Colin for your quick answer !

Well my purpose is to handle the full set of feature for those languages according to a custom syntax analyser and custom metrics and fonctional rules too. Well, I’ll create special language names, a bit sad though.  
Didier
