Skip to content

Commit a460002

Browse files
authored
Merge pull request #46 from imsweb/maven-deploy-fix
Convert to Maven Central Portal
2 parents 6bd3d05 + 9657952 commit a460002

File tree

3 files changed

+65
-118
lines changed

3 files changed

+65
-118
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/setup-java@v2
1919
with:
2020
distribution: 'adopt'
21-
java-version: '17'
21+
java-version: '21'
2222
- name: Cache Gradle packages
2323
uses: actions/cache@v4
2424
with:

.github/workflows/publish.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
uses: actions/setup-java@v2
2121
with:
2222
distribution: 'adopt'
23-
java-version: '17'
24-
- name: Publish
23+
java-version: '21'
24+
- name: Publish to Maven Central (Portal)
2525
run: |
2626
chmod +x gradlew
27-
./gradlew publish closeAndReleaseRepository
27+
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
2828
env:
29-
ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }}
30-
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
31-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SEER_GPG_SECRET_KEY }}
32-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SEER_GPG_PASSWORD }}
29+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
30+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
31+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
32+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 57 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
import com.vanniktech.maven.publish.SonatypeHost
4+
15
plugins {
26
id 'java-library'
37
id 'checkstyle'
48
id 'jacoco'
59
id "com.github.spotbugs" version "6.1.11"
6-
id 'maven-publish'
7-
id 'signing'
8-
id "io.codearte.nexus-staging" version "0.30.0"
910
id 'com.adarshr.test-logger' version '4.0.0'
1011
id "com.github.ben-manes.versions" version "0.52.0"
1112
id 'org.sonatype.gradle.plugins.scan' version '3.1.1'
1213
id "org.sonarqube" version "6.1.0.5360"
14+
id 'com.vanniktech.maven.publish' version '0.31.0'
1315
}
1416

1517
group = 'com.imsweb'
16-
version = '5.7'
18+
version = '5.8-SNAPSHOT'
1719
description = 'Java client library for SEER*API'
1820

