Gradle-Jacoco Plugin Released

I just pushed out the 0.1.0 version of the Gradle-Jacoco plugin. See Github for details.

https://github.com/ajoberstar/gradle-jacoco

Hi Andrew,

This plugin look great. Great work on the DSL. Cheers!

0.2.0 should be hitting Maven Central within 24 hours.

This looks quite nice.

It does appear to add a required dependency upon org.jacoco.ant that makes sense for local report generation, but is not necessary when just generating output for sonar.

Also, is there a potential plugin application ordering issue such that if jacoco is applied first, it looks like it will miss later sonar plugin applications.

Hmm, it also seems that applying jacoco before the java plugin will not necessarily do much. I might be looking at it wrong, but a plugins.withType(JavaPlugin).whenPluginAdded {} might help, and you could assign things to the Test tasks at that point as well.

There is also a different gradle plugin for jacoco referenced here (can’t wait for the gradle plugins portal…):

http://www.eclemma.org/jacoco/trunk/doc/integrations.html

I have not actually had a chance to test-drive this, so take my comments with a grain of salt. :slight_smile:

-Spencer

Correct, it does add a dependency on the Jacoco Ant JAR regardless. It is in a separate configuration, so it will only resolve if you use either ‘JacocoMerge’ or ‘JacocoReport’. Not sure if there are any other drawbacks to having that dependency. I believe this is the same pattern used by the other quality plugins in Gradle core, though I may be wrong on the details.

Plugin ordering should not matter. My understanding is that ‘withType(Class)’ will apply the closure against the matching plugins regardless of when they are applied.

The ‘Test’ task stuff is also waiting until the tasks are created.

I did see that plugin before I wrote mine, but it looks pretty limited. It provides an overall convention for configuring Jacoco use on the ‘test’ task. I wanted to go broader and include a more fluent DSL.

Thanks for looking into it! Let me know if you have any further questions about the plugin.

My understanding is that withType(Class) will apply the closure against the matching plugins regardless of when they are applied.

That’s correct.

Excellent. I’ve learned something (which is always good), and will definitely adjust the incorrect/redundant pattern I’ve been using so far.

-Spencer