File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
restdocs-api-spec-gradle-plugin
src/test/kotlin/com/epages/restdocs/apispec/gradle
samples/restdocs-api-spec-sample Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,10 @@ allprojects {
5656 apply (plugin = " jacoco" )
5757 apply (plugin = " maven-publish" )
5858 apply (plugin = " org.jmailen.kotlinter" )
59-
6059 }
6160}
6261
6362
64-
6563subprojects {
6664
6765 val jacksonVersion by extra { " 2.9.5" }
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ gradlePlugin {
2626val jacksonVersion: String by extra
2727val junitVersion: String by extra
2828
29+ val jacocoRuntime by configurations.creating
30+
2931dependencies {
3032 compileOnly(gradleKotlinDsl())
3133
@@ -44,4 +46,22 @@ dependencies {
4446 testImplementation(" com.jayway.jsonpath:json-path:2.4.0" )
4547
4648 testCompile(gradleTestKit())
49+
50+ jacocoRuntime(" org.jacoco:org.jacoco.agent:0.8.2:runtime" )
51+ }
52+
53+ // generate gradle properties file with jacoco agent configured
54+ // see https://discuss.gradle.org/t/testkit-jacoco-coverage/18792
55+ val createTestKitFiles by tasks.creating {
56+ val outputDir = project.file(" $buildDir /testkit" )
57+
58+ inputs.files(jacocoRuntime)
59+ outputs.dir(outputDir)
60+
61+ doLast {
62+ outputDir.mkdirs()
63+ file(" $outputDir /testkit-gradle.properties" ).writeText(" org.gradle.jvmargs=-javaagent:${jacocoRuntime.asPath} =destfile=$buildDir /jacoco/test.exec" )
64+ }
4765}
66+
67+ tasks[" test" ].dependsOn(createTestKitFiles)
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ abstract class RestdocsOpenApiTaskTestBase {
4646 buildFile = resolve(" build.gradle" ).toFile()
4747 snippetsFolder = resolve(" build/generated-snippets" ).toFile().apply { mkdirs() }
4848 outputFolder = resolve(" build/openapi" ).toFile()
49+
50+ initializeGradleProperties()
4951 }
5052 }
5153
@@ -245,4 +247,10 @@ abstract class RestdocsOpenApiTaskTestBase {
245247
246248 protected fun outputFileContext (): DocumentContext =
247249 JsonPath .parse(outputFolder.resolve(" $outputFileNamePrefix .$format " ).readText().also { println (it) })
250+
251+ private fun Path.initializeGradleProperties () {
252+ // jacoco agent configuration
253+ resolve(" gradle.properties" ).toFile()
254+ .writeText(File (" build/testkit/testkit-gradle.properties" ).readText())
255+ }
248256}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ buildscript {
1010 }
1111 dependencies {
1212 classpath(" org.springframework.boot:spring-boot-gradle-plugin:${ springBootVersion} " )
13- classpath(" com.epages:restdocs-api-spec-gradle-plugin:0.0.6 " )
13+ classpath(" com.epages:restdocs-api-spec-gradle-plugin:0.5.0 " )
1414 }
1515}
1616
@@ -42,7 +42,7 @@ dependencies {
4242 testCompile(' org.springframework.boot:spring-boot-starter-test' )
4343 testCompile(' org.springframework.restdocs:spring-restdocs-mockmvc' )
4444
45- testCompile(' com.epages:restdocs-api-spec:0.0.6 ' )
45+ testCompile(' com.epages:restdocs-api-spec:0.5.0 ' )
4646 // testCompile project(':restdocs-api-spec') //enable for depending on the submodule directly
4747 testCompile(' com.google.guava:guava:23.0' )
4848}
You can’t perform that action at this time.
0 commit comments