Migrating publishing to gradle
This commit is contained in:
parent
f4cd76ef7d
commit
bf34f79d19
3 changed files with 44 additions and 37 deletions
14
Jenkinsfile
vendored
14
Jenkinsfile
vendored
|
|
@ -14,22 +14,20 @@ node {
|
|||
}
|
||||
|
||||
withMaven(mavenConfiguration) {
|
||||
def mvnParams = "-Dbuild.number=${BUILD_NUMBER} -Dbuild.development=false"
|
||||
def gradleParams = "--no-daemon -Pversion=1.0.${BUILD_NUMBER}"
|
||||
|
||||
stage('Build') {
|
||||
sh "mvn ${mvnParams} clean compile"
|
||||
sh "./gradlew ${gradleParams} -x test clean build"
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
sh "mvn ${mvnParams} test"
|
||||
}
|
||||
|
||||
stage('Package') {
|
||||
sh "mvn ${mvnParams} -DskipStatic -DskipTests package"
|
||||
sh "./gradlew ${gradleParams} test"
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
sh "mvn ${mvnParams} -DskipStatic -DskipTests deploy"
|
||||
sh "./gradlew ${gradleParams} publishToMavenLocal"
|
||||
sh "./gradlew ${gradleParams} -Prelease publish"
|
||||
|
||||
sh "mvn ${mvnParams} scm:tag"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'java-library'
|
||||
id 'jacoco'
|
||||
}
|
||||
|
||||
apply from: 'build_publish.gradle'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
|
@ -61,4 +63,4 @@ sourceSets {
|
|||
srcDirs 'test'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue