Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clover+Maven+Eclipse

I am using eclipse + maven2 to build my applications. I need to start working with clover.

My question is therefore: from your experience, what is the best way to combine these 3.

I mean, I know there is a clover plugin for eclipse, there is also a clover plugin for maven2 and of course there is maven plugin for eclipse (m2eclipse - which I am already using).

What should I use and how?

Thank you.

like image 640
Avi Y Avatar asked Jun 28 '26 01:06

Avi Y


1 Answers

Under Eclipse, use the Clover Eclipse Plugin.

Under Maven, use the Maven Clover Plugin. Add a Clover Report to the site generation:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>
          [...]
        </configuration>
        <executions>
          <execution>
            <phase>pre-site</phase>
            <goals>
              <goal>instrument</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
  <reporting>
    <plugins>
      [...]
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>
          [...]
        </configuration>
      </plugin>
    </plugins>
  </reporting>
[...]

Optionally, you can check for a test coverage percentage and fail the build in case of non-compliance:

  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>
          <targetPercentage>80%</targetPercentage>
        </configuration>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>instrument</goal>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

The maven build remains the master. Run it using your preferred method (command line or m2eclipse).

like image 94
Pascal Thivent Avatar answered Jun 30 '26 22:06

Pascal Thivent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!