Skip to content
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

[gradle] Reworking publishing pipeline #2886

Merged
merged 6 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the 4.0.1 release fails, we may consider reverting to the uploadArchives and maven publishing plugin.

./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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to see how this goes, but I guess that calling the task closeAndReleaseRepository would also be necessary. (the maven nexus plugin is doing something like this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the SNAPSHOT path (master), but your comment made me realize that I had completely missed updating the uploadArchives in the following conditional block which is used for releases. I believe the releases branch is the only one that requires closing.

popd;
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
mvn clean deploy --settings CI/settings.xml;
Expand Down
135 changes: 56 additions & 79 deletions modules/openapi-generator-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.2.60'
ext.kotlin_version = '1.2.61'
repositories {
mavenCentral()
maven {
Expand All @@ -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"
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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:/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 = "[email protected]"
}
}
scm {
url = 'https:/OpenAPITools/openapi-generator'
connection = 'scm:git:git:/OpenAPITools/openapi-generator.git'
developerConnection = 'scm:git:ssh://[email protected]:OpenAPITools/openapi-generator.git'
}
issueManagement {
system = 'GitHub'
url = 'https:/OpenAPITools/openapi-generator/issues'
}
}
}
}
}

nexusPublishing {
username = ossrhUsername
password = ossrhPassword
stagingProfileId = "org.openapitools"
packageGroup = "org.openapitools"
}

gradlePlugin {
plugins {
openApiGenerator {
Expand All @@ -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"
}
}
}
Expand All @@ -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:/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 "[email protected]"
}
}
scm {
url 'https:/OpenAPITools/openapi-generator'
connection 'scm:git:git:/OpenAPITools/openapi-generator.git'
developerConnection 'scm:git:ssh://[email protected]:OpenAPITools/openapi-generator.git'
}
issueManagement {
system 'GitHub'
url 'https:/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 {
Expand All @@ -205,4 +182,4 @@ compileTestKotlin {
}
}

uploadArchives.dependsOn 'check'
publishToNexus.dependsOn 'check'
1 change: 1 addition & 0 deletions modules/openapi-generator-gradle-plugin/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
rootProject.name = 'openapi-generator-gradle-plugin'
enableFeaturePreview('STABLE_PUBLISHING')