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

Ability to publish to multiple profiles from same repository #658

Closed
runningcode opened this issue Nov 5, 2023 · 8 comments
Closed

Ability to publish to multiple profiles from same repository #658

runningcode opened this issue Nov 5, 2023 · 8 comments

Comments

@runningcode
Copy link

I'm converting my Gradle plugin to use gradle-maven-publish-plugin I'm currently getting the following error when attempting to publish my plugin.

> Closing the repository failed with the following errors:
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.sha512
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.asc.sha1
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.sha256
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.asc.md5
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.asc
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.md5
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.sha1
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.asc.sha256
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom
  Profile target mismatch: /com/osacky/fladle/com.osacky.fladle.gradle.plugin/0.17.5/com.osacky.fladle.gradle.plugin-0.17.5.pom.asc.sha512
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.asc
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.asc.md5
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.sha256
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.asc.sha1
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.sha512
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.asc.sha512
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.sha1
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.asc.sha256
  Profile target mismatch: /com/osacky/fulladle/com.osacky.fulladle.gradle.plugin/0.17.5/com.osacky.fulladle.gradle.plugin-0.17.5.pom.md5

I've narrowed this error down to the fact that all artifacts are being published with the same nexus profile.

This function only selects one profile for one artifact's group id.

In this case, I need the ability to publish each artifact using a different nexus profile. For example, the artifact with the groupId com.osacky.fladle artifact needs to be published using the com.osacky.fladle profile. The com.osacky.fulladle artifact needs to be published with the com.osacky.fulladle artifact.

I was wondering if you agree with the above assessment and if there is a way to configure each artifact in a single project to publish to a different profile? Thanks 🙏

@gabrielittner
Copy link
Collaborator

Your assessment is correct. We currently only support one profile per build, so it would be a new feature that we'd need to support.

One complexity which I'm not sure about right now is that we create a staging repository and then set the url of that as the repository url. If we'd need 2 separate staging repos we'd also need to create 2 repositories and then selectively only publish each artifact to one of the 2 repositories.

Could you share a screenshot of your staging profiles in the web UI? Also do you remember or could you try and check what the name of the automatically created staging repositories was before using this plugin?

@runningcode
Copy link
Author

Here's a screenshot of the staging profiles in the web UI:
image

I wasn't sure what you mean by the name of the automatically created staging repositories. Is it just what appears in the "Repository" column in the UI? No, I can't remember :(

@gabrielittner
Copy link
Collaborator

I wasn't sure what you mean by the name of the automatically created staging repositories. Is it just what appears in the "Repository" column in the UI? No, I can't remember :(

There is an extra staging repository page in the web UI where you can manually close and release created repositories. Usually those are named after the staging profile with a number suffix, like comosacky-123. I'm mostly curious whether you'd get 3 separate repositories usually, one for each staging profile that is used during publishing.

@runningcode
Copy link
Author

Yes, I usually do get 3 of them when publishing, but I cannot remember their names.

@gabrielittner
Copy link
Collaborator

That helps 👍

@runningcode
Copy link
Author

Any updates on here or any way I can help?

@gabrielittner
Copy link
Collaborator

After looking into this I think the best thing would be to check with Sonatype whether it's possible to have a staging profile that is allowed to publish all 3 groups. That would also make sense from the perspective that these 3 should be published together so it would be better if they are in the same staging repository.

Things that are theoretically possible on our side, but all not great. The core issue is that for each staging profile we have a different url to publish to.

  1. Add a way to disable the direct interactions with Sonatype. That would give you the standard behavior of 3 implicitly/automatically created staging repos. However it also takes away one of the biggest upsides of this plugin especially when publishing a Gradle plugin which by default don't thave too much to configure.
  2. We can add a repository to publishing.repositories for each staging profile and then adapt the other parts accordingly, however
    • This would still create a publishing task for each combination of publication and repository, so in your case we'd have 9 tasks but only 3 of them will actually work. We can disable the others but it's still a weird and confusing user experience.
    • It's tricky to figure out whether a group is a separate staging profile or not at configuration time. So it will be complicated to determine how many repositories we need to add.
  3. The PublishToMavenRepository does have a setter for MavenArtifactRepository so I was thinking of using that to pass a wrapper around the one we create that overrides getUrl based on the group. However the implementation of the setter casts to the internal DefaultMavenArtifactRepository so that isn't an option. As far as I can see we also can't (without internal APIs) create a repository outside of publishing.repositories to avoid the issue mentioned in 2 by just creating them and manually setting them on the created tasks.

Maybe one option could also be to request a setUrl method on PublishToMavenRepository on the Gradle side. When running with configuration cache it's creating a new repository internally at execution time anyways. It would also solve the issue that it's currently not possible to lazily set a repository url.

@gabrielittner
Copy link
Collaborator

As mentioned this is not really possible to do with what Gradle exposes for the publishing APIs. With the new Central Portal there are no publishing profiles so I'm closing this since everything will eventually move there.

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

No branches or pull requests

2 participants