Open ThomasJejkal opened 3 years ago
Did you create the repository?
nexusPublishing {
repositories {
sonatype()
}
}
Sure, I've added the following elements:
buildscript {
[...]
dependencies {
classpath("io.github.gradle-nexus:publish-plugin:1.0.0")
}
}
[...]
apply plugin: 'io.github.gradle-nexus.publish-plugin'
[...]
nexusPublishing {
repositories {
sonatype()
}
}
Furthermore, I've added 'sonatypeUsername' and 'sonatypePassword' into ~/.gradle/gradle.properties. What else do I need?
I'm just wondering, if I call
./gradlew.bat tasks
I only see the following elements in the 'Publishing tasks' section:
Publishing tasks
----------------
closeAndReleaseSonatypeStagingRepository - Closes and releases open staging repository in 'sonatype' Nexus instance.
closeAndReleaseStagingRepository - Closes and releases open staging repositories in the following Nexus instance: 'sonatype'
closeSonatypeStagingRepository - Closes open staging repository in 'sonatype' Nexus instance.
releaseSonatypeStagingRepository - Releases closed staging repository in 'sonatype' Nexus instance.
There is no task 'publishToSonatype' listed anywhere.
Have you defined any publications?
No, as no one asked me to do so. ;-)
I've added the publications section and I'm now ending up at a point, where the task wants to deploy to the snapshots repository and fails with HTTP 400. Are there any hints why a) it goes to the snapshots repository and b) why this fails?
It would be really great to have a working example on how to use the plugin as there seem to be some additional prerequisites which are not mentioned in the README. Many thanks in advance.
@ThomasJejkal It's not official, but you can take a look at the minimal project used in the e2e tests ran on CI: https://github.com/gradle-nexus/nexus-publish-e2e-minimal/blob/master/build.gradle
@ThomasJejkal I agree that a full example would be helpful and we should add that.
If it goes to the snapshots repository and you haven't changed the useStaging
property, that means your version ends with -SNAPSHOT
, does it? Does your project's group
match the "Repo Target" in your staging profile? Have you set stagingProfileId
on nexusPublishing.repositories.sonatype
or packageGroup
on nexusPublishing
?
I think I see the point. I was trying to integrate the publishing into a GitHub action and skipped the release plugin as it was not clear to me what is covered by this plugin here. On Monday I will try to implement the whole release workflow and report back in both cases, if it works and of course also if it doesn't work. ;-)
Thanks a lot for you help so far.
@ThomasJejkal Feel free to propose a README improvement to make it more obvious about the publishing plugin.
I've finally managed to perform a complete publication process, thanks again for your support. At the end there were a couple of open points I had to cope with and I'm not sure if some of them might be obvious for others, who are more familiar with publishing to Sonatype than I was, and if some of them fit into the scope of your project.
One issue, where your minimal example helped a lot, was the fact, that Sonatype requires some attributes to be present in the pom. I guess mentioning this in the README could help others.
The second (a lot more frustrating) issue was related to the fact, that I want to integrate the publishing into a GitHub action. Thus, I had to find a way to deal with signing using credentials from environment variables. Here I'm not sure if you want to overload your README with information that might be not relevant for the majority of your users.
If you are interested, I could try to provide a sample project including a README covering the two scenarios: publication from local machine and from GitHub including additional steps that have to be carried out, e.g. tagging, release and defining/triggering a GitHub Action.
If you are interested, I could try to provide a sample project including a README covering the two scenarios.
@ThomasJejkal That would be great. Let's start with the first, GitHub-agnostic, scenario, shall we?
hey @ThomasJejkal i would be highly interested in the full example as well. especially the publish via github actions scenario :)
As promised, I've created a sample project describing the required steps in order to publish in both ways: from your local machine as well as via GitHub Action.
If you are interested, check out the nexus-publish-example.
If there are any problems or questions, feel free to contact me.
I have this exact issue trying to use the plugin on the Hibernate Reactive project: https://github.com/DavideD/hibernate-reactive/tree/687-release
I've added the nexusPublishing and I also have a publishing. When I try to call the task I have Task 'publishToSonatype' not found in root project 'hibernate-reactive'
. But I can see all the other tasks in the tasks list. I also have a warning when I import the project in Intellij that sonatype
in the repositories is not recognized. Am I missing something?
Nevermind, it seems I've solved this issue and found where I can add it to my project.
@DavideD how did you solve this?
What I'm realizing is that nexusPublishing
needs to be defined in the root project, and therefore it is also looking for group
and version
in the root project. This is causing a lot of disruption in my Android project.
I've put it in the root of the project. You can see it here: https://github.com/hibernate/hibernate-reactive/blob/021cd601f6e0d25bc552446f1f4c0c102a153b5e/build.gradle#L99
And I've defined the version and group in the root and in the subprojects.
@DavideD Thanks. By the way, there is logically no group or version in my root project.
Today, I found this plugin and I was hoping to get rid of these manual steps while releasing artifacts. Unfortunately, I did not manage to get the plugin running, yet.
I guess I did everything written in the README, but I'm still ending up at a message telling me
while trying to call
Am I missing something? Thanks for your support.