Skip to content

Instantly share code, notes, and snippets.

@michaelajr
Last active May 26, 2018 15:37
Show Gist options
  • Save michaelajr/bcff10f1577a34c57fb6a890e01aded2 to your computer and use it in GitHub Desktop.
Save michaelajr/bcff10f1577a34c57fb6a890e01aded2 to your computer and use it in GitHub Desktop.
Maven For Pipelining, Part 1
<!-- Run unit tests with code coverage -->
<profile>
<id>unit-test</id>
<activation>
<file>
<exists>${basedir}/src/test</exists>
</file>
</activation>
<properties>
<testAgent></testAgent>
</properties>
<build>
<pluginManagement>
<plugins>
<!-- Code Coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>${sonar.coverage.exclusions}</exclude>
</excludes>
</configuration>
<executions>
<!-- Before running unit tests -->
<execution>
<id>preTest</id>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<skip>${skipUnitTests}</skip>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<propertyName>testAgent</propertyName>
</configuration>
</execution>
<!-- After running unit tests -->
<execution>
<id>postTest</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<skip>${skipUnitTests}</skip>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- Update SureFire (already bound to test phase) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{testAgent} ${jvmArgs}</argLine>
<skipTests>${skipUnitTests}</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!-- Use in lifecycle -->
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment