Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Clover is disabled eliminate recompilation of sources during test task execution #112

Closed
freshcodemonger opened this issue Apr 16, 2018 · 10 comments
Assignees
Milestone

Comments

@freshcodemonger
Copy link

I tried the enabled = false but that just turns off the generation of the clover reports. The instrumentation still occurs.

@Alex-Vol
Copy link
Collaborator

Are you sure you set this correctly? It has been tested and it works.

clover.enabled = false

or

clover {
    enabled = false
}

@Alex-Vol
Copy link
Collaborator

Alex-Vol commented Apr 17, 2018

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

@freshcodemonger
Copy link
Author

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.

@Alex-Vol
Copy link
Collaborator

Umm, it is there as ../deps.gradle. It is not that hard to find.
deps.gradle

@freshcodemonger
Copy link
Author

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.

@freshcodemonger
Copy link
Author

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 !

@Alex-Vol
Copy link
Collaborator

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.

@Alex-Vol Alex-Vol self-assigned this Apr 17, 2018
@Alex-Vol Alex-Vol changed the title Is there a way to turn off instrumentation When Clover is disabled eliminate recompilation of sources during test task execution Apr 17, 2018
@freshcodemonger
Copy link
Author

I think all you'd need for this is :

https://github.com/bmuschko/gradle-clover-plugin/blob/master/src/main/groovy/com/bmuschko/gradle/clover/CloverPlugin.groovy

Line 64:

if (cloverPluginConvention.enabled) {
AggregateDatabasesTask aggregateDatabasesTask = configureAggregateDatabasesTask(project, cloverPluginConvention)
configureActions(project, cloverPluginConvention, aggregateDatabasesTask)
configureGenerateCoverageReportTask(project, cloverPluginConvention, aggregateDatabasesTask)
configureAggregateReportsTask(project, cloverPluginConvention)
}

@Alex-Vol
Copy link
Collaborator

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)
}

@freshcodemonger
Copy link
Author

Good point. Thanks for looking at it.

Alex-Vol-SV added a commit that referenced this issue May 7, 2018
…urces during test task execution

This change eliminated the injected task actions for Test task type
when `enabled` flag is set to false. Previously we simply relied to
the OpenClover closer-setup Ant task enabled flag to disable instrumentation
but we also caused the recompilation of the classes when the enabled==false.
With this change there is no action and classes are compiled only once.
@Alex-Vol-SV Alex-Vol-SV added this to the 2.2.2 milestone Feb 19, 2019
Alex-Vol-SV added a commit that referenced this issue Feb 20, 2019
…urces during test task execution

This change eliminated the injected task actions for Test task type
when `enabled` flag is set to false. Previously we simply relied to
the OpenClover closer-setup Ant task enabled flag to disable instrumentation
but we also caused the recompilation of the classes when the enabled==false.
With this change there is no action and classes are compiled only once.
@Alex-Vol-SV Alex-Vol-SV added Fixed and removed Fixed labels Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants