Guest User

Untitled

a guest
Apr 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. buildscript {
  2. ext {
  3. ....
  4. }
  5. repositories {
  6. mavenCentral()
  7. maven {
  8. ....
  9. }
  10. }
  11. dependencies {
  12. .....
  13. }
  14. }
  15.  
  16.  
  17. apply plugin: 'java'
  18. apply plugin: 'eclipse'
  19. apply plugin: 'idea'
  20. apply plugin: 'jacoco'
  21.  
  22. jar {
  23. baseName = "coverage-test"
  24. }
  25.  
  26.  
  27. dependencies {
  28. // my dependencies
  29. }
  30.  
  31.  
  32. eclipse {
  33. classpath {
  34. containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
  35. containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
  36. }
  37. }
  38.  
  39. wrapper {
  40. gradleVersion = '3.4.1'
  41. }
  42.  
  43. jacoco {
  44. toolVersion = '0.7.9'
  45. }
  46.  
  47. jacocoTestReport {
  48. reports {
  49. xml.enabled false
  50. csv.enabled false
  51. }
  52. group = "Reporting"
  53. description = "Generate Jacoco coverage reports after running tests."
  54. additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
  55.  
  56. afterEvaluate {
  57. classDirectories = files(classDirectories.files.collect {
  58. fileTree(
  59. dir: it,
  60. excludes:
  61. [
  62. 'com/jacoco/dto/**',
  63. 'com/jacoco/configs/**',
  64. //and others
  65. ])
  66. })
  67. }
  68. }
  69.  
  70. jacocoTestCoverageVerification {
  71.  
  72. //I tried this and it didn't work
  73.  
  74. // classDirectories = files(classDirectories.files.collect {
  75. // fileTree(
  76. // dir: it,
  77. // excludes:
  78. // [
  79. // 'com/jacoco/dto/**',
  80. // 'com/jacoco/configs/**',
  81. // //and others
  82. // ])
  83. // })
  84.  
  85. violationRules {
  86. rule {
  87. //Also tried this and it didn't work
  88.  
  89. // excludes = ['com/jacoco/dto/**', ...]
  90.  
  91. limit {
  92. counter = 'BRANCH'
  93. minimum = 0.8
  94. }
  95. }
  96. }
  97. }
  98. check.dependsOn jacocoTestCoverageVerification
  99.  
  100. violationRules {
  101. rule {
  102. element = 'CLASS'
  103. excludes = ['com.jacoco.dto.*']
  104. limit {
  105. counter = 'BRANCH'
  106. minimum = 0.8
  107. }
  108. }
  109. }
  110.  
  111. check.dependsOn jacocoTestCoverageVerification
  112.  
  113. afterEvaluate {
  114. classDirectories = files(classDirectories.files.collect {
  115. fileTree(dir: it, exclude: [
  116. 'com/example/my/package/*',
  117. 'com/example/service/MyApplication.kt',
  118. 'com/google/protobuf/*'
  119. ])
  120. })
  121. }
  122.  
  123. apply plugin: "jacoco”
  124.  
  125. jacocoTestCoverageVerification {
  126. afterEvaluate {
  127. classDirectories = files(classDirectories.files.collect {
  128. fileTree(dir: it, exclude: [
  129. 'com/example/my/package/*',
  130. 'com/example/service/MyApplication.kt',
  131. 'com/google/protobuf/*'
  132. ])
  133. })
  134. }
  135.  
  136. violationRules {
  137. rule {
  138. limit {
  139. minimum = 0.79
  140. }
  141. }
  142. }
  143. }
  144.  
  145.  
  146. // to run coverage verification during the build (and fail when appropriate)
  147. check.dependsOn jacocoTestCoverageVerification
Add Comment
Please, Sign In to add comment