After much fiddling I managed to get it working by setting the classpath in
the cobertura test task:
[code]
task('cobertura', group: 'Test', type: Test,
description: 'Instruments and runs the project\'s test cases, then
generates Cobertura coverate reports.') {
systemProperties['net.sourceforge.cobertura.datafile'] = serFile
classpath.from configurations.cobertura
}
[/code]
The documentation on the test Type was a little sketchy - I tried using '=',
but that didn't seem to do anything. I had to look through the code of
DefaultFileCollection to find the 'from' method.
Cheers,
Eric
On Wed, Jul 13, 2011 at 12:42 PM, Eric Berry <[email protected]> wrote:
> Hi all,
> I'm trying to set up a Cobertura test task for work. I've looked at the
> plugin listed in the wiki, and it works very well, but we have some
> restrictions that would make the plugin difficult to use here.
>
> We have an internal repository that all dependencies must be proxied
> through, and the Plugin requires outside access to download the init script
> and jar file. I've downloaded the source, and I could probably modify it so
> that everything is hosted internally, but that would require more work from
> other folks other than myself.
>
> So, I'm trying to implement the solution in the cookbook:
> http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-usingCobertura
>
> But that solution ties it to the test task, which would mean each developer
> would have to generate those reports when running unit tests. I'd like to
> create a 'cobertura' test task that can be run separately, but I'm getting
> an error when I run tests through this new task.
> [quote]
> java.lang.NoClassDefFoundError:
> net/sourceforge/cobertura/coveragedata/HasBeenInstrumented
> [/quote]
>
> My task is defined as such:
> [code]
> task('cobertura', group: 'Test', type: Test,
> description: 'Instruments and runs the project\'s test cases, then
> generates Cobertura coverate reports.') {
> systemProperties['net.sourceforge.cobertura.datafile'] = serFile
> }
> [/code]
>
> And I just tie the cookbook solution to my cobertura task instead of test.
>
> If I remove the .doFirst, and doLast closures the task runs fine and I see
> my tests succeed. Including them results in all tests failing with the error
> above.
>
> I have a test project available in Launchpad:
> https://code.launchpad.net/~elberry/+junk/gradle-cobertura<https://code.launchpad.net/%7Eelberry/+junk/gradle-cobertura>
>
> Or a downloadable tgz file:
> www.tellurianring.com/projects/gradle-cobertura.tgz
>
> Any help with this would be greatly appreciated.
>
> Thanks,
> Eric
>
> --
> Learn from the past. Live in the present. Plan for the future.
> Blog: http://eric-berry.blogspot.com
> jEdit <http://www.jedit.org> - Programmer's Text Editor
> Bazaar <http://bazaar.canonical.com> - Version Control for Humans
>
--
Learn from the past. Live in the present. Plan for the future.
Blog: http://eric-berry.blogspot.com
jEdit <http://www.jedit.org> - Programmer's Text Editor
Bazaar <http://bazaar.canonical.com> - Version Control for Humans