Migrating publishing to gradle

This commit is contained in:
Ziver Koc 2024-09-10 22:36:53 +02:00
parent f4cd76ef7d
commit bf34f79d19
3 changed files with 44 additions and 37 deletions

View file

@ -1,12 +1,22 @@
// Documentation: https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
// Secrets stored in ~/.jreleaser/config.toml
apply plugin: 'maven-publish'
apply plugin: 'signing'
publishing {
repositories {
maven {
def snapshotsRepoUrl = 'http://oss.sonatype.org/content/repositories/snapshots/'
def releasesRepoUrl = 'http://oss.sonatype.org/service/local/staging/deploy/maven2/'
url = project.hasProperty('release') && !version.endsWith('SNAPSHOT') ? releasesRepoUrl : snapshotsRepoUrl
}
}
publications {
maven(MavenPublication) {
mavenJava(MavenPublication) {
groupId = 'se.koc'
artifactId = 'zutil'
from components.java
pom {
@ -34,31 +44,28 @@ publishing {
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
// Signing
signing {
sign publishing.publications.mavenJava
}
// Generate version.txt
ext.genOutputDir = file("${buildDir}/generated-resources")
task generateVersionTxt() {
ext.outputFile = file("${genOutputDir}/version.txt")
outputs.file(outputFile)
doLast {
outputFile.text = """GroupId: ${project.group}
Name: ${project.name}
Version: ${version}
Build-time: ${java.time.LocalDateTime.now()}
"""
}
}
jreleaser {
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
nexus2 {
'maven-central' {
active = 'ALWAYS'
url = 'https://s01.oss.sonatype.org/service/local'
snapshotUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
closeRepository = true
releaseRepository = true
stagingRepository('build/staging-deploy')
}
}
}
}
}
sourceSets.main.output.dir genOutputDir, builtBy: generateVersionTxt