https://kotlinlang.org logo
#gradle
Title
# gradle
p

Pablichjenkov

02/21/2023, 3:44 AM
Using the maven-publish plugin, is there a way to get the http response code when the plugin tries to post the artifact. I notice when an artifact with the same version is posted Nexus ignores the update which is expected. But I would like to let the person that trigger the release that the version already exists and they forgot to increase the number. This is for the case of a manual release and not an automatic release based on commit count or auto incremental counter.
I was thinking of keeping a file in a remote server or in the code itself, that tracks the releases mapped to commit count. Or perhaps getting the latest version from Nexus using the rest API. In the second case, is there any Gradle kotlin/groovy code source someone could point at, I browsed the internet with no luck.
v

Vampire

02/21/2023, 9:36 AM
For similar things I have a task that downloads the open api spec from Nexus, sends it through the open api generator Gradle plugin, and then use that, but that might be overkill. Especially just to check the latest version, you can simply use the Gradle resolution engine. Just create a detached configuration, depend on the coordinates using
+
as version or
latest.integration
, then resolve it and look at the resolution result to extract the version. Having said that, maybe you should change the Nexus configuration? I would not expect publish calls to be ignored, but either overwriting the existing version if allowed in configuration or fail the publication. And afair the latter should be the default.
p

Pablichjenkov

02/21/2023, 3:47 PM
I will take a look into the version resolution alternative, see if I can update a local property or a local file before running the publishing task. In regards to the Nexus repo behavior, I am basing my assumption by checking the updated date in their web portal, and it doesn't change when I trigger a publish with the same version. I will recheck, perhaps is a bug in their portal, but in any case, I really prefer this behavior. I had bitter experiences with artifact overwrite in the past. I prefer immutable artifacts per version.
v

Vampire

02/21/2023, 3:51 PM
Yes, but it should fail if you try to publish again and not silently discard it
p

Pablichjenkov

02/21/2023, 6:47 PM
That's right
19 Views