1
- buildscript {
2
- ext. kotlin_version = ' 1.3.30'
3
- repositories {
4
- mavenLocal()
5
- maven { url " https://repo1.maven.org/maven2" }
6
- maven {
7
- url " https://plugins.gradle.org/m2/"
8
- }
9
- maven {
10
- url " https://oss.sonatype.org/content/repositories/releases/"
11
- }
12
- maven {
13
- url " https://oss.sonatype.org/content/repositories/snapshots/"
14
- }
15
- }
16
- dependencies {
17
- classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
18
- classpath " gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.1.3"
19
- classpath " com.gradle.publish:plugin-publish-plugin:0.11.0"
20
- classpath " io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0"
21
- classpath " de.marcphilipp.gradle:nexus-publish-plugin:0.2.0"
22
- }
23
- }
1
+ import io.github.gradlenexus.publishplugin.CloseNexusStagingRepository
2
+ import io.github.gradlenexus.publishplugin.ReleaseNexusStagingRepository
3
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
+
5
+ plugins {
6
+ id(" com.gradle.plugin-publish" ) version " 1.0.0"
7
+ id(" io.github.gradle-nexus.publish-plugin" ) version " 1.1.0"
8
+ id(" java-gradle-plugin" )
9
+ id(" maven-publish" )
10
+ id(" org.gradle.kotlin.kotlin-dsl" ) version " 2.4.1"
11
+ id(" org.jetbrains.kotlin.jvm" ) version " 1.7.10"
12
+ id(" signing" )
13
+ }
14
+
15
+ group = " org.openapitools"
16
+ version = " $openApiGeneratorVersion "
17
+ ext. isReleaseVersion = ! version. endsWith(" SNAPSHOT" )
24
18
25
- group ' org.openapitools'
26
- // Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
27
- version " $openApiGeneratorVersion "
28
19
description = """
29
- This plugin supports common functionality found in Open API Generator CLI as a gradle plugin.
20
+ This plugin supports common functionality found in Open API Generator CLI as a Gradle plugin.
30
21
31
22
This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
32
23
specifications as part of your build. Other tasks are available as command line tasks.
33
24
"""
34
- ext. isReleaseVersion = ! version. endsWith(" SNAPSHOT" )
35
-
36
- apply plugin : ' com.gradle.plugin-publish'
37
- apply plugin : ' java-gradle-plugin'
38
- apply plugin : ' signing'
39
- apply plugin : ' kotlin'
40
- apply plugin : " org.gradle.kotlin.kotlin-dsl"
41
- apply plugin : ' io.codearte.nexus-staging'
42
- apply plugin : " de.marcphilipp.nexus-publish"
43
25
44
- sourceCompatibility = 1.8
45
- targetCompatibility = 1.8
26
+ java {
27
+ withSourcesJar()
28
+ withJavadocJar()
29
+ sourceCompatibility = 1.8
30
+ targetCompatibility = 1.8
31
+ }
46
32
47
33
repositories {
48
- mavenLocal()
49
- maven { url " https://repo1.maven.org/maven2" }
50
- maven {
51
- url " https://oss.sonatype.org/content/repositories/releases/"
52
- }
34
+ mavenCentral()
53
35
maven {
36
+ name = " Sonatype Snapshots"
54
37
url " https://oss.sonatype.org/content/repositories/snapshots/"
55
38
}
56
- jcenter()
57
39
}
58
40
59
41
dependencies {
60
- compile gradleApi()
61
- // Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
62
- compile " org.openapitools:openapi-generator:$openApiGeneratorVersion "
63
- compile " org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version "
64
-
65
- testCompile ' org.testng:testng:6.9.6' ,
66
- " org.jetbrains.kotlin:kotlin-test:$kotlin_version "
67
-
68
- testCompile " org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version "
42
+ implementation(" org.openapitools:openapi-generator:$openApiGeneratorVersion " )
43
+ testImplementation(" org.jetbrains.kotlin:kotlin-test-testng:1.7.10" )
69
44
}
70
45
71
- test {
46
+ tasks . named( " test" , Test ) . configure {
72
47
useTestNG()
73
- testClassesDirs = files(project. tasks. compileTestKotlin. destinationDir)
74
48
testLogging. showStandardStreams = false
75
49
76
50
beforeTest { descriptor ->
77
51
logger. lifecycle(" Running test: " + descriptor)
78
52
}
79
53
80
- failFast = true
81
-
82
54
onOutput { descriptor , event ->
83
55
// SLF4J may complain about multiple bindings depending on how this is run.
84
56
// This is just a warning, but can make test output less readable. So we ignore it specifically.
@@ -88,133 +60,105 @@ test {
88
60
}
89
61
}
90
62
91
- task javadocJar (type : Jar ) {
92
- from javadoc
93
- classifier = ' javadoc'
94
- }
95
-
96
- task sourcesJar (type : Jar ) {
97
- from sourceSets. main. allSource
98
- classifier = ' sources'
99
- }
100
-
101
- artifacts {
102
- archives javadocJar, sourcesJar
63
+ tasks. withType(KotlinCompile ). configureEach {
64
+ kotlinOptions {
65
+ jvmTarget = " 1.8"
66
+ }
103
67
}
104
68
105
- publishing {
106
- publications {
107
- mavenJava(MavenPublication ) {
108
- from components. java
109
- artifact sourcesJar
110
- artifact javadocJar
111
- pom {
112
- name = ' OpenAPI-Generator Contributors'
113
- description = project. description
114
- url = ' https://openapi-generator.tech'
115
- organization {
116
- name = ' org.openapitools'
117
- url = ' https://github.com/OpenAPITools'
118
- }
119
- licenses {
120
- license {
121
- name = " The Apache Software License, Version 2.0"
122
- url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
123
- distribution = " repo"
124
- }
125
- }
126
- developers {
127
- developer {
128
- id = " openapitools"
129
- name = " OpenAPI-Generator Contributors"
130
-
131
- }
132
- }
133
- scm {
134
- url = ' https://github.com/OpenAPITools/openapi-generator'
135
- connection = ' scm:git:git://github.com/OpenAPITools/openapi-generator.git'
136
- developerConnection
= ' scm:git:ssh://[email protected] :OpenAPITools/openapi-generator.git'
137
- }
138
- issueManagement {
139
- system = ' GitHub'
140
- url = ' https://github.com/OpenAPITools/openapi-generator/issues'
141
- }
142
- }
143
- }
69
+ tasks. withType(Javadoc ). configureEach {
70
+ if (JavaVersion . current(). isJava9Compatible()) {
71
+ options. addBooleanOption(" html5" , true )
144
72
}
145
73
}
146
74
147
- nexusStaging {
148
- username = project. properties[" ossrhUsername" ]
149
- password = project. properties[" ossrhPassword" ]
75
+ tasks. withType(CloseNexusStagingRepository ). configureEach {
76
+ onlyIf { nexusPublishing. useStaging. get() }
150
77
}
151
78
152
- nexusPublishing {
153
- // To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon
154
- stagingProfileId = " 456297f829bbbe"
79
+ tasks. withType(ReleaseNexusStagingRepository ). configureEach {
80
+ onlyIf { nexusPublishing. useStaging. get() }
155
81
}
156
82
157
83
gradlePlugin {
84
+ website = " https://openapi-generator.tech/"
85
+ vcsUrl = " https://github.com/OpenAPITools/openapi-generator"
158
86
plugins {
159
87
openApiGenerator {
160
- id = ' org.openapi.generator'
161
- implementationClass = ' org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin'
88
+ id = " org.openapi.generator"
89
+ description = " OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)."
90
+ displayName = " OpenAPI Generator Gradle Plugin"
91
+ implementationClass = " org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin"
92
+ tags. addAll(" openapi-3.0" , " openapi-2.0" , " openapi" , " swagger" , " codegen" , " sdk" )
162
93
}
163
94
}
164
95
}
165
96
166
- pluginBundle {
167
- // These settings are set for the whole plugin bundle
168
- website = ' https://openapi-generator.tech/ '
169
- vcsUrl = ' https://github.com/OpenAPITools/openapi-generator '
170
- description = ' OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3) '
97
+ nexusPublishing {
98
+ repositories {
99
+ sonatype {
100
+ username = project . properties[ " ossrhUsername " ]
101
+ password = project . properties[ " ossrhPassword " ]
171
102
172
- plugins {
173
- // first plugin
174
- openApiGenerator {
175
- id = ' org.openapi.generator'
176
- displayName = ' OpenAPI Generator Gradle Plugin'
177
- tags = [' openapi-3.0' , ' openapi-2.0' , ' openapi' , ' swagger' , ' codegen' , ' sdk' ]
178
- version = " $openApiGeneratorVersion "
179
- group = " org.openapitools"
103
+ // To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile
104
+ stagingProfileId = " 456297f829bbbe"
180
105
}
181
106
}
182
107
}
183
108
184
- // signing will require three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile.
185
- // These can be passed to the gradle command:
109
+ // Signing requires three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile.
110
+ // These can be passed to the Gradle command:
186
111
// ./gradlew -Psigning.keyId=yourid
187
112
// or stored as key=value pairs in ~/.gradle/gradle.properties
188
113
// You can also apply them in CI via environment variables. See Gradle's docs for details.
189
114
signing {
190
- required { isReleaseVersion && (gradle. taskGraph. hasTask(" publishPluginMavenPublicationToNexusRepository" ) ) }
191
- sign publishing. publications. mavenJava
192
- }
193
-
194
- compileKotlin {
195
- kotlinOptions {
196
- jvmTarget = " 1.8"
197
- }
198
- }
199
- compileTestKotlin {
200
- kotlinOptions {
201
- jvmTarget = " 1.8"
202
- }
115
+ required { isReleaseVersion && gradle. taskGraph. hasTask(" publishPluginMavenPublicationToSonatypeRepository" ) }
116
+ sign(publishing. publications)
203
117
}
204
118
205
- javadoc {
206
- if (JavaVersion . current(). isJava9Compatible()) {
207
- options. addBooleanOption(' html5' , true )
119
+ // afterEvaluate is necessary because java-gradle-plugin
120
+ // creates its publications in an afterEvaluate callback
121
+ afterEvaluate {
122
+ tasks. named(" publishToSonatype" ). configure {
123
+ dependsOn(" check" )
208
124
}
209
- }
210
125
211
- tasks {
212
- closeRepository {
213
- onlyIf { nexusPublishing. useStaging. get() }
214
- }
215
- releaseRepository{
216
- onlyIf { nexusPublishing. useStaging. get() }
126
+ publishing {
127
+ publications {
128
+ pluginMaven {
129
+ pom {
130
+ name = " OpenAPI-Generator Contributors"
131
+ description = project. description
132
+ url = " https://openapi-generator.tech"
133
+ organization {
134
+ name = " org.openapitools"
135
+ url = " https://github.com/OpenAPITools"
136
+ }
137
+ licenses {
138
+ license {
139
+ name = " The Apache Software License, Version 2.0"
140
+ url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
141
+ distribution = " repo"
142
+ }
143
+ }
144
+ developers {
145
+ developer {
146
+ id = " openapitools"
147
+ name = " OpenAPI-Generator Contributors"
148
+
149
+ }
150
+ }
151
+ scm {
152
+ url = " https://github.com/OpenAPITools/openapi-generator"
153
+ connection = " scm:git:git://github.com/OpenAPITools/openapi-generator.git"
154
+ developerConnection
= " scm:git:ssh://[email protected] :OpenAPITools/openapi-generator.git"
155
+ }
156
+ issueManagement {
157
+ system = " GitHub"
158
+ url = " https://github.com/OpenAPITools/openapi-generator/issues"
159
+ }
160
+ }
161
+ }
162
+ }
217
163
}
218
164
}
219
-
220
- publishToNexus. dependsOn ' check'
0 commit comments