简体   繁体   English

使用Simple Java Runner的具有多个模块的Sonar C#项目

[英]Sonar C# project with multiple modules using the Simple Java Runner

I'm trying Sonar 3.2 with C# projects (the only plugins are C# Core and C# FX Cop) and using the Simple Java Runner. 我正在尝试将Sonar 3.2与C#项目一起使用(唯一的插件是C#Core和C#FX Cop),并使用Simple Java Runner。

It worked fine on a solution with a single project, but when I tried to analyse using a solution with 2 projects I always get the following error: 在具有单个项目的解决方案上运行良好,但是当我尝试使用具有2个项目的解决方案进行分析时,始终会遇到以下错误:

17:01:41.775 INFO  .s.b.b.ProjectModule - -------------  Analyzing Project1
    17:01:42.055 INFO  .s.b.ProfileProvider - Selected quality profile : [name=Custom C#,language=cs]
    17:01:42.075 INFO  nPluginsConfigurator - Configure maven plugins...
    17:01:42.125 INFO        org.sonar.INFO - Compare to previous analysis
    17:01:42.155 INFO        org.sonar.INFO - Compare over 5 days (2012-09-27)
    17:01:42.175 INFO        org.sonar.INFO - Compare over 30 days (2012-09-02)
    17:01:42.215 INFO  .b.p.SensorsExecutor - Initializer ProjectFileSystemLogger...
    17:01:42.215 INFO  jectFileSystemLogger - Source directories:
    17:01:42.215 INFO  jectFileSystemLogger -   $(Solution folder)\Project1
    17:01:42.215 INFO  .b.p.SensorsExecutor - Initializer ProjectFileSystemLogger done: 0 ms
    17:01:42.225 INFO  .b.p.SensorsExecutor - Initializer CSharpProjectInitializer...
    17:01:42.225 INFO  .b.p.SensorsExecutor - Initializer CSharpProjectInitializer done: 0 ms
    17:01:42.255 INFO   o.s.p.cpd.CpdSensor - Detection of duplicated code is not supported for C#.
    Total time: 8.442s
    Final Memory: 5M/118M
    Exception in thread "main" org.sonar.runner.RunnerException: java.lang.NullPointerException
        at org.sonar.runner.Runner.delegateExecution(Runner.java:288)
        at org.sonar.runner.Runner.execute(Runner.java:151)
        at org.sonar.runner.Main.execute(Main.java:84)
        at org.sonar.runner.Main.main(Main.java:56)
    Caused by: java.lang.NullPointerException
        at org.sonar.plugins.csharp.api.sensor.AbstractRegularCSharpSensor.assembliesFound(AbstractRegularCSharpSensor.java:101)
        at org.sonar.plugins.csharp.api.sensor.AbstractRegularCSharpSensor.shouldExecuteOnProject(AbstractRegularCSharpSensor.java:81)
        at org.sonar.plugins.csharp.api.sensor.AbstractRuleBasedCSharpSensor.shouldExecuteOnProject(AbstractRuleBasedCSharpSensor.java:48)
        at org.sonar.api.batch.BatchExtensionDictionnary.shouldKeep(BatchExtensionDictionnary.java:109)
        at org.sonar.api.batch.BatchExtensionDictionnary.getFilteredExtensions(BatchExtensionDictionnary.java:99)
        at org.sonar.api.batch.BatchExtensionDictionnary.select(BatchExtensionDictionnary.java:57)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:57)
        at org.sonar.batch.phases.Phases.execute(Phases.java:93)
        at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:139)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:131)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:126)
        at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:121)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.Batch.execute(Batch.java:104)
        at org.sonar.runner.internal.batch.Launcher.executeBatch(Launcher.java:69)
        at org.sonar.runner.internal.batch.Launcher.execute(Launcher.java:61)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonar.runner.Runner.delegateExecution(Runner.java:285)
    ... 3 more

The solution folder contains the following sonar-project.properties: 解决方案文件夹包含以下sonar-project.properties:

# Project identification
sonar.projectKey=com.project.btg
sonar.projectVersion=1.0
sonar.projectName=BTG

# Info required for Sonar
sonar.sources=.
sonar.language=cs

sonar.dotnet.visualstudio.solution.file=Sonar.project.sln
sonar.dotnet.buildPlatform=x86
sonar.dotnet.buildConfiguration=Debug

sonar.modules=Project1,Project2

#modules specific configuration
Project1:sonar.sources=.\Project1
Project1:sonar.projectName=Project 1

Project2:sonar.sources=.\Project2
Project2:sonar.sources=Project 2

The solution only has this 2 projects. 解决方案只有这2个项目。

I tried adding the modules configuration in a sonar-project.properties for each project with just: 我试着仅在每个项目的sonar-project.properties中添加模块配置:

# Project identification
sonar.projectName=Project 1

For the single project I used I had: 对于我使用的单个项目,我有:

# Project identification
sonar.projectKey=com.Project1
sonar.projectVersion=1.0
sonar.projectName=Project 1

# Info required for Sonar
sonar.sources=.
sonar.language=cs

I feel I'm missing something very simple, but I couldn't find much information on this. 我觉得我缺少一些非常简单的东西,但是我找不到关于此的很多信息。

If someone can help me with this I have an additional question: Can you analyse a hybrid solution of C++ and C# project? 如果有人可以帮助我,我还有一个问题:您可以分析C ++和C#项目的混合解决方案吗?

Thanks 谢谢

The support of multi-module is built-in for the C# plugins, you don't need to (and should not) specify: C#插件内置了对多模块的支持,您不需要(也不应该)指定:

sonar.modules=Project1,Project2

#modules specific configuration
Project1:sonar.sources=.\Project1
Project1:sonar.projectName=Project 1

Project2:sonar.sources=.\Project2
Project2:sonar.sources=Project 2

, nor add a "sonar-project.properties" inside each module. ,也不要在每个模块内添加“ sonar-project.properties”。

The C# Plugins rely on the SLN file to automatically discover the modules. C#插件依靠SLN文件来自动发现模块。 Take a look at our sample application , and just replace the Maven POM by a single "sonar-project.properties" file. 看一下我们的示例应用程序 ,仅用单个“ sonar-project.properties”文件替换Maven POM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM