2014-01-23 57 views
5

我遇到问题,为声纳分析配置多级Maven模块。如何配置Sonar和Maven多级模块?

它工作正常结构如下:

parent module 
    |- level 1 
     |- module with code to analyze 

但是,如果我添加的深度与代码分析模块,我不能配置它。

parent module 
    |- level 1 
     |- level 2 
      |- module with code to analyze 

我尝试了几种配置:

  1. 没有特殊配置: 我得到一个Can not execute SonarQube analysis: The project 'level 2' is already defined in SonarQube but not as a module of project 'level 1'. If you really want to stop directly analysing project 'level 2', please first delete it from SonarQube and then relaunch the analysis of project 'level 1'.错误。我不想在第1级启动,因为我的集成测试直接在父级模块中进行。
  2. 使用级别1和级别2上的skippedModules属性:仅分析父模块。
  3. 通过指定“带有要分析的代码的模块”来使用includedModules:只分析父模块。

有人对如何处理它有想法吗? (我的意思是不以修改层级文件夹这是非常有帮助的一些其他要求),通过预先

回答

0

感谢我认为你必须在SonarQube一个模块作为一个项目。首先,你需要删除它,然后执行新的分析。

这发生在一个项目已经存在,但在不同的级别(项目,模块等)

+0

嗨, 已经尝试过,取消对声纳的项目没有帮助。 无论如何感谢 –

+0

你可以验证密钥不存在吗? –

1

我找到了一个解决办法: - 我启动MVN在父项目 干净的安装 - 然后我启动声纳:声纳在'2级'模块中,我可以这样做,因为所有要分析的代码源都在同一模块下。

至少它在my sample project上工作,但目前我还没有处理它,使它在我的真实项目上工作。

1

建设我的Maven多模块项目一直为我工作。我正在使用SonarQube v4.3。

我在父Maven项目的根级别放置了一个sonar-project.properties文件。

这里的内容:

# Root project information 
sonar.projectKey=<I used the project pom's groupId + artifactId> 
sonar.projectName=<can be anything> 
sonar.projectVersion=<I used the project pom's version> 

# Some properties that will be inherited by the modules 
sonar.sources=src 

在我父项目的POM,我宣布这个属性:

<sonar.language>java</sonar.language> 

在同一POM,我宣布:

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>sonar-maven-plugin</artifactId> 
       <version>2.2</version> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

我只构建父项目,这会导致父项及其所有子项得到分析b y SonarQube。我使用的是:

mvn clean install sonar:sonar 

mvn sonar:sonar 
相关问题