How to avoid a file extension is binded to multiple Language

For example:
Official plugin SonarXML supports *.xml file

12:46:15.635 DEBUG: ‘AndroidManifest.xml’ indexed with language ‘xml’

There are another plugin(named MyAndroid) also support *.xml file.
If MyAndroid and SonarXML are installed, error occurs:

12:47:54.421 ERROR: Language of file ‘AndroidManifest.xml’ can not be decided as the file matches patterns of both sonar.lang.patterns.xml : /*.xml,/.xsd,**/.xsl and sonar.lang.patterns.android : **/*.xml

Because MyAndroid doesn’t know whether SonarXML is installed.
If MyAndroid doesn’t bind **/*.xml file, and SonarXML isn’t install ether,

12:46:15.631 DEBUG: ‘AndroidManifest.xml’ indexed with language ‘null’

File AndroidManifest.xml isn’t uploaded to sonarqube server if there aren’t issues in the file.

you could say that administrator can change sonar.lang.patterns.xml and sonar.lang.patterns.android in sonarqube server.
But he isn’t customer, so he doesn’t know there is conflict.

How to bind file extensions dynamically during plugin runtime to avoid conflict: MyAndroid binds *.xml files if SonarXML isn’t installed

Hi @Lu_Taoxxx

The implicit convention is to declare a language only if the plugin handle all “language related” features, like highlighting, core measures, cpd, …
Here I think this is truly the SonarXML plugin that should handle .xml files and declare the xml language.

It doesn’t prevent other plugin to report issues on any indexed file (even when there is no associated language). MyAndroid should not declare *.xml files as part of the Android language (which is wrong BTW) but can still report issues on AndroidManifest.xml.

1 Like

Yes, but the files indexed with language ‘null’ aren’t uploaded to Sonarqube Server if there aren’t issues in files.
For example: plugin sensor compares two localized files: zh.xml and en.xml which are indexed with language ‘null’, and reports an issue: “there is a key only existed in zh.xml”, then zh.xml is uploaded to Sonarqube Server but en.xml isn’t uploaded because there isn’t issue in en.xml.

Is there a solution to force upload a specific file indexed with language ‘null’?

Yes, look at SensorContext::markForPublishing