开发者

Sonar C# plugin not working?

开发者 https://www.devze.com 2023-03-20 06:32 出处:网络
Our company was glad to see the release of the C# plugins for sonar, and jumped on the first release. However, we seem to be running into an execption reported by the ProjectLinkSensor. Here\'s what w

Our company was glad to see the release of the C# plugins for sonar, and jumped on the first release. However, we seem to be running into an execption reported by the ProjectLinkSensor. Here's what we did:

On a Windows XP machine, we installed the following:

  • Windows 7 Development kit (to get to FxCop)
  • Fxcop 10.0
  • Gallio
  • Sonar 2.9 RC1 (running the Derby database)
  • Maven 2.2.1

Then we checked out the solution, and placed the following pom.xml in the directory where the sln file is:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.rolfje</groupId>
  <artifactId>SomeSilverlightProject</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>SomeSilverlightProject</name>

  <properties>
    <sonar.language>cs</sonar.language>
  </properties>

  <build>
    <sourceDirectory>${basedir}</sourceDirectory>
  </build>
</project>

In the home directory of the user that's running the maven build we've placed the foll开发者_StackOverflow社区owing settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
   <profile>
      <id>dotnet</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>

      <sonar.gallio.mode>skip</sonar.gallio.mode>
      <sonar.gallio.installDirectory>C:/Program Files/Gallio</sonar.gallio.installDirectory>

      <sonar.fxcop.mode>skip</sonar.fxcop.mode>
      <sonar.fxcop.installDirectory>D:/Program Files/Microsoft Fxcop 10.0</sonar.fxcop.installDirectory>

      <sonar.partcover.mode>skip</sonar.partcover.mode>
      <sonar.partcover.installDirectory>C:/Program Files/PartCover/PartCover .NET 4.0</sonar.partcover.installDirectory>

      <sonar.gendarme.mode>skip</sonar.gendarme.mode>
      <sonar.gendarme.installDirectory>C:/Program Files/gendarme-2.6-bin</sonar.gendarme.installDirectory>

      <sonar.gendarme.mode>skip</sonar.gendarme.mode>
      <sonar.stylecop.installDirectory>C:/Program Files/Microsoft StyleCop 4.3.2.1</sonar.stylecop.installDirectory>

      <sonar.jdbc.url>jdbc:derby://localhost:1527/sonar</sonar.jdbc.url>
      <sonar.jdbc.driver>org.apache.derby.jdbc.ClientDriver</sonar.jdbc.driver>
      <sonar.jdbc.username>sonar</sonar.jdbc.username>
      <sonar.jdbc.password>sonar</sonar.jdbc.password>
      <sonar.host.url>http://localhost:9000</sonar.host.url>

      </properties>
   </profile>
  </profiles>
</settings>

Please note that I put "skip" in front of all modules. I did this one by one, hoping that switching off one of these modules would remove the error and I would be able to give you a clearer bug report. However this did not help.

When I go into the project directory (where the sln file is) and I run the following command: mvn -e clean sonar:sonar

I see that the maven sonar plugin does analysis, fetches settings from the local sonar instance, and generates the expected output files (target/sonar/stylecop-msbuild.xml for instance). However, these reports do not get uploaded to sonar, and I see the following error being reported by maven:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: org.sonar.plugins.core.sensors.ProjectLinksSensor has unsatisfied dependency: class org.apache.maven.project.MavenProject among unsatisfiable dependencies: [[class org.apache.maven.project.MavenProject]] where org.sonar.batch.bootstrap.ProjectModule@2c507f:135<I<org.sonar.batch.bootstrap.BatchModule@659812:139<I<org.picocontainer.DefaultPicoContainer@eb1882:44<| was the leaf container being asked for dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)

Aside from the rather unhelpful error (ProjectModule@2c507f doesn't really tell me much), this looks like a nasty bug, which is causing the sonar upload (at least for me) to not work.

Did anybody else have this issue? What is causing this and why is the error reporting so terrible in this case?

Please note taht I've also reported this as a bug on Jira, because I really think the Sonar/C-Sharp plugin ecosystem is leaving me in the dark here. However, it was put into the "Wont't fix" state without additional information. The Jira bug is here: https://jira.codehaus.org/browse/SONARPLUGINS-1264


I don't know if this will solve your problem, but I noticed that you refer to the C drive in all of your <sonar.*.installDirectory> tags, except for <sonar.fxcop.installDirectory>.

Oh, and you could also try to disable the stylecop module since you've accidentally copy-pasted <sonar.gendarme.mode>skip</sonar.gendarme.mode> in front of that module...


I am one of the main developers of sonar for c#. I did not seen your jira ticket before. I actually agree with Fabrice, you should have send a mail to the user mailing-list.

About your issue, my first guess is that there is an error with your pom.xml file. If you use "mvn -e clean sonar:sonar", you need to declare in the pom.xml file the "maven-dotnet-plugin" plugin. The "clean" part will be performed by this plugin. Also, the correct command line would rather be "mvn clean package sonar:sonar", there will not be any assembly to analyse.

For more information on the maven-dotnet-plugin you can check out the documentation on : http://maven-dotnet-plugin.appspot.com

You will find a pom example here : http://maven-dotnet-plugin.appspot.com/configuration.html

Hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消