@@ -207,22 +207,43 @@ publishing {
207207 }
208208 }
209209 repositories {
210+ // only register maven.daporkchop.net repository if these environment variables are set
211+ val ossrhMavenUsername = (project.properties[" OSSRH_USERNAME" ] ? : System .getenv(" OSSRH_USERNAME" )) as String?
212+ val ossrhMavenPassword = (project.properties[" OSSRH_PASSWORD" ] ? : System .getenv(" OSSRH_PASSWORD" )) as String?
210213 maven {
211- name = " central "
214+ name = " ossrh-staging-api "
212215
213- val local = properties[ " centralAuthHeaderName " ] == null
216+ val local = ossrhMavenUsername == null || ossrhMavenPassword == null
214217 if (local) {
215218 logger.warn(" Username or password not set, publishing to local repository in build/mvnrepo/" )
216219 }
217220 val localUrl = " $buildDir /mvnrepo"
218- val releasesRepoUrl = " https://central.sonatype.com/api/v1/publisher/upload"
219- val snapshotsRepoUrl = " https://central.sonatype.com/api/v1/publisher/upload"
221+ val releasesRepoUrl = " https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
222+ // NOTE:
223+ //
224+ // Consuming Via Gradle⚓︎
225+ //
226+ // Configure your build.gradle file with the following:
227+ //
228+ // repositories {
229+ // maven {
230+ // name = 'Central Portal Snapshots'
231+ // url = 'https://central.sonatype.com/repository/maven-snapshots/'
232+ //
233+ // // Only search this repository for the specific dependency
234+ // content {
235+ // includeModule("<the snapshot's groupId>", "<the snapshot's artifactId>")
236+ // }
237+ // }
238+ // mavenCentral()
239+ // }
240+ val snapshotsRepoUrl = " https://central.sonatype.com/repository/maven-snapshots/"
220241
221242 setUrl(if (local) localUrl else if (doRelease.toBoolean()) releasesRepoUrl else snapshotsRepoUrl)
222243 if (! local) {
223- credentials( HttpHeaderCredentials :: class )
224- authentication {
225- create< HttpHeaderAuthentication >( " header " )
244+ credentials {
245+ username = ossrhMavenUsername
246+ password = ossrhMavenPassword
226247 }
227248 }
228249 }
@@ -255,7 +276,7 @@ publishing {
255276 // see https://docs.gradle.org/current/userguide/publishing_customization.html#sec:publishing_maven:conditional_publishing
256277 tasks.withType<PublishToMavenRepository >().configureEach {
257278 val predicate = provider {
258- (publication == publications[" mavenJava" ] && repository == repositories.findByName(" central " )) ||
279+ (publication == publications[" mavenJava" ] && repository == repositories.findByName(" ossrh-staging-api " )) ||
259280 (publication == publications[" versionedMavenJava" ] && repository == repositories.findByName(" DaPorkchop_" ))
260281 }
261282 onlyIf(" publishing API to Sonatype repository, and versioned API to DaPorkchop_ repository" ) {
0 commit comments