@@ -21,6 +21,7 @@ plugins {
2121 id ' com.github.johnrengelman.shadow' version ' 8.1.1'
2222 id ' org.sonarqube' version ' 5.1.0.4882'
2323 id ' team.yi.semantic-gitlog' version ' 0.6.12'
24+ id ' io.github.gradle-nexus.publish-plugin' version ' 2.0.0'
2425}
2526
2627import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
@@ -194,7 +195,33 @@ apply from: 'gradle/release.gradle'
194195apply from : ' gradle/staticCodeCheck.gradle'
195196apply from : ' gradle/changelog.gradle'
196197
197- // ############ Annotation Processing
198+ // See: https://github.com/gradle-nexus/publish-plugin
199+ nexusPublishing {
200+ repositories {
201+ sonatype {
202+ // Align with the URLs used in gradle/publishing.gradle
203+ nexusUrl. set(uri(' https://ossrh-staging-api.central.sonatype.com/service/local/' ))
204+ snapshotRepositoryUrl. set(uri(' https://central.sonatype.com/repository/maven-snapshots/' ))
205+ username. set(findProperty(' mavenCentralUsername' )?. toString())
206+ password. set(findProperty(' mavenCentralPassword' )?. toString())
207+ }
208+ }
209+ }
210+
211+ tasks. register(' publishReleaseToMavenCentral' ) {
212+ group = ' publishing'
213+ description = ' Publish a release build to Sonatype and close+release the staging repository (Maven Central).'
214+
215+ doLast {
216+ if (String . valueOf(project. version). endsWith(' -SNAPSHOT' )) {
217+ throw new GradleException (' publishReleaseToMavenCentral must be run with a non-SNAPSHOT version' )
218+ }
219+ }
220+ }
221+
222+ publishReleaseToMavenCentral. dependsOn(' publishToSonatype' )
223+ publishReleaseToMavenCentral. dependsOn(' closeAndReleaseSonatypeStagingRepository' )
224+
198225
199226task annotationProcessing (type : JavaCompile , group : ' build' ) {
200227 options. annotationProcessorPath = configurations. annotationProcessor
0 commit comments