Hi,

JaCoCo plugin for Gradle is not developed by JaCoCo Team - see 
https://www.jacoco.org/jacoco/trunk/doc/integrations.html
and there is not much Gradle experts in this mailing list who provide 
answers,
so I would advice to use another channel for such Gradle-specific questions.

However based on 
https://docs.gradle.org/current/userguide/jacoco_plugin.html#default_values_of_the_jacoco_task_extension
 :

for following "build.gradle"

apply plugin: 'java'
apply plugin: 'jacoco'

repositories {
  mavenCentral()
}

dependencies {
  testCompile 'junit:junit:4.12'
}

test {
    jacoco {
        enabled = "$jacocoEnabled".toBoolean()
    }
}

and "src/main/java/Example.java"

class Example {
  void example() {
  }
}

and "src/test/java/ExampleTest.java"

public class ExampleTest {
  @org.junit.Test
  public void test() {
    new Example().example();
  }
}

execution of

gradle --info clean build -PjacocoEnabled=true

shows that JaCoCo Java Agent is used during execution of tests ( "java ... 
-javaagent:.../jacocoagent.jar ..." )
and file "build/jacoco/test.exec" is produced,
while execution of

gradle --info clean build -PjacocoEnabled=false

shows that agent is not used and file is not produced.

And the same in case of following "build.gradle"

apply plugin: 'java'

repositories {
  mavenCentral()
}

dependencies {
  testCompile 'junit:junit:4.12'
}

if ("$jacocoEnabled".toBoolean()) {
  apply plugin: 'jacoco'
}


Hope this helps.


On Wednesday, April 17, 2019 at 7:21:07 PM UTC+2, [email protected] 
wrote:
>
> Hi,
>
> I'm trying to figure out how I can conditionally skip the Jacoco 
> instrumentation and coverage analysis in a Gradle build. I don't want the 
> coverage tasks to run in every execution of the build, I'd like to be able 
> to control that using a command line property. I tried extracting the 
> Jacoco code to its own Gradle file and using apply from: as in 
> https://stackoverflow.com/questions/42501869/gradle-skip-jacoco-during-test, 
> but this results in:
>
> java.lang.ClassNotFoundException: 
> org.jacoco.agent.rt.internal_1f1cc91.PreMain
>
> Any insight on how to accomplish this?
>
> Thanks,
> Edward
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/3320b2ac-b9b1-4f5d-a3cc-fa9548d69ecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to