Skip to content

Commit

Permalink
Open up SonatypeHost (#504)
Browse files Browse the repository at this point in the history
fixes #503
  • Loading branch information
yschimke committed Jan 27, 2023
1 parent 9300a2b commit f041faa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ abstract class MavenPublishBaseExtension(
project.tasks.registerDropRepository(buildService)
}

@JvmOverloads
@JvmSynthetic
fun publishToMavenCentral(host: String, automaticRelease: Boolean = false) {
publishToMavenCentral(SonatypeHost.valueOf(host), automaticRelease)
}

/**
* Automatically apply Gradle's `signing` plugin and configure all publications to be signed. If signing credentials
* are not configured this will fail the build unless the current version is a `SNAPSHOT`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.vanniktech.maven.publish

import java.io.Serializable
import org.gradle.api.provider.Provider

/**
Expand All @@ -8,12 +9,9 @@ import org.gradle.api.provider.Provider
*
* https://central.sonatype.org/articles/2021/Feb/23/new-users-on-s01osssonatypeorg/
*/
enum class SonatypeHost(
data class SonatypeHost(
internal val rootUrl: String
) {
DEFAULT("https://oss.sonatype.org"),
S01("https://s01.oss.sonatype.org");

) : Serializable {
internal fun apiBaseUrl(): String {
return "$rootUrl/service/local/"
}
Expand All @@ -28,4 +26,19 @@ enum class SonatypeHost(
"$rootUrl/service/local/staging/deployByRepositoryId/${stagingRepositoryId.get()}/"
}
}

companion object {
@JvmStatic
fun valueOf(sonatypeHost: String): SonatypeHost = when (sonatypeHost) {
"DEFAULT" -> DEFAULT
"S01" -> S01
else -> throw IllegalArgumentException("No SonatypeHost constant $sonatypeHost")
}

@JvmField
val DEFAULT = SonatypeHost("https://oss.sonatype.org")

@JvmField
val S01 = SonatypeHost("https://s01.oss.sonatype.org")
}
}

0 comments on commit f041faa

Please sign in to comment.