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

closeRepository task run before publishing all subprojects #157

Closed
ihostage opened this issue Mar 4, 2020 · 8 comments
Closed

closeRepository task run before publishing all subprojects #157

ihostage opened this issue Mar 4, 2020 · 8 comments

Comments

@ihostage
Copy link

ihostage commented Mar 4, 2020

Given

  1. Gradle 6.2.1
  2. id("io.codearte.nexus-staging") version "0.21.2"
    id("de.marcphilipp.nexus-publish") version "0.4.0"
  3. MultiModule project

Reproducing

  1. Clone repository https://github.com/taymyr/lagom-openapi and checkout to branch nexus_plugins
  2. Remove -SNAPSHOT from version in /build.gradle.kts
  3. Change packageGroup for your.
  4. Run build by command ./gradlew clean publishToSonatype closeRepository -x test
$ ./gradlew clean publishToSonatype closeRepository -x test
> Task :lagom-openapi-core:dokka
> Task :scala:lagom-openapi-scala-impl:compileScala
> Task :scala:lagom-openapi-scala-api:scaladoc
> Task :scala:lagom-openapi-scala-impl:compileScala
> Task :scala:lagom-openapi-scala-impl:scaladoc
> Task :closeRepository
Requested operation was executed successfully in attempt 6 (maximum allowed 361)
> Task :scala:lagom-openapi-scala-impl:publishMavenPublicationToSonatypeRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':scala:lagom-openapi-scala-impl:publishMavenPublicationToSonatypeRepository'.
> Failed to publish publication 'maven' to repository 'sonatype'
   > Could not PUT 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/orgtaymyr-1085/org/taymyr/lagom/lagom-openapi-scala-impl_2.13/1.2.0/lagom-openapi-scala-impl_2.13-1.2.0.jar'. Received status code 400 from server: Bad Request

BUILD FAILED in 6m 16s
61 actionable tasks: 60 executed, 1 up-to-date

Dry Run

Dry run log is correct and closeRepository task is latest.

$ ./gradlew clean publishToSonatype closeRepository --dry-run -x test
:clean SKIPPED
:lagom-openapi-core:clean SKIPPED
:java:lagom-openapi-java-api:clean SKIPPED
:java:lagom-openapi-java-impl:clean SKIPPED
:scala:lagom-openapi-scala-api:clean SKIPPED
:scala:lagom-openapi-scala-impl:clean SKIPPED
:java:publishToSonatype SKIPPED
:lagom-openapi-core:dokka SKIPPED
:lagom-openapi-core:dokkaJar SKIPPED
:lagom-openapi-core:compileKotlin SKIPPED
:lagom-openapi-core:compileJava SKIPPED
:lagom-openapi-core:processResources SKIPPED
:lagom-openapi-core:classes SKIPPED
:lagom-openapi-core:inspectClassesForKotlinIC SKIPPED
:lagom-openapi-core:jar SKIPPED
:lagom-openapi-core:generateMetadataFileForMavenPublication SKIPPED
:lagom-openapi-core:generatePomFileForMavenPublication SKIPPED
:lagom-openapi-core:initializeSonatypeStagingRepository SKIPPED
:lagom-openapi-core:sourcesJar SKIPPED
:lagom-openapi-core:signMavenPublication SKIPPED
:lagom-openapi-core:publishMavenPublicationToSonatypeRepository SKIPPED
:lagom-openapi-core:publishToSonatype SKIPPED
:scala:publishToSonatype SKIPPED
:java:lagom-openapi-java-api:dokka SKIPPED
:java:lagom-openapi-java-api:dokkaJar SKIPPED
:java:lagom-openapi-java-api:compileKotlin SKIPPED
:java:lagom-openapi-java-api:compileJava SKIPPED
:java:lagom-openapi-java-api:processResources SKIPPED
:java:lagom-openapi-java-api:classes SKIPPED
:java:lagom-openapi-java-api:inspectClassesForKotlinIC SKIPPED
:java:lagom-openapi-java-api:jar SKIPPED
:java:lagom-openapi-java-api:generateMetadataFileForMavenPublication SKIPPED
:java:lagom-openapi-java-api:generatePomFileForMavenPublication SKIPPED
:java:lagom-openapi-java-api:initializeSonatypeStagingRepository SKIPPED
:java:lagom-openapi-java-api:sourcesJar SKIPPED
:java:lagom-openapi-java-api:signMavenPublication SKIPPED
:java:lagom-openapi-java-api:publishMavenPublicationToSonatypeRepository SKIPPED
:java:lagom-openapi-java-api:publishToSonatype SKIPPED
:java:lagom-openapi-java-impl:dokka SKIPPED
:java:lagom-openapi-java-impl:dokkaJar SKIPPED
:java:lagom-openapi-java-impl:compileKotlin SKIPPED
:java:lagom-openapi-java-impl:generateLombokConfig SKIPPED
:java:lagom-openapi-java-impl:compileJava SKIPPED
:java:lagom-openapi-java-impl:processResources SKIPPED
:java:lagom-openapi-java-impl:classes SKIPPED
:java:lagom-openapi-java-impl:inspectClassesForKotlinIC SKIPPED
:java:lagom-openapi-java-impl:jar SKIPPED
:java:lagom-openapi-java-impl:generateMetadataFileForMavenPublication SKIPPED
:java:lagom-openapi-java-impl:generatePomFileForMavenPublication SKIPPED
:java:lagom-openapi-java-impl:initializeSonatypeStagingRepository SKIPPED
:java:lagom-openapi-java-impl:sourcesJar SKIPPED
:java:lagom-openapi-java-impl:signMavenPublication SKIPPED
:java:lagom-openapi-java-impl:publishMavenPublicationToSonatypeRepository SKIPPED
:java:lagom-openapi-java-impl:publishToSonatype SKIPPED
:scala:lagom-openapi-scala-api:compileJava SKIPPED
:scala:lagom-openapi-scala-api:compileScala SKIPPED
:scala:lagom-openapi-scala-api:processResources SKIPPED
:scala:lagom-openapi-scala-api:classes SKIPPED
:scala:lagom-openapi-scala-api:jar SKIPPED
:scala:lagom-openapi-scala-api:generateMetadataFileForMavenPublication SKIPPED
:scala:lagom-openapi-scala-api:generatePomFileForMavenPublication SKIPPED
:scala:lagom-openapi-scala-api:initializeSonatypeStagingRepository SKIPPED
:scala:lagom-openapi-scala-api:scaladoc SKIPPED
:scala:lagom-openapi-scala-api:scalaDocJar SKIPPED
:scala:lagom-openapi-scala-api:sourcesJar SKIPPED
:scala:lagom-openapi-scala-api:signMavenPublication SKIPPED
:scala:lagom-openapi-scala-api:publishMavenPublicationToSonatypeRepository SKIPPED
:scala:lagom-openapi-scala-api:publishToSonatype SKIPPED
:scala:lagom-openapi-scala-impl:compileJava SKIPPED
:scala:lagom-openapi-scala-impl:compileScala SKIPPED
:scala:lagom-openapi-scala-impl:processResources SKIPPED
:scala:lagom-openapi-scala-impl:classes SKIPPED
:scala:lagom-openapi-scala-impl:jar SKIPPED
:scala:lagom-openapi-scala-impl:generateMetadataFileForMavenPublication SKIPPED
:scala:lagom-openapi-scala-impl:generatePomFileForMavenPublication SKIPPED
:scala:lagom-openapi-scala-impl:initializeSonatypeStagingRepository SKIPPED
:scala:lagom-openapi-scala-impl:scaladoc SKIPPED
:scala:lagom-openapi-scala-impl:scalaDocJar SKIPPED
:scala:lagom-openapi-scala-impl:sourcesJar SKIPPED
:scala:lagom-openapi-scala-impl:signMavenPublication SKIPPED
:scala:lagom-openapi-scala-impl:publishMavenPublicationToSonatypeRepository SKIPPED
:scala:lagom-openapi-scala-impl:publishToSonatype SKIPPED
:closeRepository SKIPPED
@szpak
Copy link
Member

