-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Expand file tree
/
Copy pathbuild.gradle
More file actions
170 lines (149 loc) · 5.98 KB
/
build.gradle
File metadata and controls
170 lines (149 loc) · 5.98 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import io.github.gradlenexus.publishplugin.CloseNexusStagingRepository
import io.github.gradlenexus.publishplugin.ReleaseNexusStagingRepository
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.gradle.plugin-publish") version "2.0.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("java-gradle-plugin")
id("maven-publish")
id("org.gradle.kotlin.kotlin-dsl") version "5.2.0"
id("org.jetbrains.kotlin.jvm") version "2.0.21"
id("signing")
}
group = "org.openapitools"
version = "$openApiGeneratorVersion"
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
description = """
This plugin supports common functionality found in Open API Generator CLI as a Gradle plugin.
This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
specifications as part of your build. Other tasks are available as command line tasks.
"""
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenLocal()
mavenCentral()
maven {
name = "Sonatype Snapshots"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
implementation("org.openapitools:openapi-generator:$openApiGeneratorVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test-testng:1.9.0")
}
tasks.named("test", Test).configure {
useTestNG()
testLogging.showStandardStreams = false
systemProperty("openApiGeneratorVersion", openApiGeneratorVersion)
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
onOutput { descriptor, event ->
// SLF4J may complain about multiple bindings depending on how this is run.
// This is just a warning, but can make test output less readable. So we ignore it specifically.
if (!event.message.contains("SLF4J:")) {
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message)
}
}
}
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "11"
}
}
tasks.withType(Javadoc).configureEach {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}
tasks.withType(CloseNexusStagingRepository).configureEach {
onlyIf { nexusPublishing.useStaging.get() }
}
tasks.withType(ReleaseNexusStagingRepository).configureEach {
onlyIf { nexusPublishing.useStaging.get() }
}
tasks.named("validatePlugins").configure {
enableStricterValidation = true
}
gradlePlugin {
website = "https://openapi-generator.tech/"
vcsUrl = "https://github.com/OpenAPITools/openapi-generator"
plugins {
openApiGenerator {
id = "org.openapi.generator"
description = "OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)."
displayName = "OpenAPI Generator Gradle Plugin"
implementationClass = "org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin"
tags.addAll("openapi-3.0", "openapi-2.0", "openapi", "swagger", "codegen", "sdk")
}
}
}
nexusPublishing {
repositories {
sonatype {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile
stagingProfileId = "456297f829bbbe"
}
}
}
// Signing requires three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile.
// These can be passed to the Gradle command:
// ./gradlew -Psigning.keyId=yourid
// or stored as key=value pairs in ~/.gradle/gradle.properties
// You can also apply them in CI via environment variables. See Gradle's docs for details.
signing {
required = { isReleaseVersion && gradle.taskGraph.hasTask("publishPluginMavenPublicationToSonatypeRepository") }
sign(publishing.publications)
}
// afterEvaluate is necessary because java-gradle-plugin
// creates its publications in an afterEvaluate callback
afterEvaluate {
tasks.named("publishToSonatype").configure {
dependsOn("check")
}
publishing {
publications {
pluginMaven {
pom {
name = "OpenAPI-Generator Contributors"
description = project.description
url = "https://openapi-generator.tech"
organization {
name = "org.openapitools"
url = "https://github.com/OpenAPITools"
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id = "openapitools"
name = "OpenAPI-Generator Contributors"
email = "team@openapitools.org"
}
}
scm {
url = "https://github.com/OpenAPITools/openapi-generator"
connection = "scm:git:git://github.com/OpenAPITools/openapi-generator.git"
developerConnection = "scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git"
}
issueManagement {
system = "GitHub"
url = "https://github.com/OpenAPITools/openapi-generator/issues"
}
}
}
}
}
}