bmuschko / gradle-clover-plugin

Gradle plugin for generating a code coverage report using Clover
Apache License 2.0
74 stars 49 forks source link

Java project with groovy tests can't find groovyc #59

Closed jeremydyoung closed 7 years ago

jeremydyoung commented 9 years ago

When you have a project where only the tests use groovy, the clover plugin can't locate Groovyc as seen in the error below.

* What went wrong:
Execution failed for task ':test'.
> taskdef class org.codehaus.groovy.ant.Groovyc cannot be found
 using the classloader AntClassLoader[]

The workaround is to include groovy as a compile dependency, however this is not ideal.

jeremydyoung commented 9 years ago

I am not sure if it would have been better to only create the pull request, sorry if this was duplication.

okorz001 commented 8 years ago

Thanks for the patch, I was stuck on this.

Alex-Vol-SV commented 7 years ago

This is a very simple and well formed pull request with integration tests. We should try to get it merged in the current release stream.

Alex-Vol-SV commented 7 years ago

Merged to master, pending release.

piotrgajow commented 7 years ago

I think this issue was reintroduced in v2.1.1, as I got an error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> taskdef class org.codehaus.groovy.ant.Groovyc cannot be found

Which can befixed by adding

    compile 'org.codehaus.groovy:groovy-all:2.4.7'

in build.gradle.

Alex-Vol commented 7 years ago

What Gradle version are you using?

Alex-Vol commented 7 years ago

I tried Gradle 3.5 and Gradle 2.4 with the integration test java-project-groovy-tests that is used to confirm this issue is fixed and it worked with both versions. The project is in the source tree if you want to try as well. I need more information about your specific environment and versions.

piotrgajow commented 7 years ago

I am using gradle in a grails project with this versions:

------------------------------------------------------------
Gradle 3.5
------------------------------------------------------------

Build time:   2017-04-10 13:37:25 UTC
Revision:     b762622a185d59ce0cfc9cbc6ab5dd22469e18a6

Groovy:       2.4.10
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_51 (Oracle Corporation 25.51-b03)
OS:           Windows 8.1 6.3 amd64

$ grails -version
|Grails Version: 3.2.7
|Groovy Version: 2.4.7
|JVM Version: 1.8.0_51
sdelamo commented 7 years ago

I needed to add in Grails 3.3.0.RC! project the dependency: compile "org.codehaus.groovy:groovy-all:2.4.12"

With that it is running fine.

Thanks for fixing the compatibility with Grails 3 @Alex-Vol Really appreciated!

Alex-Vol commented 7 years ago

I am going to look into why Grails invocation causes this. It is quite possibly another manifestation of #59 or similar. If I can reproduce with my Grails 3 test project I can make a quick fix.

I will open an issue for this.

Alex-Vol commented 7 years ago

After spending some time looking at this issue it seems that currently it works as designed. We expect to find the Groovyc class in the compile classpath when compiling Groovy tests. This may be a side-effect of the way Grails compiles Groovy code, perhaps using the build it Gradle Groovy compile task.

This is a new issue unrelated to the original java project with groovy tests issue, that was specifically requiring a Java project to depend on Groovy. As it stands now I cannot fix it without coming up with an alternative way to compile Groovy tests and Groovy code. The workaround will have to stand as is.

If possible the provided configuration should be used instead of compile configuration to avoid having a direct dependency of groovy if that is undesirable.