szpak commented Mar 5, 2020

closeRepository and releaseRepository was originally created as independent tasks to close and release a staging repository. The files could be uploaded in a separate Gradle execution (or in any other way) to create a staging repository which later on would need to be closed (and released).

The usage with nexus-publish improved reliability, but also tighten GNSP's tasks with the publishing process (unless you pass the repository ID from the command line). Most likely, it would be useful to add shouldRunAfter with all the Upload and Publish tasks. Probably, with the way to disable it on demand.

In the meantime, you may want to add it manually in your project.

@ihostage
Copy link
Author

ihostage commented Mar 12, 2020

@szpak You are absolutely right 👍 And, of course, the next configuration helped me.

tasks.closeRepository {
    mustRunAfter(subprojects.map { it.tasks.getByName("publishToSonatype") }.toTypedArray())
}

But I thought, that this configuration of tasks ordering already implemented in the plugin 😄

@szpak
Copy link
Member

szpak commented Mar 12, 2020

@vlsi You have dependsOn which may be ok for your case, but shouldRunAfter gives an option to still run close or release tasks separately, e.g. if the closing task failed due to timeout and release has to be performed separately (as an emergency operation).

@vlsi
Copy link

vlsi commented Mar 12, 2020

if the closing task failed due to timeout

If it failed due to timeout, then in 99.84% of the cases it means the operation is in progress at the Nexus side. No retry is required in that case.

In extreme cases, there always is an option to open Nexus UI and release the repository.

Note: closeRepository task itself can't figure out the repository id (yet?) which makes it very very hard to use in isolation.

@szpak
Copy link
Member

szpak commented Mar 12, 2020

No retry is required in that case.

Sure, that's why I mentioned close. Usually after some time you can call release.

Note: closeRepository task itself can't figure out the repository id (yet?) which makes it very very hard to use in isolation.

If you have just one, it's not a problem. With the new plugin there is an option to specify the ID.

@szpak
Copy link
Member

szpak commented Feb 26, 2021

TL;TD. This case is already improved in gradle-nexus-publish-plugin.

A longer version. To make releasing to Maven Central even easier, I and Marc Phillip (the author of nexus-publish-plugin) combined forces to create a next generation, unified, 2-in-1 plugin - gradle-nexus-publish-plugin. It is a recommended solution, as our development effort will be put in that new plugin. See my blog post and the official migration guide.

@szpak szpak closed this as completed Feb 26, 2021
@ihostage
Copy link
Author

Thank you @szpak! One repo we already migrated to GNPP 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants