@@ -143,6 +143,43 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
143143 }
144144}
145145
146+ /* *
147+ * Configure nexus publishing plugin. This (conditionally) enables the `gradle-nexus.publish-plugin` and configures it.
148+ */
149+ fun Project.configureNexus (
150+ nexusUrl : String = "https : // ossrh-staging-api.central.sonatype.com/service/local/",
151+ snapshotRepositoryUrl : String = "https : // central.sonatype.com/repository/maven-snapshots/",
152+ ) {
153+ verifyRootProject { " Kotlin SDK nexus configuration must be applied to the root project only" }
154+
155+ val requiredProps = listOf (SONATYPE_USERNAME_PROP , SONATYPE_PASSWORD_PROP , PUBLISH_GROUP_NAME_PROP )
156+ val doConfigure = requiredProps.all { project.hasProperty(it) }
157+ if (! doConfigure) {
158+ logger.info(" skipping nexus configuration, missing one or more required properties: $requiredProps " )
159+ return
160+ }
161+
162+ apply (plugin = " io.github.gradle-nexus.publish-plugin" )
163+ extensions.configure<NexusPublishExtension > {
164+ val publishGroupName = project.property(PUBLISH_GROUP_NAME_PROP ) as String
165+ group = publishGroupName
166+ packageGroup.set(publishGroupName)
167+ repositories {
168+ create(" awsNexus" ) {
169+ this .nexusUrl.set(uri(nexusUrl))
170+ this .snapshotRepositoryUrl.set(uri(snapshotRepositoryUrl))
171+ username.set(project.property(SONATYPE_USERNAME_PROP ) as String )
172+ password.set(project.property(SONATYPE_PASSWORD_PROP ) as String )
173+ }
174+ }
175+
176+ transitionCheckOptions {
177+ maxRetries.set(180 )
178+ delayBetween.set(Duration .ofSeconds(10 ))
179+ }
180+ }
181+ }
182+
146183/* *
147184 * Configure JReleaser publishing plugin. This (conditionally) enables the `org.jreleaser` plugin and configures it.
148185 */
0 commit comments