Sonar具有多模块maven项目和配置文件

时间:2014-03-25 13:41:03

标签: maven jenkins sonarqube multi-module profiles

我有一个主项目pom.xml,其中一个模块没有绑定到任何配置文件(模块A),一个模块绑定到配置文件rest(模块module.REST)。在jenkins配置文件中,有一个带有cobertura和sonar插件的构建配置。

当Jenkins执行声纳构建时,maven runner仅分析未绑定到配置文件的模块和项目模块本身。有没有其他方法可以告诉声纳分析所有模块而不在插件本身所在的配置文件中再次指定这些模块(在我的情况下这是jenkins配置文件)?我认为cobertura插件确实可以对所有模块执行代码覆盖。

示例:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>group</groupId>
    <artifactId>project</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>A</module>
    </modules>
    <profiles>
        <profile>
            <id>rest</id>
            <modules>
                <module>module.REST</module>
            </modules>
        </profile>
        <profile>
            <id>jenkins</id>
            <activation>
                <property>
                    <name>BUILD_NUMBER</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                        <version>2.5.1</version>
                        <configuration>
                            <aggregate>true</aggregate>
                            <formats>
                                <format>xml</format>
                            </formats>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>cobertura</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <version>1.0</version>
                    </plugin>
                </plugins>
            </build>
            <modules>
                <module>module.REST</module>
            </modules>
        </profile>
    </profiles>
</project>

0 个答案:

没有答案