This message was deleted.
# dependency-management
s
This message was deleted.
s
I see. So there is only one
MavenPublication
created and we switch between snapshot and release repositories based on project properties or the version suffix.
t
Yes, and fwiw https://github.com/gradle-nexus/publish-plugin does just that (switches target repository URL based on
-SNAPSHOT
suffix in version). If you're planning publishing to a Nexus repository (including the Central Repository through Sonatype OSS), I'd recommended it.
👍 1
r
@Satyarth Sampath For the MavenPublication, I do rely on the tag, the tag can be checkout from any branches, then apply the variants e.g dev, alpha, beta, rc https://github.com/gojek/clickstream-android/blob/main/.github/workflows/publish.yml#L3
s
Thanks Raditya! My challenge would now be to how to make this work with credentials in the maven settings file (ref). It is easier to do if I have multiple repository objects since the credentials differ for each. That’s my next task 🙂
Also incase I want separate tasks for publishing Snapshot vs publishing release, I would need to create a separate task of type
GradleBuild
and pass arguments to correctly setup snapshot versions? Is there any other way of achieving this. I would prefer not to ask devs to provide CLI args to differentiate between types of releases.
@raditya gumay qq: So what you shared is for release publications right? Is there a separate mechanism to publish snapshots?
Oh I see, Snapshots are also published via tags.
r
@Satyarth Sampath yes i do utilizing tags for all variants mas. so instead of rely on the repo-regex which can be changes or modified, utilizing tags is more scalable and convenient
or do you really want to publish snapshot based on repo regex?
s
So I’m trying to move these to separate tasks. i.e. creating separate gradle tasks for publishing snapshots and releases. For which I’d need to modify the version number by some mechanism before the maven-publish plugin’s tasks take over.
My current process was to setup a wrapper task of type https://docs.gradle.org/current/dsl/org.gradle.api.tasks.GradleBuild.html which would add the additional project property of “Snapshot” . This would then trigger the snapshot branch of the build(which will append snapshot to the version name and so on). Do you see any thing wrong in this approach?