Inconsistency with sonar.langage property / Allow the override to multi-language

464 views
Skip to first unread message

philipp...@gmail.com

unread,
Dec 17, 2015, 5:28:21 PM12/17/15
to SonarQube
The problem

Sonar language property as defined in the doc (http://docs.sonarqube.org/display/SONAR/Analysis+Parameters#AnalysisParameters-ProjectConfiguration.1) allow to "set the language of the source code to analyze". "If not set, a multi-language analysis will be triggered."

1. Case #1 setting language
<properties>
<sonar.language>java</sonar.language>
</properties>

2. Case #2 Setting no language (multi-language)
<properties>
</properties>

3. Case #2 Setting empty language (expect multi-language)
<properties>
<sonar.language></sonar.language>
</properties>

However the last case does not work as expected. Most plugins will run but the "language verifier" will make the maven build/sonar analysis failed.
Why specify use an empty string ? Basically to override a configuration that is inherits in maven.

How to reproduce

To reproduce the problem run any Sonar build (mvn sonar:sonar) on any project with the 3rd configuration above.

Maven stack trace
<<<
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project vulnerable-jsp-app: You must install a plugin that supports the language '' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project vulnerable-jsp-app: You must install a plugin that supports the language ''
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)

        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: You must install a plugin that supports the language ''
        at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstrapper.execute(RunnerBootstrapper.java:104)
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:135)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: You must install a plugin that supports the language ''
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
>>>


Source of the problem

The plugin selected to run are actually as expected because StringUtils.defaultIfBlank is used.

I think that the bug is located in the LanguageVerifier class where the property if read without the check for null or empty string.


Let me know if more detail are require..

Julien HENRY

unread,
Dec 18, 2015, 4:45:18 AM12/18/15
to SonarQube, philipp...@gmail.com
Hi Philippe,

Thanks for the detailed report. Ticket created:

++

Julien

Philippe Arteau

unread,
Dec 18, 2015, 12:22:46 PM12/18/15
to Julien HENRY, SonarQube
Thanks for the update
Reply all
Reply to author
Forward
0 new messages