Skip to content

Commit 6267501

Browse files
committed
Add back configureNexus function
1 parent 5b7a1d1 commit 6267501

File tree

1 file changed

+37
-0
lines changed
  • build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl

1 file changed

+37
-0
lines changed

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)