1

I have a main project pom.xml which has one module not bound to any profile (module A) and one module bound to profile rest (module module.REST). In jenkins profile, there is a build configuration with a cobertura and sonar plugin.

When Jenkins executes the sonar build, the maven runner only analyses modules which are not bound to profiles and the project module itself. Is there any other way to tell sonar to analyze all modules without specifying those modules again in the profile where the plugin itself is located (in my case this is jenkins profile)? I think cobertura plugin does perform code coverage on ALL modules.

Example:

<?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>
  • This is one of the examples which i could add to my [blog entry](http://blog.soebes.de/blog/2013/11/09/why-is-it-bad-to-activate-slash-deactive-modules-by-profiles-in-maven/). The point is if you have module not in the reactor maven does not see the module nor sonar does know of any of them. So Why did you define that module in a profile? Furthermore why do you use an old version of the sonar-maven-plugin? Why have you bound the coberatury to the package phase? Does not make sense. Usually code coverage will be done within the site generation. – khmarbaise Mar 26 '14 at 06:26
  • I want to be able to compile this project to use different set of modules. On set refers to RESTful operations the other set is for SOAP operations. Since I have 2 customers I want to deliver one implementation for one customer and the other one to the other customer.I'm using the old version since it is maven2 compatible. – user3459699 Mar 26 '14 at 08:28
  • Does not make sense. Just compile all modules and deliver to the customer what you like. But don't change the modules within the reactor. You will get in trouble if you create a release. Have you checked the sonar plugin with your Maven version. Apart from that [Maven 2 is End Of Life](http://maven.apache.org/maven-2.x-eol.html). So update as soon as possible. – khmarbaise Mar 26 '14 at 08:32
  • If I think about it I kinda agree with you. I am in the process of switching to Maven 3 though. Regarding cobertura I'm not sure which phase to bind it to. Some say it should be declared within section. Bu this is another topic. Thank you. – user3459699 Mar 26 '14 at 09:07

0 Answers0