Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2cf143

Browse files
mschielmannMichal Schielmannel-dot
authored
Migrate to new publisher (#38)
* migrate-to - migrate to jreleaser for maven central release * migrate-to - provide public key * migrate-to - provide public key * migrate-to - migrate to new publish method * migrate-to - migrate to new publish method --------- Co-authored-by: Michal Schielmann <[email protected]> Co-authored-by: Krzysztof Bieroń <[email protected]>
1 parent a22f85e commit a2cf143

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

build.gradle

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ plugins {
55
id 'org.jreleaser' version '1.19.0'
66
}
77

8-
group = "com.shift4"
9-
version = "3.0.1-SNAPSHOT"
10-
archivesBaseName = "shift4-java"
8+
group = 'com.shift4'
9+
version = '3.0.1-SNAPSHOT'
10+
archivesBaseName = 'shift4-java'
11+
12+
def stagingForReleases = 'staging-deploy/releases'
13+
def stagingForSnapshots = 'staging-deploy/snapshots'
14+
15+
def releasesMavenCentralUrl = 'https://central.sonatype.com/api/v1/publisher'
16+
def snapshotsMavenCentralUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
1117

1218
repositories {
1319
mavenCentral()
@@ -35,7 +41,7 @@ test {
3541
}
3642

3743
dependencies {
38-
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0'
44+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.19.1'
3945
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
4046
implementation 'commons-codec:commons-codec:1.15'
4147
implementation 'org.apache.httpcomponents:httpmime:4.5.14'
@@ -49,8 +55,8 @@ dependencies {
4955
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
5056
}
5157

52-
ext.genResourcesDir = file("$buildDir/generated-resources")
53-
task generateBuildProperties {
58+
ext.genResourcesDir = layout.buildDirectory.dir('generated-resources').get().asFile
59+
tasks.register('generateBuildProperties') {
5460
ext.buildPropertiesFile = file("$genResourcesDir/com/shift4/build.properties")
5561
outputs.file(buildPropertiesFile)
5662
doLast {
@@ -94,27 +100,11 @@ publishing {
94100
}
95101
repositories {
96102
maven {
97-
url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI()
103+
url = layout.buildDirectory.dir(version.endsWith('SNAPSHOT') ? stagingForSnapshots : stagingForReleases).get().asFile.toURI()
98104
}
99105
}
100106
}
101107

102-
tasks.withType(GenerateModuleMetadata) {
103-
enabled = false
104-
}
105-
106-
if (findProperty("signingKey") != null) {
107-
signing {
108-
def signingKey = findProperty("signingKey")
109-
def signingPassword = findProperty("signingPassword")
110-
useInMemoryPgpKeys(signingKey, signingPassword)
111-
sign publishing.publications.mavenJava
112-
}
113-
}
114-
115-
repositories {
116-
mavenCentral()
117-
}
118108

119109
jreleaser {
120110
signing {
@@ -127,12 +117,31 @@ jreleaser {
127117
mavenCentral {
128118
sonatype {
129119
active = 'ALWAYS'
130-
url = 'https://central.sonatype.com/api/v1/publisher'
131-
snapshotSupported = true
120+
def isSnapshot = version.endsWith('SNAPSHOT')
121+
url = isSnapshot ? snapshotsMavenCentralUrl : releasesMavenCentralUrl
122+
snapshotSupported = isSnapshot
132123
applyMavenCentralRules = true
133-
stagingRepository('build/staging-deploy')
124+
stagingRepository('build/' + (isSnapshot ? stagingForSnapshots : stagingForReleases))
134125
}
135126
}
136127
}
137128
}
138129
}
130+
131+
tasks.withType(GenerateModuleMetadata) {
132+
enabled = false
133+
}
134+
135+
if (findProperty("signingKey") != null) {
136+
signing {
137+
def signingKey = findProperty("signingKey")
138+
def signingPassword = findProperty("signingPassword")
139+
useInMemoryPgpKeys(signingKey, signingPassword)
140+
sign publishing.publications.mavenJava
141+
}
142+
}
143+
144+
repositories {
145+
mavenCentral()
146+
}
147+

0 commit comments

Comments
 (0)