automatically close the created repository and optionally also release it #403
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will automatically close the repository that we created at the end of the build and based on a Gradle property or a parameter in the DSL also release it automatically. I think we don't need an option to control the automatic closing, each build will create a new repository anyways so there shouldn't be anything added after the fact. If there is a valid use case for it we can still make it optional later. Releasing on the other hand is a bigger step so I decided to make it opt-in. Even if you want to use it it allows for something like only enabling it on CI by setting an env var.
The closing and releasing is not done through the
closeAndReleaseRepository
task. The issue with the task is that it would need to wait for publishing in all other subprojects to finish so we would need cross project dependencies. One solution would have been the root plugin that we had before which would at least simplify it to only the root project task having to wait for all projects to finish publishing, but I also had some other issues that plugin. The solution is to trigger this from the build service. When a build service implementsAutoCloseable
Gradle will callclose
when the build service is no longer needed. ImplementingOperationCompletionListener
and registering it will make it so that we can detect that no task failed (in that case close and release is not run) and will make it so that the build service is needed for the whole build which means thatclose
is only called after the last task finished. Theclose
implementation then checks if a staging repo was created and then does the close and release operations.I'm not 100% sure yet about the future of the close and release task. For now I made a small change to the nexus code so that running it on an already close repo will simply release it instead of printing an error that it is not open. So it can be used to then release it manually if automatic releasing isn't enabled. It could also be used to manually retry closing and releasing the already created staging repo if it failed. So it probably continue existing. One future change could be making the
--release
cli parameter required though and removing automatically finding a repo. The build will print the id of the repo when creating and automatically closing it, so you always know it.