一个包含多个配置文件和每个配置文件的声纳分析的主 pom 文件

one master pom file with multiple profiles and sonar analysis for each profile

我的项目总共有 50 个模块和 10 个配置文件。 5 个配置文件用于构建 5 个产品,5 个配置文件用于对相同的 5 个产品进行单元测试。

30 个通用模块和 4 个用于构建每个产品的配置文件的模块。 现在我必须了解如何将 SONAR 分析与每个产品的 Jenkins 作业集成。

我需要在声纳中看到 5 个条目,每个产品一个,但我只有一个 pom 文件。这能实现吗

请帮忙。下面的示例 pom 文件

<modules>
        <!-- Script related projects -->
        <!-- Common modules -->
        <module>./././bundles/com.abc.module1</module>
        <module>./././bundles/com.abc.module2</module>
            .
            .
        <module>./././bundles/com.abc.module30</module>
</modules>

<profiles>
        <profile>
            <id>product1</id>
            <modules>
                <module>./././bundles/com.abc.module31</module>
                <module>./././bundles/com.abc.module32</module>
            </modules>
        </profile>

        <profile>
            <id>product1-tests</id>
            <modules>
                <module>./././bundles/com.abc.testmodule1</module>
                <module>./././bundles/com.abc.testmodule2</module>
            </modules>
        </profile>
        .
        .
        .

</profiles>

如果您现在没有,我会创建一个包含所有源模块的配置文件,并有一个 jenkins 作业,运行s 声纳来构建和分析该单一配置文件。 Sonar 将为您提供源的质量指标和覆盖范围,因此您只需要一个包含所有源的声纳项目。此配置文件应包括您的测试,但仅用于收集覆盖率数据作为测试 运行 - 您不需要对测试进行质量测量(除非您对这类事情感兴趣)。

Sonar 根据'artifactId' 标签构建项目。由于对于一个 pom 文件我们只有 1 'artifactId',我们只能在 sonarqube 中列出 1 个项目。对于多个声纳项目条目,我们必须有多个 pom 文件。 谢谢。