diff --git a/.travis.yml b/.travis.yml index 32cc18325a4a..88fc97509b86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -136,8 +136,8 @@ 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}" uploadArchives --no-daemon; - echo "Finished ./gradlew uploadArchives"; + ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository --no-daemon; + echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository"; popd; elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then mvn clean deploy --settings CI/settings.xml; diff --git a/modules/openapi-generator-gradle-plugin/build.gradle b/modules/openapi-generator-gradle-plugin/build.gradle index 346deef7c4b6..3aa20c67236b 100644 --- a/modules/openapi-generator-gradle-plugin/build.gradle +++ b/modules/openapi-generator-gradle-plugin/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.2.60' + ext.kotlin_version = '1.2.61' repositories { mavenCentral() maven { @@ -11,14 +11,13 @@ buildscript { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { - url "https://plugins.gradle.org/m2/" - } } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:1.0-rc-3" classpath "com.gradle.publish:plugin-publish-plugin:0.10.1" + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0" + classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.2.0" } } @@ -35,10 +34,11 @@ ext.isReleaseVersion = !version.endsWith("SNAPSHOT") apply plugin: 'com.gradle.plugin-publish' apply plugin: 'java-gradle-plugin' -apply plugin: 'maven' 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 @@ -87,6 +87,54 @@ test { } } + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + 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 = "http://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' + } + } + } + } +} + +nexusPublishing { + username = ossrhUsername + password = ossrhPassword + stagingProfileId = "org.openapitools" + packageGroup = "org.openapitools" +} + gradlePlugin { plugins { openApiGenerator { @@ -109,6 +157,7 @@ pluginBundle { displayName = 'OpenAPI Generator Gradle Plugin' tags = ['openapi-3.0', 'openapi-2.0', 'openapi', 'swagger', 'codegen', 'sdk'] version = "$openApiGeneratorVersion" + group = "org.openapitools" } } } @@ -119,79 +168,7 @@ pluginBundle { // 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("uploadArchives") } - sign configurations.archives -} - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} - -artifacts { - archives javadocJar, sourcesJar -} - -def pomConfig = { - description project.description - name 'OpenAPI-Generator Contributors' - 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 "http://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' - } -} - -uploadArchives { - repositories { - - // credentials here would need to be passed along with the gradle command: - // ./gradlew -P ossrhUsername=yourUser - // or stored in ~/.gradle/gradle.properties as key=value pairs - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - - pom.withXml { - def root = asNode() - root.appendNode('description', project.description) - root.children().last() + pomConfig - } - } - } + sign publishing.publications } compileKotlin { @@ -205,4 +182,4 @@ compileTestKotlin { } } -uploadArchives.dependsOn 'check' +publishToNexus.dependsOn 'check' diff --git a/modules/openapi-generator-gradle-plugin/settings.gradle b/modules/openapi-generator-gradle-plugin/settings.gradle index 563879e5d5dd..dfb2ecf250c2 100644 --- a/modules/openapi-generator-gradle-plugin/settings.gradle +++ b/modules/openapi-generator-gradle-plugin/settings.gradle @@ -1,2 +1,3 @@ rootProject.name = 'openapi-generator-gradle-plugin' +enableFeaturePreview('STABLE_PUBLISHING')