I defined a custom property name for the JaCoCo agent but the prepare-agent 
goal doesn't update the value of the custom property if it is already defined.

In my example below, the name of the custom property is coverageAgent.
The surefire plug-in is then configured to use the coverageAgent property as 
its argument line.

When surefire runs, its argument line doesn't contain the JaCoCo agent 
configuration.

-----------------------------------------
POM.xml
-----------------------------------------
<?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>com.somecompany.bdo</groupId>
  <artifactId>bdo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jacoco.propertyName>coverageAgent</jacoco.propertyName>
    <coverageAgent/>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.0</version>
        <executions>
          <execution>
            <id>jacoco-prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.20.1</version>
        <configuration>
          <argLine>${coverageAgent}</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

-----------------------------------------
Maven output
-----------------------------------------
mvn -X clean test
...
[INFO] --- jacoco-maven-plugin:0.8.0:prepare-agent (jacoco-prepare-agent) @ bdo 
---
...
[INFO] coverageAgent set to 
-javaagent:/home/rmozone/.m2/repository/org/jacoco/org.jacoco.agent/0.8.0/org.jacoco.agent-0.8.0-runtime.jar=destfile=/home/rmozone/workspace/git/bdoo/target/jacoco.exec
...
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ bdo ---
...
[DEBUG] Forking command line: /bin/sh -c cd /home/rmozone/workspace/git/bdoo && 
/usr/lib/jvm/java-8-oracle/jre/bin/java -jar 
/home/rmozone/workspace/git/bdoo/target/surefire/surefirebooter2531224102921618966.jar
 /home/rmozone/workspace/git/bdoo/target/surefire 
2018-02-03T13-44-20_556-jvmRun1 surefire3724758252028070151tmp 
surefire_01835185317323397064tmp

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/8c5caa36-18ab-4a6f-a31b-0933d70bb5e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to