Skip to content

Conversation

@alecgrieser
Copy link
Collaborator

@alecgrieser alecgrieser commented Nov 5, 2025

This replaces the usage of the nexus publishing plugin with direct calls to the sonatype central publishing API. It makes the following modifications:

  1. Each published project will write to a central staging repo if we have enabled central publishing.
  2. A new task, createMavenCentralBundle, will go through and scoop up all of the relevant files from the staging repo to produce the final bundle
  3. An additional task, publishMavenCentralBundle, will upload the bundle to the central publishing API (see: https://central.sonatype.com/api-doc and https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle)
  4. The release action now calls the new publishMavenCentralBundle task

This should allow us to retire our usage of the legacy API. Locally, I was able to validate that the bundle we get back from createMavenCentralBundle has the same layout as one generated by the JReleaser tool. Running the upload task, I was able to validate that I get an invalid token error, which is as good as I could get without giving it the proper credentials.

This resolves #3709

@alecgrieser alecgrieser added the build improvement Improvement to the build system label Nov 5, 2025
…loading URL

This replaces the usage of the nexus publishing plugin with direct calls to the sonatype central publishing API. It makes the following modifications:

1. Each published project will write to a central staging repo if we have enabled central publishing.
1. A new task, `createMavenCentralBundle`, will go through and scoop up all of the relevant files from the staging repo to produce the final bundle
1. An additional task, `publishMavenCentralBundle`, will upload the bundle to the central publishing API (see: https://central.sonatype.com/api-doc and https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle)
1. The release action now calls the new `publishMavenCentralBundle` task

This should allow us to retire our usage of the legacy API.
@alecgrieser alecgrieser changed the title Replace nexus publishing repo with direct call to central sonatype uploading URL Replace nexus publishing plugin with direct call to central sonatype uploading URL Nov 5, 2025
Copy link
Collaborator

@ScottDugas ScottDugas left a comment

Choose a reason for hiding this comment

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

Mostly comments to future proof and prevent unlikely and surprising failures

connection.setDoOutput(true)
connection.setRequestProperty('Authorization', "Bearer ${encodedCredentials}")

def boundary = "----GradleBoundary${System.currentTimeMillis()}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that we are uploading a zip, would it be worthwhile to add a uuid other this to help ensure that the zip file itself doesn't have this sequence of bytes? (at least if I understand multipart correctly)
Or would it be worthwhile to validate on our end that the string we use for the boundary is not in the file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I could see that. It may be overkill, and that is sort of what the current time millis is for. I think a UUID is probably safe enough, though we could do a search for it, I suppose

destinationDirectory = layout.buildDirectory.dir('distributions')

from(stagingRepo) {
include "${rootProject.group.replaceAll('.', '/')}/**/${project.version}/*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This means if a sub-project publishes to the staging repo, but doesn't put the results in org/foundationdb we just won't publish it, right? Probably ok, at least for the time being to not protect against that, I can't foresee us messing that up, and I think the only improvement would be to error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, though that's somewhat deliberate, as the bundle we produce is tagged with the group ID of the project, and I believe that central may actually reject our artifacts if it's in a different group

@ScottDugas ScottDugas merged commit da406a3 into FoundationDB:main Nov 5, 2025
8 checks passed
@alecgrieser alecgrieser deleted the use-curl-directly branch November 5, 2025 16:19
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this pull request Nov 5, 2025
This updates the logic in the `publishMavenCentralBundle` task so that it no longer loads the full contents of the file into memory. It does this by maintaining a buffer and then writing the contents of the buffer into the stream, which allows us to avoid materializing the full element into memory. This is to try and fix a Java heap memory error that we saw previously (see: https://github.com/FoundationDB/fdb-record-layer/actions/runs/19108664941/job/54605649248).

While I was here, I also updated the boundary for the HTTP multi-part form from the current time millis to a UUID, in response to a comment from the previous PR (FoundationDB#3723 (comment)).
alecgrieser added a commit that referenced this pull request Nov 5, 2025
This updates the logic in the `publishMavenCentralBundle` task so that
it no longer loads the full contents of the file into memory. It does
this by maintaining a buffer and then writing the contents of the buffer
into the stream, which allows us to avoid materializing the full element
into memory. This is to try and fix a Java heap memory error that we saw
previously (see:
https://github.com/FoundationDB/fdb-record-layer/actions/runs/19108664941/job/54605649248).
    
While I was here, I also updated the boundary for the HTTP multi-part
form from the current time millis to a UUID, in response to a comment
from the previous PR
(#3723 (comment)).
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this pull request Nov 6, 2025
arnaud-lacurie pushed a commit that referenced this pull request Nov 7, 2025
This reverts #3723 and #3724 and returns us back to publishing via the
nexus publishing API. The impetus for this is that the last approach got
stuck in a publishing state after the upload (see:
https://github.com/FoundationDB/fdb-record-layer/actions/runs/19117047380/job/54633288001,
which succeeded, but for which we didn't get artifacts actually
published despite the server upload succeeding).

When we are in this mode, we expect the build to fail with a 400 error
letting us know that we didn't upload anything. However, if we didn't
`close` the staging repositories (which is the step that is failing),
then legacy API would not be expected to upload anything to the central
repo. So we need to continue to do that part even though we think it
will fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build improvement Improvement to the build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move away from legacy OSSRH API for publishing

2 participants