-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Use Gradle 7.6 to build Gradle plugin #13860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
631c9a1
53fe746
8bdef7d
5350fb9
6fc3f36
ae84c6a
58f9602
55f8812
a1bd14a
927818d
06e96ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,24 +160,24 @@ after_success: | |
echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; | ||
pushd .; | ||
cd modules/openapi-generator-gradle-plugin; | ||
./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; | ||
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository"; | ||
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository; | ||
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository"; | ||
popd; | ||
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then | ||
echo "Publishing from branch $TRAVIS_BRANCH"; | ||
mvn clean deploy --settings CI/settings.xml; | ||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; | ||
pushd .; | ||
cd modules/openapi-generator-gradle-plugin; | ||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository --no-daemon; | ||
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository closeAndReleaseRepository"; | ||
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository; | ||
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseRepository"; | ||
popd; | ||
fi; | ||
if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)"; | ||
pushd .; | ||
cd modules/openapi-generator-gradle-plugin; | ||
./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; | ||
./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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @erichaagdev we're working on v6.3.0 release but Travis CI shows the following errors:
Do you know what may have caused this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Travis CI job full log: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/jobs/594874885 |
||
echo "Finished ./gradlew publishPlugins (plugin portal)"; | ||
popd; | ||
fi; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,56 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.3.30' | ||
repositories { | ||
mavenLocal() | ||
maven { url "https://repo1.maven.org/maven2" } | ||
maven { | ||
url "https://plugins.gradle.org/m2/" | ||
} | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/releases/" | ||
} | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
} | ||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.1.3" | ||
classpath "com.gradle.publish:plugin-publish-plugin:0.11.0" | ||
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0" | ||
classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.2.0" | ||
} | ||
} | ||
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 "1.0.0" | ||
id("io.github.gradle-nexus.publish-plugin") version "1.1.0" | ||
id("java-gradle-plugin") | ||
id("maven-publish") | ||
id("org.gradle.kotlin.kotlin-dsl") version "2.4.1" | ||
id("org.jetbrains.kotlin.jvm") version "1.7.10" | ||
id("signing") | ||
} | ||
|
||
group = "org.openapitools" | ||
version = "$openApiGeneratorVersion" | ||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT") | ||
|
||
group 'org.openapitools' | ||
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION | ||
version "$openApiGeneratorVersion" | ||
description = """ | ||
This plugin supports common functionality found in Open API Generator CLI as a gradle plugin. | ||
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. | ||
""" | ||
ext.isReleaseVersion = !version.endsWith("SNAPSHOT") | ||
|
||
apply plugin: 'com.gradle.plugin-publish' | ||
apply plugin: 'java-gradle-plugin' | ||
apply plugin: 'signing' | ||
apply plugin: 'kotlin' | ||
apply plugin: "org.gradle.kotlin.kotlin-dsl" | ||
apply plugin: 'io.codearte.nexus-staging' | ||
apply plugin: "de.marcphilipp.nexus-publish" | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
java { | ||
withSourcesJar() | ||
withJavadocJar() | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
wing328 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
maven { url "https://repo1.maven.org/maven2" } | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/releases/" | ||
} | ||
mavenCentral() | ||
maven { | ||
name = "Sonatype Snapshots" | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile gradleApi() | ||
// Shared OpenAPI Generator version be passed via command line arg as -PopenApiGeneratorVersion=VERSION | ||
compile "org.openapitools:openapi-generator:$openApiGeneratorVersion" | ||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" | ||
|
||
testCompile 'org.testng:testng:6.9.6', | ||
"org.jetbrains.kotlin:kotlin-test:$kotlin_version" | ||
|
||
testCompile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version" | ||
implementation("org.openapitools:openapi-generator:$openApiGeneratorVersion") | ||
testImplementation("org.jetbrains.kotlin:kotlin-test-testng:1.7.10") | ||
} | ||
|
||
test { | ||
tasks.named("test", Test).configure { | ||
useTestNG() | ||
testClassesDirs = files(project.tasks.compileTestKotlin.destinationDir) | ||
testLogging.showStandardStreams = false | ||
|
||
beforeTest { descriptor -> | ||
logger.lifecycle("Running test: " + descriptor) | ||
} | ||
|
||
failFast = true | ||
|
||
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. | ||
|
@@ -88,133 +60,105 @@ test { | |
} | ||
} | ||
|
||
task javadocJar(type: Jar) { | ||
from javadoc | ||
classifier = 'javadoc' | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
from sourceSets.main.allSource | ||
classifier = 'sources' | ||
} | ||
|
||
artifacts { | ||
archives javadocJar, sourcesJar | ||
tasks.withType(KotlinCompile).configureEach { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
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 = "[email protected]" | ||
} | ||
} | ||
scm { | ||
url = 'https://github.com/OpenAPITools/openapi-generator' | ||
connection = 'scm:git:git://github.com/OpenAPITools/openapi-generator.git' | ||
developerConnection = 'scm:git:ssh://[email protected]:OpenAPITools/openapi-generator.git' | ||
} | ||
issueManagement { | ||
system = 'GitHub' | ||
url = 'https://github.com/OpenAPITools/openapi-generator/issues' | ||
} | ||
} | ||
} | ||
tasks.withType(Javadoc).configureEach { | ||
if (JavaVersion.current().isJava9Compatible()) { | ||
options.addBooleanOption("html5", true) | ||
} | ||
} | ||
|
||
nexusStaging { | ||
username = project.properties["ossrhUsername"] | ||
password = project.properties["ossrhPassword"] | ||
tasks.withType(CloseNexusStagingRepository).configureEach { | ||
onlyIf { nexusPublishing.useStaging.get() } | ||
} | ||
|
||
nexusPublishing { | ||
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile --no-daemon | ||
stagingProfileId = "456297f829bbbe" | ||
tasks.withType(ReleaseNexusStagingRepository).configureEach { | ||
onlyIf { nexusPublishing.useStaging.get() } | ||
} | ||
|
||
gradlePlugin { | ||
website = "https://openapi-generator.tech/" | ||
vcsUrl = "https://github.com/OpenAPITools/openapi-generator" | ||
plugins { | ||
openApiGenerator { | ||
id = 'org.openapi.generator' | ||
implementationClass = 'org.openapitools.generator.gradle.plugin.OpenApiGeneratorPlugin' | ||
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") | ||
} | ||
} | ||
} | ||
|
||
pluginBundle { | ||
// These settings are set for the whole plugin bundle | ||
website = 'https://openapi-generator.tech/' | ||
vcsUrl = 'https://github.com/OpenAPITools/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)' | ||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
username = project.properties["ossrhUsername"] | ||
password = project.properties["ossrhPassword"] | ||
|
||
plugins { | ||
// first plugin | ||
openApiGenerator { | ||
id = 'org.openapi.generator' | ||
displayName = 'OpenAPI Generator Gradle Plugin' | ||
tags = ['openapi-3.0', 'openapi-2.0', 'openapi', 'swagger', 'codegen', 'sdk'] | ||
version = "$openApiGeneratorVersion" | ||
group = "org.openapitools" | ||
// To retrieve: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGNING_SECRET" getStagingProfile | ||
stagingProfileId = "456297f829bbbe" | ||
} | ||
} | ||
} | ||
|
||
// signing will require three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile. | ||
// These can be passed to the gradle command: | ||
// 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("publishPluginMavenPublicationToNexusRepository") ) } | ||
sign publishing.publications.mavenJava | ||
} | ||
|
||
compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
compileTestKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
required { isReleaseVersion && gradle.taskGraph.hasTask("publishPluginMavenPublicationToSonatypeRepository") } | ||
sign(publishing.publications) | ||
} | ||
|
||
javadoc { | ||
if(JavaVersion.current().isJava9Compatible()) { | ||
options.addBooleanOption('html5', true) | ||
// afterEvaluate is necessary because java-gradle-plugin | ||
// creates its publications in an afterEvaluate callback | ||
afterEvaluate { | ||
tasks.named("publishToSonatype").configure { | ||
dependsOn("check") | ||
} | ||
} | ||
|
||
tasks { | ||
closeRepository { | ||
onlyIf { nexusPublishing.useStaging.get() } | ||
} | ||
releaseRepository{ | ||
onlyIf { nexusPublishing.useStaging.get() } | ||
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 = "[email protected]" | ||
} | ||
} | ||
scm { | ||
url = "https://github.com/OpenAPITools/openapi-generator" | ||
connection = "scm:git:git://github.com/OpenAPITools/openapi-generator.git" | ||
developerConnection = "scm:git:ssh://[email protected]:OpenAPITools/openapi-generator.git" | ||
} | ||
issueManagement { | ||
system = "GitHub" | ||
url = "https://github.com/OpenAPITools/openapi-generator/issues" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishToNexus.dependsOn 'check' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not figure out why previously the
publishMavenJavaPublicationToNexusRepository
task was called in the firstif
condition, but thepublishPluginMavenPublicationToNexusRepository
task was called in the second. I came to the conclusion this was probably not intentional.In any case, there is no longer a
mavenJava
publication sopublishPluginMavenPublicationToSonatypeRepository
is called in both places.