-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
executable file
·110 lines (88 loc) · 3.65 KB
/
build.gradle.kts
File metadata and controls
executable file
·110 lines (88 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import kotlin.apply
repositories {
mavenCentral()
}
plugins {
kotlin("jvm")
`java-gradle-plugin`
`kotlin-dsl`
id("com.gradle.plugin-publish") version "0.21.0"
}
apply(plugin = "io.spring.dependency-management")
the<DependencyManagementExtension>().apply {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
gradlePlugin {
plugins {
register("com.epages.restdocs-api-spec") {
id = "com.epages.restdocs-api-spec"
implementationClass = "com.epages.restdocs.apispec.gradle.RestdocsApiSpecPlugin"
}
}
}
pluginBundle {
website = "https://github.com/ePages-de/restdocs-api-spec"
vcsUrl = "https://github.com/ePages-de/restdocs-api-spec"
tags = listOf("spring", "restdocs", "openapi", "openapi3", "postman", "api", "specification")
description = "Extends Spring REST Docs with API specifications in OpenAPI2, OpenAPI3 and Postman Collections formats"
(plugins) {
"com.epages.restdocs-api-spec" {
displayName = "restdocs-api-spec gradle plugin"
}
}
mavenCoordinates {
groupId = "com.epages"
artifactId = "restdocs-api-spec-gradle-plugin"
}
}
val jacocoRuntime by configurations.creating
dependencies {
implementation(project(":restdocs-api-spec-openapi-generator"))
implementation(project(":restdocs-api-spec-openapi3-generator"))
implementation(project(":restdocs-api-spec-postman-generator"))
implementation("tools.jackson.core:jackson-databind:3.0.2")
implementation("tools.jackson.module:jackson-module-kotlin:3.0.2")
implementation("tools.jackson.dataformat:jackson-dataformat-yaml:3.0.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core")
testImplementation("com.jayway.jsonpath:json-path:2.10.0")
testImplementation(gradleTestKit())
jacocoRuntime("org.jacoco:org.jacoco.agent:0.8.2:runtime")
}
// generate gradle properties file with jacoco agent configured
// see https://discuss.gradle.org/t/testkit-jacoco-coverage/18792
val createTestKitFiles by tasks.registering {
val outputDir = project.layout.buildDirectory.dir("testkit")
inputs.files(jacocoRuntime)
outputs.dir(outputDir)
doLast {
outputDir.get().asFile.mkdirs()
val destFile =
project.layout.buildDirectory
.file("jacoco/test.exec")
.get()
.asFile.path
val outFile = outputDir.get().file("testkit-gradle.properties").asFile
outFile.writeText("org.gradle.jvmargs=-javaagent:${jacocoRuntime.asPath}=destfile=$destFile")
}
}
tasks["test"].dependsOn(createTestKitFiles)
// Set Gradle plugin publishing credentials from environment
// see https://github.com/gradle/gradle/issues/1246
// https://github.com/cortinico/kotlin-gradle-plugin-template/blob/1194fbbb2bc61857a76da5b5b2df919a558653de/plugin-build/plugin/build.gradle.kts#L43-L55
val configureGradlePluginCredentials by tasks.registering {
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
val secret = System.getenv("GRADLE_PUBLISH_SECRET")
if (key == null || secret == null) {
throw GradleException("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables")
}
System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
}
}
tasks["publishPlugins"].dependsOn(configureGradlePluginCredentials)