Hi, In your case jacoco-maven-plugin updates property, but maven-surefire-plugin doesn't use this update.
>From our documentation at http://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html : If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo. One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation <http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation> Explanation of "late property evaluation" from http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation : Maven does property replacement for ${...} values in pom.xml before any plugin is run. So Surefire would never see the place-holders in its argLine property. Since the Version 2.17 using an alternate syntax for these properties, @{...} allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly. So replace in your pom.xml "${coverageAgent}" by "@{coverageAgent}". mvn clean test -X | grep "command line" [DEBUG] Forking command line: /bin/sh -c cd /tmp/j && /home/godin/.java-select/versions/jdk1.8.0_152/jre/bin/java -javaagent:/home/godin/.m2/repository/org/jacoco/org.jacoco.agent/0.8.0/org.jacoco.agent-0.8.0-runtime.jar=destfile=/tmp/j/target/jacoco.exec -jar /tmp/j/target/surefire/surefirebooter6907447922370012705.jar /tmp/j/target/surefire 2018-02-03T20-14-39_816-jvmRun1 surefire5242086529034299797tmp surefire_07205880708538677833tmp P.S. please be aware that the standard courtesies (Hi, Thanks, ...) are always appreciated in this and other mailing lists. On Saturday, February 3, 2018 at 4:47:47 PM UTC+1, [email protected] wrote: > > 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/c3186fb4-ef2c-4302-813b-db3ac10b8e6d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
