94 lines
2.7 KiB
Groovy
94 lines
2.7 KiB
Groovy
// Documentation: https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
|
|
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'signing'
|
|
|
|
publishing {
|
|
repositories {
|
|
maven {
|
|
def snapshotsRepoUrl = 'http://oss.sonatype.org/content/repositories/snapshots/'
|
|
def releaseRepoUrl = 'http://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
url = project.hasProperty('release') ? releaseRepoUrl : snapshotsRepoUrl
|
|
|
|
credentials {
|
|
def repositoryUsername = project.hasProperty('mavenCentralUsername') ? mavenCentralUsername : "unknown"
|
|
project.logger.info("Setting Maven Central Credentials: ${repositoryUsername}")
|
|
|
|
username(repositoryUsername)
|
|
password( project.hasProperty('mavenCentralPassword') ? mavenCentralPassword : "unknown")
|
|
}
|
|
}
|
|
}
|
|
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
from components.java
|
|
|
|
pom {
|
|
name = 'Zutil'
|
|
description = 'A library containing utility classes and code snippets.'
|
|
url = 'https://github.com/Ziver/zutil'
|
|
|
|
licenses {
|
|
license {
|
|
name = 'MIT License'
|
|
url = 'http://www.opensource.org/licenses/mit-license.php'
|
|
}
|
|
}
|
|
developers {
|
|
developer {
|
|
id = 'Ziver Koc'
|
|
name = 'dev@koc.se'
|
|
}
|
|
}
|
|
scm {
|
|
connection = 'scm:git:https://github.com/Ziver/zutil.git'
|
|
developerConnection = 'scm:git:https://repo.koc.se/zutil-java.git'
|
|
url = 'https://github.com/Ziver/zutil'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Signing
|
|
|
|
signing {
|
|
required { hasProperty("signing.secretKeyRingFile") }
|
|
//sign publishing.publications.mavenJava
|
|
sign configurations.archives
|
|
}
|
|
|
|
// 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()}
|
|
"""
|
|
}
|
|
}
|
|
|
|
sourceSets.main.output.dir genOutputDir, builtBy: generateVersionTxt
|
|
|
|
// Generate additional Jars
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = 'javadoc'
|
|
from javadoc
|
|
}
|
|
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
artifacts {
|
|
archives javadocJar, sourcesJar
|
|
}
|