1921
tasks.withType(JavaCompile).configureEach {
@@ -24,9 +26,6 @@ tasks.withType(JavaCompile).configureEach {
2426
java {
2527
sourceCompatibility = JavaVersion.VERSION_1_8
2628
targetCompatibility = JavaVersion.VERSION_1_8
27-
28-
withJavadocJar()
29-
withSourcesJar()
3029
}
3130

3231
repositories {
@@ -70,33 +69,45 @@ jar {
7069
}
7170
}
7271

72+
tasks.withType(JavaCompile).configureEach {
73+
options.encoding = 'UTF-8'
74+
options.compilerArgs << "-Werror" << "-Xlint:-options"
75+
}
76+
7377
tasks.withType(Javadoc).configureEach {
7478
failOnError false
7579
options.addStringOption('Xdoclint:none', '-quiet')
7680
options.addStringOption('encoding', 'UTF-8')
7781
options.addStringOption('charSet', 'UTF-8')
7882
}
7983

84+
javadoc {
85+
if (JavaVersion.current().isJava9Compatible()) {
86+
options.addBooleanOption('html5', true)
87+
}
88+
}
89+
8090
test {
8191
useJUnitPlatform()
8292
}
8393

94+
test.finalizedBy jacocoTestReport
95+
96+
jacocoTestReport {
97+
reports {
98+
xml.required = true
99+
}
100+
}
101+
84102
checkstyle {
85-
toolVersion '8.29'
103+
toolVersion = '8.29'
86104
configFile = file("config/checkstyle/checkstyle.xml")
87105
}
88106

89107
spotbugs {
90108
excludeFilter = file('config/spotbugs/spotbugs-exclude.xml')
91109
}
92110

93-
jacocoTestReport {
94-
reports {
95-
xml.required = true
96-
}
97-
}
98-
test.finalizedBy jacocoTestReport
99-
100111
sonarqube {
101112
properties {
102113
property "sonar.projectKey", "imsweb_seerapi-client-java"
@@ -105,115 +116,51 @@ sonarqube {
105116
}
106117
}
107118

108-
// Nexus vulnerability scan (see https://github.com/sonatype-nexus-community/scan-gradle-plugin)
109119
ossIndexAudit {
110120
outputFormat = 'DEPENDENCY_GRAPH'
111121
printBanner = false
112122
}
113123

114-
def isNonStable = { String version ->
115-
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
116-
def regex = /^[0-9,.v-]+(-r)?$/
117-
return !stableKeyword && !(version ==~ regex)
118-
}
124+
mavenPublishing {
125+
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
119126

120-
// https://github.com/ben-manes/gradle-versions-plugin
121-
tasks.named("dependencyUpdates").configure {
122-
rejectVersionIf {
123-
isNonStable(it.candidate.version)
124-
}
125-
}
127+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
128+
signAllPublications()
126129

127-
wrapper {
128-
gradleVersion = '8.14'
129-
distributionType = Wrapper.DistributionType.ALL
130-
}
130+
pom {
131+
name = 'SEER*API Java Client'
132+
description = 'API mapping for SEER*API in Java'
133+
url = 'https://github.com/imsweb/seerapi-client-java'
131134

132-
// don't try to release a snapshot to a non-snapshot repository, that won't work anyway
133-
if (version.endsWith('-SNAPSHOT')) {
134-
gradle.startParameter.excludedTaskNames += 'signMavenJavaPublication'
135-
gradle.startParameter.excludedTaskNames += 'closeAndReleaseRepository'
136-
}
137-
138-
publishing {
139-
publications {
140-
mavenJava(MavenPublication) {
141-
artifactId = 'seerapi-client-java'
142-
from components.java
143-
versionMapping {
144-
usage('java-api') {
145-
fromResolutionOf('runtimeClasspath')
146-
}
147-
usage('java-runtime') {
148-
fromResolutionResult()
149-
}
150-
}
151-
pom {
152-
name = 'SEER*API Java Client'
153-
description = 'API mapping for SEER*API in Java'
154-
url = 'https://github.com/imsweb/seerapi-client-java'
155-
inceptionYear = '2014'
156-
157-
licenses {
158-
license {
159-
name = 'The MIT License (MIT)'
160-
url = 'http://www.opensource.org/licenses/mit-license.php'
161-
distribution = 'repo'
162-
}
163-
}
164-
165-
developers {
166-
developer {
167-
id = 'ctmay4'
168-
name = 'Chuck May'
169-
email = 'mayc@imsweb.com'
170-
}
171-
developer {
172-
id = 'depryf'
173-
name = 'Fabian Depry'
174-
email = 'depryf@imsweb.com'
175-
}
176-
}
177-
178-
scm {
179-
url = 'https://github.com/imsweb/seerapi-client-java'
180-
connection = 'scm:https://github.com/imsweb/seerapi-client-java.git'
181-
developerConnection = 'scm:git@github.com:imsweb/seerapi-client-java.git'
182-
}
135+
licenses {
136+
license {
137+
name = 'The MIT License (MIT)'
138+
url = 'http://www.opensource.org/licenses/mit-license.php'
183139
}
184140
}
185-
}
186-
repositories {
187-
maven {
188-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
189-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
190-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
191-
192-
credentials {
193-
username = project.findProperty('nexusUsername') ?: ''
194-
password = project.findProperty('nexusPassword') ?: ''
141+
142+
developers {
143+
developer {
144+
id = 'ctmay4'
145+
name = 'Chuck May'
146+
email = 'mayc@imsweb.com'
147+
}
148+
developer {
149+
id = 'depryf'
150+
name = 'Fabian Depry'
151+
email = 'depryf@imsweb.com'
195152
}
196153
}
197-
}
198-
}
199-
200-
signing {
201-
def signingKey = project.findProperty('signingKey') ?: ''
202-
def signingPassword = project.findProperty('signingPassword') ?: ''
203-
204-
useInMemoryPgpKeys(signingKey, signingPassword)
205154

206-
sign publishing.publications.mavenJava
207-
}
208-
209-
javadoc {
210-
if (JavaVersion.current().isJava9Compatible()) {
211-
options.addBooleanOption('html5', true)
155+
scm {
156+
url = 'https://github.com/imsweb/seerapi-client-java'
157+
connection = 'scm:https://github.com/imsweb/seerapi-client-java.git'
158+
developerConnection = 'scm:git@github.com:imsweb/seerapi-client-java.git'
159+
}
212160
}
213161
}
214162

215-
// configure nexus staging plugin
216-
nexusStaging {
217-
numberOfRetries = 50
218-
delayBetweenRetriesInMillis = 5000
163+
wrapper {
164+
gradleVersion = '8.14'
165+
distributionType = Wrapper.DistributionType.ALL
219166
}

0 commit comments

Comments
 (0)