OSSRH to Central Portal (with jreleaser)

Created Diff never expires
10 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
79 lines
42 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
111 lines
plugins {
plugins {
id 'java-library'
id 'java-library'
id 'signing'
id 'signing'
id 'maven-publish'
id 'maven-publish'
id 'org.jreleaser' version '1.17.0'
}
}


repositories {
repositories {
mavenCentral()
mavenCentral()
}
}


task sourcesJar(type: Jar) {
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
archiveClassifier.set('sources')
from sourceSets.main.allSource
from sourceSets.main.allSource
}
}


task javadocJar(type: Jar) {
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
archiveClassifier.set('javadoc')
from tasks.javadoc.destinationDir
from tasks.javadoc.destinationDir
}
}


publishing {
publishing {
publications {
publications {
mavenJava(MavenPublication) {
maven(MavenPublication) {
from components.java
from components.java
artifact sourcesJar
artifact sourcesJar
artifact javadocJar
artifact javadocJar


groupId = 'com.example'
groupId = 'com.example'
version = '1.0.0'
version = '1.0.0'
artifactId = 'sample-package'
artifactId = 'sample-package'


pom {
pom {
name.set('Sample package')
name.set('Sample package')
description.set('This is sample.')
description.set('This is sample.')
url.set('https://github.com/your-github-name/repository-name')
url.set('https://github.com/your-github-name/repository-name')


licenses {
licenses {
license {
license {
name.set('MIT License')
name.set('MIT License')
url.set('https://opensource.org/licenses/MIT')
url.set('https://opensource.org/licenses/MIT')
}
}
}
}


developers {
developers {
developer {
developer {
id.set('Your id')
id.set('Your id')
name.set('Your name')
name.set('Your name')
email.set('???@???.???')
email.set('???@???.???')
}
}
}
}


scm {
scm {
connection.set('scm:git:git://github.com/your-github-name/repository-name.git')
connection.set('scm:git:git://github.com/your-github-name/repository-name.git')
developerConnection.set('scm:git:ssh://github.com/your-github-name/repository-name.git')
developerConnection.set('scm:git:ssh://github.com/your-github-name/repository-name.git')
url.set('https://github.com/your-github-name/repository-name')
url.set('https://github.com/your-github-name/repository-name')
}
}
}
}
}
}
}
}


repositories {
repositories {
maven {
maven {
name 'OSSRH'
url = layout.buildDirectory.dir('staging-deploy')
url uri('https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/')
credentials {
username = project.findProperty('ossrhUsername')?.toString()
password = project.findProperty('ossrhPassword')?.toString()
}
}
}
}
}
}
}


def githubToken = project.findProperty('githubToken')

def gpgPublicKey = project.findProperty('gpgPublicKey')
def gpgSecretKey = project.findProperty('gpgSecretKey')
def gpgSecretKey = project.findProperty('gpgSecretKey')
def gpgPassphrase = project.findProperty('gpgPassphrase')
def gpgPassphrase = project.findProperty('gpgPassphrase')


signing {
def centralUsername = project.findProperty('centralUsername')
useInMemoryPgpKeys(gpgSecretKey, gpgPassphrase)
def centralPassword = project.findProperty('centralPassword')
sign publishing.publications.mavenJava

jreleaser {
project {
gitRootSearch = true
}

release {
github {
token.set(githubToken)
}
}

signing {
active = 'ALWAYS'
armored = true
mode = 'MEMORY'
publicKey.set(gpgPublicKey)
secretKey.set(gpgSecretKey)
passphrase.set(gpgPassphrase)
}

deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
username.set(centralUsername)
password.set(centralPassword)
stagingRepository('build/staging-deploy')
}
}
}
}
}
}