【问题标题】:How to configure Sonar and Maven multilevel modules?如何配置 Sonar 和 Maven 多级模块?
【发布时间】:2015-10-06 02:37:09
【问题描述】:

我在为声纳分析配置多级 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:仅分析父模块。

有人知道如何处理它吗? (我的意思是不修改层次文件夹,这对其他一些需求真的很有帮助)

提前致谢

【问题讨论】:

    标签: sonarqube


    【解决方案1】:

    我找到了一个解决方法: - 我在父项目上启动 mvn clean install - 然后我在 'level 2' 模块启动 sonar:sonar,我可以这样做,因为要分析的所有代码源都在同一个模块下。

    至少它正在处理my sample project,但目前我还没有处理让它在我的实际项目中运行。

    【讨论】:

      【解决方案2】:

      构建我的 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>
      

      我只构建父项目,这会导致 SonarQube 分析父项目及其所有子项目。我正在使用:

      mvn clean install sonar:sonar
      

      mvn sonar:sonar
      

      【讨论】:

        【解决方案3】:

        我认为您在 SonarQube 中有一个模块作为项目。首先,您需要删除它,然后执行新的分析。

        当项目已经存在但处于不同级别(项目、模块等)时会发生这种情况

        【讨论】:

        • 嗨,已经尝试过了,删除 Sonar 上的项目没有帮助。还是谢谢
        • 你能验证密钥不存在吗?
        【解决方案4】:

        此行为与此 JIRA 相关:http://jira.codehaus.org/browse/SONAR-4245

        唯一的解决方案是使用旧版本的声纳..

        【讨论】:

          猜你喜欢
          • 2015-12-30
          • 2016-04-16
          • 2012-10-13
          • 1970-01-01
          • 2013-03-16
          • 2017-12-26
          • 1970-01-01
          • 2017-09-24
          • 2017-09-21
          相关资源
          最近更新 更多