@@ -21,9 +21,11 @@ This plugin supports common functionality found in Open API Generator CLI as a g
2121This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
2222specifications as part of your build. Other tasks are available as command line tasks.
2323"""
24+ ext. isReleaseVersion = ! version. endsWith(" SNAPSHOT" )
2425
2526apply plugin : ' java-gradle-plugin'
26- apply plugin : ' maven-publish'
27+ apply plugin : ' maven'
28+ apply plugin : ' signing'
2729apply plugin : ' kotlin'
2830apply plugin : " org.gradle.kotlin.kotlin-dsl"
2931
6769 }
6870}
6971
70-
7172gradlePlugin {
7273 plugins {
7374 openApiGenerator {
@@ -77,6 +78,87 @@ gradlePlugin {
7778 }
7879}
7980
81+ // signing will require three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile.
82+ // These can be passed to the gradle command:
83+ // ./gradlew -Psigning.keyId=yourid
84+ // or stored as key=value pairs in ~/.gradle/gradle.properties
85+ // You can also apply them in CI via environment variables. See Gradle's docs for details.
86+ signing {
87+ required { isReleaseVersion && gradle. taskGraph. hasTask(" uploadArchives" ) }
88+ sign configurations. archives
89+ }
90+
91+ task javadocJar (type : Jar ) {
92+ classifier = ' javadoc'
93+ from javadoc
94+ }
95+
96+ task sourcesJar (type : Jar ) {
97+ from sourceSets. main. allSource
98+ classifier = ' sources'
99+ }
100+
101+ artifacts {
102+ archives javadocJar, sourcesJar
103+ }
104+
105+ def pomConfig = {
106+ description project. description
107+ name ' OpenAPI-Generator Contributors'
108+ url ' https://openapi-generator.tech'
109+ organization {
110+ name ' org.openapitools'
111+ url ' https://github.com/OpenAPITools'
112+ }
113+ licenses {
114+ license {
115+ name " The Apache Software License, Version 2.0"
116+ url " http://www.apache.org/licenses/LICENSE-2.0.txt"
117+ distribution " repo"
118+ }
119+ }
120+ developers {
121+ developer {
122+ id " openapitools"
123+ name " OpenAPI-Generator Contributors"
124+ email " team@openapitools.org"
125+ }
126+ }
127+ scm {
128+ url ' https://github.com/OpenAPITools/openapi-generator'
129+ connection ' scm:git:git://github.com/OpenAPITools/openapi-generator.git'
130+ developerConnection ' scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git'
131+ }
132+ issueManagement {
133+ system ' GitHub'
134+ url ' https://github.com/OpenAPITools/openapi-generator/issues'
135+ }
136+ }
137+
138+ uploadArchives {
139+ repositories {
140+
141+ // credentials here would need to be passed along with the gradle command:
142+ // ./gradlew -P ossrhUsername=yourUser
143+ // or stored in ~/.gradle/gradle.properties as key=value pairs
144+ mavenDeployer {
145+ beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
146+ repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2/" ) {
147+ authentication(userName : ossrhUsername, password : ossrhPassword)
148+ }
149+ snapshotRepository(url : " https://oss.sonatype.org/content/repositories/snapshots/" ) {
150+ authentication(userName : ossrhUsername, password : ossrhPassword)
151+ }
152+
153+ pom. withXml {
154+ def root = asNode()
155+ root. appendNode(' description' , project. description)
156+ root. children(). last() + pomConfig
157+ }
158+ }
159+ }
160+ }
161+
80162compileKotlin {
81163 kotlinOptions {
82164 jvmTarget = " 1.8"
@@ -86,4 +168,4 @@ compileTestKotlin {
86168 kotlinOptions {
87169 jvmTarget = " 1.8"
88170 }
89- }
171+ }
0 commit comments