Skip to content

Commit 792d44d

Browse files
authored
Use Gradle 7.6 to build Gradle plugin (#13860)
* Upgrade Gradle plugin Gradle build to Gradle 7.5.1 * Update Travis workflow file to support new tasks * Update Maven POM with Gradle 7.5.1 * Capitalize many occurrences of "Gradle" in the Gradle plugin README * Update Gradle version in appveyor.yml and shippable.yml * Update comments * Update Gradle wrapper to 7.5.1 * Capitalize Gradle in shippable.yml * Leave Open API * Upgrade Gradle plugin build to Gradle 7.6 * Upgrade wrapper to Gradle 7.6
1 parent a92afd2 commit 792d44d

13 files changed

+299
-296
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,24 @@ after_success:
160160
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
161161
pushd .;
162162
cd modules/openapi-generator-gradle-plugin;
163-
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishMavenJavaPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
164-
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
163+
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository;
164+
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository";
165165
popd;
166166
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then
167167
echo "Publishing from branch $TRAVIS_BRANCH";
168168
mvn clean deploy --settings CI/settings.xml;
169169
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
170170
pushd .;
171171
cd modules/openapi-generator-gradle-plugin;
172-
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon;
173-
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository";
172+
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository;
173+
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository";
174174
popd;
175175
fi;
176176
if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then
177177
echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)";
178178
pushd .;
179179
cd modules/openapi-generator-gradle-plugin;
180-
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET --no-daemon;
180+
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET;
181181
echo "Finished ./gradlew publishPlugins (plugin portal)";
182182
popd;
183183
fi;

appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ install:
1515
# install gradle
1616
- ps: |
1717
Add-Type -AssemblyName System.IO.Compression.FileSystem
18-
if (!(Test-Path -Path "C:\gradle\gradle-5.6.4" )) {
18+
if (!(Test-Path -Path "C:\gradle\gradle-7.6" )) {
1919
(new-object System.Net.WebClient).DownloadFile(
20-
'https://services.gradle.org/distributions/gradle-5.6.4-bin.zip',
20+
'https://services.gradle.org/distributions/gradle-7.6-bin.zip',
2121
'C:\gradle-bin.zip'
2222
)
2323
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\gradle-bin.zip", "C:\gradle")
2424
}
25-
- cmd: SET PATH=C:\maven\apache-maven-3.8.3\bin;C:\gradle\gradle-5.6.4\bin;%JAVA_HOME%\bin;%PATH%
25+
- cmd: SET PATH=C:\maven\apache-maven-3.8.3\bin;C:\gradle\gradle-7.6\bin;%JAVA_HOME%\bin;%PATH%
2626
- cmd: SET MAVEN_OPTS=-Xmx4g
2727
- cmd: SET JAVA_OPTS=-Xmx4g
2828
- cmd: SET M2_HOME=C:\maven\apache-maven-3.8.3

modules/openapi-generator-gradle-plugin/README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
= OpenAPI Generator Gradle Plugin
22

3-
This document describes the gradle plugin for OpenAPI Generator.
3+
This document describes the Gradle plugin for OpenAPI Generator.
44

5-
This gradle plugin offers a declarative DSL via _extensions_ (these are Gradle project extensions).
5+
This Gradle plugin offers a declarative DSL via _extensions_ (these are Gradle project extensions).
66
These map almost fully 1:1 with the options you'd pass to the CLI or Maven plugin. The plugin maps the extensions to a task of the same name to provide a clean API. If you're interested in the extension/task mapping concept from a high-level, you can https://docs.gradle.org/current/userguide/custom_plugins.html#sec:mapping_extension_properties_to_task_properties[check out Gradle's docs].
77

88
== Tasks
@@ -37,7 +37,7 @@ compileJava.dependsOn tasks.openApiGenerate
3737
```
3838
====
3939

40-
All extensions can be rewritten as tasks. Where you can have only a single extension defined in your gradle file, you may have multiple tasks.
40+
All extensions can be rewritten as tasks. Where you can have only a single extension defined in your Gradle file, you may have multiple tasks.
4141

4242
.One Extension, multiple tasks
4343
[source,groovy]
Lines changed: 100 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,56 @@
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")
2418

25-
group 'org.openapitools'
26-
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION
27-
version "$openApiGeneratorVersion"
2819
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.
3021
3122
This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x
3223
specifications as part of your build. Other tasks are available as command line tasks.
3324
"""
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"
4325

44-
sourceCompatibility = 1.8
45-
targetCompatibility = 1.8
26+
java {
27+
withSourcesJar()
28+
withJavadocJar()
29+
sourceCompatibility = 1.8
30+
targetCompatibility = 1.8
31+
}
4632

4733
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()
5335
maven {
36+
name = "Sonatype Snapshots"
5437
url "https://oss.sonatype.org/content/repositories/snapshots/"
5538
}
56-
jcenter()
5739
}
5840

5941
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")
6944
}
7045

71-
test {
46+
tasks.named("test", Test).configure {
7247
useTestNG()
73-
testClassesDirs = files(project.tasks.compileTestKotlin.destinationDir)
7448
testLogging.showStandardStreams = false
7549

7650
beforeTest { descriptor ->
7751
logger.lifecycle("Running test: " + descriptor)
7852
}
7953

80-
failFast = true
81-
8254
onOutput { descriptor, event ->
8355
// SLF4J may complain about multiple bindings depending on how this is run.
8456
// This is just a warning, but can make test output less readable. So we ignore it specifically.
@@ -88,133 +60,105 @@ test {
8860
}
8961
}
9062

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+
}
10367
}
10468

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)
14472
}
14573
}
14674

147-
nexusStaging {
148-
username = project.properties["ossrhUsername"]
149-
password = project.properties["ossrhPassword"]
75+
tasks.withType(CloseNexusStagingRepository).configureEach {
76+
onlyIf { nexusPublishing.useStaging.get() }
15077
}
15178

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() }
15581
}
15682

15783
gradlePlugin {
84+
website = "https://openapi-generator.tech/"
85+
vcsUrl = "https://github.com/OpenAPITools/openapi-generator"
15886
plugins {
15987
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")
16293
}
16394
}
16495
}
16596

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"]
171102

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"
180105
}
181106
}
182107
}
183108

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:
186111
// ./gradlew -Psigning.keyId=yourid
187112
// or stored as key=value pairs in ~/.gradle/gradle.properties
188113
// You can also apply them in CI via environment variables. See Gradle's docs for details.
189114
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)
203117
}
204118

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")
208124
}
209-
}
210125

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+
}
217163
}
218164
}
219-
220-
publishToNexus.dependsOn 'check'
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)