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

Support publishing using Ivy #222

Merged
merged 38 commits into from
Jun 1, 2023

Conversation

maczikasz
Copy link
Contributor

@maczikasz maczikasz commented May 24, 2023

This PR is aimed to support publishing to sonatype nexus using IvyPublication

The change adds extra configuration options for ivy and hooks into ivy-publish as well as maven-publish to create the required tasks for pushing to sonatype

The compat tests are ran for both publish plugin typesm only duplicated where the artifact patterns are different for the assertions

There are 2 end to end test repositories that are currently hosted under my github, these could be moved over to any of the maintainer's github

Readme is also updated

This PR builds on the initial work of @marcphilipp

marcphilipp and others added 11 commits May 22, 2023 14:46
Ivy publications are used when the layout of the deployed artifacts
needs to be customized, e.g. when publishing Sbt plugins.
Add a fallback url for the early url check inside IvyPublishingPlugin
Add a the proper task ids for the nexus plugin to depend on for ivy publishing as well
Change publication types to be a single property instead of a set
Move the already existing tests to a BaseNexusPublishPluginTests and move all Ivy/Maven specific test to aptly named test classes
@maczikasz
Copy link
Contributor Author

Removed some accidental reformats

README.md Outdated Show resolved Hide resolved
.gitmodules Outdated Show resolved Hide resolved
maczikasz and others added 3 commits May 24, 2023 13:53
Co-authored-by: Marc Philipp <marc@gradle.com>
UrlArtifactRepository was only introduced in gradle 5.1 and gradle modules are not uploaded in gradle 5
It makes more sense to have these properties configured on an individual repository level rather than at the plugin level
This will allow the configuration of repositories with different publication types and repository layouts, mimics the original gradle configuration more closely
Copy link
Contributor

@szpak szpak left a comment

Choose a reason for hiding this comment

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

Just a few details, but in general it looks good.

@maczikasz
Copy link
Contributor Author

@szpak There are some new changes that we discussed with @marcphilipp

Moving publicationType and ivyRepositoryPattern to the NexusRepository level instead of the extension level

Move commits that were pushed to the incorrect repo
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@szpak
Copy link
Contributor

szpak commented May 31, 2023

It seems to be ready. Thanks @maczikasz for your contribution!

I need some time to review the other 2.0.0 candidates, but I will try to merge & release it "soon".

@szpak
Copy link
Contributor

szpak commented May 31, 2023

Btw, do you guys have anything in mind which could/should be done before 2.0.0 (as a breaking change, in addition to dropping "build support" for <JDK 11)?

@maczikasz
Copy link
Contributor Author

It seems to be ready. Thanks @maczikasz for your contribution!

I need some time to review the other 2.0.0 candidates, but I will try to merge & release it "soon".

Thanks for reviewing. If you merge and maybe will there be a snapshot or pre-release version that we could use before release? We have time to wait for the release before needing this in our side for production, but would be really cool to try it out before

Copy link
Contributor

@szpak szpak left a comment

Choose a reason for hiding this comment

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

I moved your changes to the other branch and tested e2e. I had to do some minor adjustments (1, 2) in e2e projects, but it the end, all of them passed: https://github.com/gradle-nexus/publish-plugin/actions/runs/5149777155/jobs/9273194799

I also forked them in the gradle-nexus group to make a possibility to push the changes (however, I still plan to test the "e2e projects inline in the main repo" idea). Of course, extracting the core e2e logic still holds true :-).

@szpak szpak added this pull request to the merge queue Jun 1, 2023
Merged via the queue into gradle-nexus:master with commit 1d122e1 Jun 1, 2023
@szpak
Copy link
Contributor

szpak commented Jun 1, 2023

If you merge and maybe will there be a snapshot or pre-release version that we could use before release?

Sure, I just have to merge some long awaiting PRs and it takes time due to the CI builds. Probably I could merge them locally to on another branch to merge it at once.

@szpak
Copy link
Contributor

szpak commented Jun 2, 2023

If you merge and maybe will there be a snapshot or pre-release version that we could use before release? We have time to wait for the release before needing this in our side for production, but would be really cool to try it out before

@maczikasz It's quite harder than I initially thought :-/. I completely forgot that in this project there is no publishing to Maven Central configured and I cannot send snapshots there. Is it possible to release a snapshot version of the plugin to plugins.gradle.org? Or you had anything else in mind (e.g. publishing 2.0.0-rc1 as a regular version)?

@TWiStErRob
Copy link
Collaborator

This works on Gradle 8.2-milestone-1, but breaks on 8.2-rc-1:
https://github.com/gradle-nexus/publish-plugin/actions/runs/5162790263/jobs/9300726822#step:5:80

@TWiStErRob
Copy link
Collaborator

@szpak others do publish rcs like that: https://plugins.gradle.org/plugin/org.ajoberstar.stutter, even Gradle itself https://plugins.gradle.org/plugin/com.gradle.plugin-publish

@szpak szpak added this to the 2.0.0 milestone Jun 4, 2023
@szpak
Copy link
Contributor

szpak commented Jun 4, 2023

This works on Gradle 8.2-milestone-1, but breaks on 8.2-rc-1: https://github.com/gradle-nexus/publish-plugin/actions/runs/5162790263/jobs/9300726822#step:5:80

Good catch, thanks @TWiStErRob . It seems to be an another issue with the new tests for Ivy. I added build scan to that workflow and the reported error is not something that I expected :-/

> Task :initializeMyNexusStagingRepository	
Created staging repository 'orgexample-42' at http://localhost:46845/repositories/orgexample-42/content/	
	
> Task :publishIvyCustomPublicationToMyNexusRepository FAILED	
	
FAILURE: Build failed with an exception.	
	
* What went wrong:	
Execution failed for task ':publishIvyCustomPublicationToMyNexusRepository'.	
> Failed to publish publication 'ivyCustom' to repository 'myNexus'	
   > Could not PUT 'http://localhost:46845/org/example/sample/0.0.1/sample-0.0.1.jar'. Received status code 404 from server: Not Found

@maczikasz Could there be any general regressions in the recent code in master?

@TWiStErRob
Copy link
Collaborator

Note: there's one mention of Ivy in the release notes, however that issue was also included in milestone-1's release notes. Ref https://docs.gradle.org/8.2-rc-1/release-notes.html

@maczikasz
Copy link
Contributor Author

maczikasz commented Jun 7, 2023

Sorry guys for missing the notifications checking now the failures

@szpak
Copy link
Contributor

szpak commented Jun 7, 2023

@maczikasz
Copy link
Contributor Author

thanks @szpak

Yes, I know what the issue is, it seems that the url is cached in the DefaultIvyArtifactRepository and since we are setting a lazy provider the first value that returns is used. We create the staging repos at a later task hence the staging repo url is never used to publish the artifacts.

I raised it internally, I have managed to do a very (VERY) hacky solutions to get the test green, but I need a better way, and also to understand if this is intended or not

@szpak
Copy link
Contributor

szpak commented Jun 8, 2023

@maczikasz To give you a chance to test the Ivy functionality in a real usage, I've just released 2.0.0-rc-1 to the portal. We still plan some minor changes (and maybe in the meantime you will find a less hacky solution for the url issue ;-) ), but please let us know, if it works for you at all.

@maczikasz
Copy link
Contributor Author

@szpak I have finished testing the ivy publication with 2.0.0.-rc-1 and everything seems to work as expected, I have managed to release things to sonatype and use it subsequently. Thanks a lot for your support on this

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

Successfully merging this pull request may close these issues.

4 participants