Question about argLine set to empty

68 views
Skip to first unread message

Roberto Andrioli

unread,
Jan 28, 2017, 10:54:09 AM1/28/17
to JaCoCo and EclEmma Users
Hey Guys,

I have another question about JaCoCo. 

Why is JaCoCo plugin setting argLine to empty when the plugin execution is skipped? Why simply does nothing? i.e., do not change argLine.

I come with this question after setup a simple Maven project. In this project I have a Java agent configured in the argLine directly in properties section:

```
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <argLine>-javaagent:lib/my-custom-agent.jar -Doutput.file=target/output.bin</argLine>
</properties>
```

JaCoCo plugin prepend its own configuration in the argLine and Surefire runs everything perfectly. But when JaCoCo plugin is skipped, the argLine is set to empty and my custom agent do not run.

I know, I can easily fix this issue by configuring the Surefire plugin. But there is some technical reason for this behavior?

Thanks in advance

Roberto

Evgeny Mandrikov

unread,
Jan 28, 2017, 2:53:29 PM1/28/17
to JaCoCo and EclEmma Users
Hi,

Initially in version 0.6.1 this was implemented as prepending of empty string ( see https://github.com/jacoco/jacoco/commit/ca863838a09a935572c3291da708870f6b9bc3c3#diff-1e1f9f25011241fca234b2856ec18b8eR175 associated with https://github.com/jacoco/jacoco/issues/44 ) to cover scenario when execution is skipped with following configuration

<properties>
  <-- no argLine here -->
</properties>

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <argLine>-foobar ${argLine}</argLine>
  </configuration>
</plugin>

According to https://github.com/jacoco/jacoco/pull/192 there was regression in 0.6.4 regarding this.
But unfortunately behavior wasn't fully restored in 0.6.5 ( https://github.com/jacoco/jacoco/commit/c4aef33c74400419852d76b6579fbcbf58b4666e ) , i.e. it started to set empty instead of prepending empty string.

All in all - thank you for finding this bug! I created ticket https://github.com/jacoco/jacoco/issues/486

For now there are seems to be multiple ways to workaround this, like the one that you mention. Another one - is to use property dedicated for JaCoCo using "propertyName" parameter ( http://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html#propertyName ).

Hope this helps.

Regards,
Evgeny

Roberto Andrioli

unread,
Jan 28, 2017, 10:01:55 PM1/28/17
to JaCoCo and EclEmma Users
Now everything makes sense :)

Nice tip about the "propertyName".  I can append this property manually in the argLine property and don't need to configure the Surefire plugin. Great.

I'll change my code to use that until next version

Thanks

Roberto

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/oWXxpvEz-dw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/af708c09-5c38-4139-a8e3-644e137b6a15%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages