Skip to content

Commit 4a6f5f2

Browse files
author
may
committed
Convert to Maven Central Portal
1 parent 6bd3d05 commit 4a6f5f2

File tree

1 file changed

+59
-120
lines changed

1 file changed

+59
-120
lines changed

build.gradle

Lines changed: 59 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
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

19-
tasks.withType(JavaCompile).configureEach {
20-
options.encoding = 'UTF-8'
21-
options.compilerArgs << "-Werror" << "-Xlint:-options"
22-
}
23-
2421
java {
2522
sourceCompatibility = JavaVersion.VERSION_1_8
2623
targetCompatibility = JavaVersion.VERSION_1_8
27-
28-
withJavadocJar()
29-
withSourcesJar()
3024
}
3125

3226
repositories {
@@ -38,8 +32,6 @@ dependencies {
3832

3933
api 'com.squareup.retrofit2:retrofit:2.11.0'
4034
api 'com.squareup.retrofit2:converter-jackson:2.11.0'
41-
42-
// retrofit will not update these dependencies to fix vulnerabilities
4335
api 'com.squareup.okhttp3:okhttp:4.12.0'
4436
api 'com.squareup.okio:okio:3.11.0'
4537

@@ -54,11 +46,10 @@ dependencies {
5446
}
5547

5648
jar {
57-
// specify the archive name; otherwise the version is appended to the war file
5849
archiveFileName = 'seerapi-java.jar'
59-
6050
manifest {
61-
attributes('Implementation-Title': 'SEER*API Java Client',
51+
attributes(
52+
'Implementation-Title': 'SEER*API Java Client',
6253
'Implementation-Version': archiveVersion,
6354
'Implementation-Vendor': group,
6455
'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
@@ -70,33 +61,45 @@ jar {
7061
}
7162
}
7263

64+
tasks.withType(JavaCompile).configureEach {
65+
options.encoding = 'UTF-8'
66+
options.compilerArgs << "-Werror" << "-Xlint:-options"
67+
}
68+
7369
tasks.withType(Javadoc).configureEach {
7470
failOnError false
7571
options.addStringOption('Xdoclint:none', '-quiet')
7672
options.addStringOption('encoding', 'UTF-8')
7773
options.addStringOption('charSet', 'UTF-8')
7874
}
7975

76+
javadoc {
77+
if (JavaVersion.current().isJava9Compatible()) {
78+
options.addBooleanOption('html5', true)
79+
}
80+
}
81+
8082
test {
8183
useJUnitPlatform()
8284
}
8385

86+
test.finalizedBy jacocoTestReport
87+
88+
jacocoTestReport {
89+
reports {
90+
xml.required = true
91+
}
92+
}
93+
8494
checkstyle {
85-
toolVersion '8.29'
95+
toolVersion = '8.29'
8696
configFile = file("config/checkstyle/checkstyle.xml")
8797
}
8898

8999
spotbugs {
90100
excludeFilter = file('config/spotbugs/spotbugs-exclude.xml')
91101
}
92102

93-
jacocoTestReport {
94-
reports {
95-
xml.required = true
96-
}
97-
}
98-
test.finalizedBy jacocoTestReport
99-
100103
sonarqube {
101104
properties {
102105
property "sonar.projectKey", "imsweb_seerapi-client-java"
@@ -105,115 +108,51 @@ sonarqube {
105108
}
106109
}
107110

108-
// Nexus vulnerability scan (see https://github.com/sonatype-nexus-community/scan-gradle-plugin)
109111
ossIndexAudit {
110112
outputFormat = 'DEPENDENCY_GRAPH'
111113
printBanner = false
112114
}
113115

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-
}
116+
mavenPublishing {
117+
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
119118

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

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

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-
170-
}
171-
developer {
172-
id = 'depryf'
173-
name = 'Fabian Depry'
174-
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:[email protected]:imsweb/seerapi-client-java.git'
182-
}
127+
licenses {
128+
license {
129+
name = 'The MIT License (MIT)'
130+
url = 'http://www.opensource.org/licenses/mit-license.php'
183131
}
184132
}
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') ?: ''
133+
134+
developers {
135+
developer {
136+
id = 'ctmay4'
137+
name = 'Chuck May'
138+
139+
}
140+
developer {
141+
id = 'depryf'
142+
name = 'Fabian Depry'
143+
195144
}
196145
}
197-
}
198-
}
199-
200-
signing {
201-
def signingKey = project.findProperty('signingKey') ?: ''
202-
def signingPassword = project.findProperty('signingPassword') ?: ''
203-
204-
useInMemoryPgpKeys(signingKey, signingPassword)
205-
206-
sign publishing.publications.mavenJava
207-
}
208146

209-
javadoc {
210-
if (JavaVersion.current().isJava9Compatible()) {
211-
options.addBooleanOption('html5', true)
147+
scm {
148+
url = 'https://github.com/imsweb/seerapi-client-java'
149+
connection = 'scm:https://github.com/imsweb/seerapi-client-java.git'
150+
developerConnection = 'scm:[email protected]:imsweb/seerapi-client-java.git'
151+
}
212152
}
213153
}
214154

215-
// configure nexus staging plugin
216-
nexusStaging {
217-
numberOfRetries = 50
218-
delayBetweenRetriesInMillis = 5000
155+
wrapper {
156+
gradleVersion = '8.14'
157+
distributionType = Wrapper.DistributionType.ALL
219158
}

0 commit comments

Comments
 (0)