Closed freshcodemonger closed 5 years ago
Are you sure you set this correctly? It has been tested and it works.
clover.enabled = false
or
clover {
enabled = false
}
I retested this in a single project as well as a multiproject configuration. Both report Clover disabled and do not apply instrumentation. The test I used was a simple build we have to run functional tests with. The build.gradle file for this is here: disabled-instrumentation
For reference this is the output I receive when running the multiproject configuration:
:p1:clean
:p2:clean
:p3:clean
:p1:compileJava
:p1:processResources NO-SOURCE
:p1:classes
:p1:jar
:p1:assemble
:p1:compileTestJava
:p1:processTestResources NO-SOURCE
:p1:testClasses
:p1:test
[clover-clean] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-clean] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-clean] Clover free edition.
[clover-setup] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-setup] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-setup] Clover free edition.
Clover is disabled.
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p1/build/classes/java/main
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p1/build/classes/java/test
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p1/build/classes/java
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p1/build/classes/java
:p1:check
:p1:build
:p2:compileJava
:p2:processResources NO-SOURCE
:p2:classes
:p2:jar
:p2:assemble
:p2:compileTestJava
:p2:processTestResources NO-SOURCE
:p2:testClasses
:p2:test
[clover-clean] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-clean] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-clean] Clover free edition.
[clover-setup] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-setup] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-setup] Clover free edition.
Clover is disabled.
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p2/build/classes/java/main
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p2/build/classes/java/test
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p2/build/classes/java
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p2/build/classes/java
:p2:check
:p2:build
:p3:compileJava
:p3:processResources NO-SOURCE
:p3:classes
:p3:jar
:p3:assemble
:p3:compileTestJava
:p3:processTestResources NO-SOURCE
:p3:testClasses
:p3:test
[clover-clean] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-clean] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-clean] Clover free edition.
[clover-setup] OpenClover Version 4.2.0, built on April 30 2017 (build-1000)
[clover-setup] Loaded from: /home/avolanis/.gradle/caches/modules-2/files-2.1/org.openclover/clover/4.2.0/6e24ca61354259476c48022595355dfe022e46ca/clover-4.2.0.jar
[clover-setup] Clover free edition.
Clover is disabled.
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p3/build/classes/java/main
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p3/build/classes/java/test
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p3/build/classes/java
[move] Moving 1 file to /home/avolanis/github.com/gradle-clover-plugin/src/functTest/projects/java-project-disabled-instrumentation/p3/build/classes/java
:p3:check
:p3:build
BUILD SUCCESSFUL in 3s
15 actionable tasks: 15 executed
Thanks for testing it !!
Where do I find the referenced deps.gradle? I tried a search on the repo but it didn't find it.
I'll give my code another try and see if I can narrow down my issue.
Umm, it is there as ../deps.gradle. It is not that hard to find. deps.gradle
Sorry not sure why I didn't find it !
So I tried and though it claims it is disabled I still get output and the classes get recompiled:
Shouldn't it exit before loading up the openClover jar file?
Task :test [clover-clean] OpenClover Version 4.2.0, built on April 30 2017 (build-1000) [clover-clean] Loaded from: F:.gradle\caches\modules-2\files-2.1\org.openclover\clover\4.2.0\6e24ca61354259476c48022595355dfe022e46ca\clover-4.2.0.jar [clover-clean] Clover free edition. [clover-setup] OpenClover Version 4.2.0, built on April 30 2017 (build-1000) [clover-setup] Loaded from: F:.gradle\caches\modules-2\files-2.1\org.openclover\clover\4.2.0\6e24ca61354259476c48022595355dfe022e46ca\clover-4.2.0.jar [clover-setup] Clover free edition. Clover is disabled. [javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 141 source files to D:\git\bcit\cc168\build\classes\java\main [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 26 source files to D:\git\bcit\cc168\build\classes\java\test [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details.
My junit tests also start failing due to the re-compilation. For now I have a work around I just push the clover stuff to a apply file and do something like:
if (cloverEnabled.toBoolean()) { apply from: 'b/clover.gradle' }
Thanks for the work on this plugin !
Yea, the classes are recompiled but without instrumentation. Your workaround disables the plugin completely and solves the issue. Perhaps we can allow for the instrumentation to be disabled by not adding the task action on the test task. I will take this on as an enhancement. With this plugin we do not need to be coupled so closely to the underlying library facilities. I can see how we may be able to let the plugin do the right thing instead of disabling the Clover instrumentation while everything else is still invoked.
I think all you'd need for this is :
Line 64:
if (cloverPluginConvention.enabled) { AggregateDatabasesTask aggregateDatabasesTask = configureAggregateDatabasesTask(project, cloverPluginConvention) configureActions(project, cloverPluginConvention, aggregateDatabasesTask) configureGenerateCoverageReportTask(project, cloverPluginConvention, aggregateDatabasesTask) configureAggregateReportsTask(project, cloverPluginConvention) }
Thanks, but it is a bit more complex than that. Perhaps the best approach is to disable the tasks instead of removing them. Your suggestion would work in the general case but in many environments such an approach would break an automated build should the option to enable was turned off.
As a CI engineer I would want the disable option to not break any existing task selections that I may have in place. Take as an example a case where one declared a finalizedBy cloverAggregateReport
in their build.gradle. They would prefer when enabled is false by an external property to not have to add logic that also skips the finalizedBy
clause in their code.
I will spend some time thinking about the best approach to make this happen. I think if I were to just disable the injected actions in configureActions we would get the desired effect.
if (cloverPluginConvention.enabled) {
configureActions(project, cloverPluginConvention, aggregateDatabasesTask)
}
Good point. Thanks for looking at it.
I tried the enabled = false but that just turns off the generation of the clover reports. The instrumentation still occurs.