vanniktech / gradle-maven-publish-plugin

A Gradle plugin that publishes your Android and Kotlin libraries, including sources and javadoc, to Maven Central or any other Nexus instance.
https://vanniktech.github.io/gradle-maven-publish-plugin
Apache License 2.0
1.3k stars 119 forks source link

Allow extending `SonatypeHost` #833

Closed vRallev closed 1 month ago

vRallev commented 2 months ago

SonatypeHost is data class to hold two primitive properties. It defines built-in defaults for known hosts, but doesn't expose the constructor or a factory method to create new ones and throws an exception instead.

I'm asking adding a factory method or making the constructor public. Sonatype provides custom domains for organizations, e.g. AWS uses aws.oss.sonatype.org. Without changing the host we cannot publish our artifacts through this plugin.

As a workaround I copied the existing source file into buildSrc, modified it my needs and then publishing just worked fine.

gabrielittner commented 2 months ago

SonatypeHost has a public single argument costructor that takes the url for a host. That's what Google is using for their Sonatype instance https://github.com/google/horologist/blob/8ce20e41a98507d5cbe20f4efb512412954af762/build.gradle.kts#L86

vRallev commented 2 months ago

I don't know how, but I missed that line. It would be great if SONATYPE_HOST in gradle.properties would support that or maybe a different parameter SONATYPE_ROOT_URL. But I also understand that this request is rare and you don't want to support that.

Feel free to close the issue.

gabrielittner commented 2 months ago

We could do something simple like if the value of SONATYPE_HOST starts with https we accept it and call that constructor

vRallev commented 2 months ago

That would be neat and remove boilerplate in our build files. The setup through the properties files is convenient.