diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 977415d..88ae06a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: '17' + java-version: '21' - name: Cache Gradle packages uses: actions/cache@v4 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5295861..8d2ef4a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,13 +20,13 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: '17' - - name: Publish + java-version: '21' + - name: Publish to Maven Central (Portal) run: | chmod +x gradlew - ./gradlew publish closeAndReleaseRepository + ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: - ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SEER_GPG_SECRET_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SEER_GPG_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} diff --git a/build.gradle b/build.gradle index 04dca12..fcb57c0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,21 @@ +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.SonatypeHost + plugins { id 'java-library' id 'checkstyle' id 'jacoco' id "com.github.spotbugs" version "6.1.11" - id 'maven-publish' - id 'signing' - id "io.codearte.nexus-staging" version "0.30.0" id 'com.adarshr.test-logger' version '4.0.0' id "com.github.ben-manes.versions" version "0.52.0" id 'org.sonatype.gradle.plugins.scan' version '3.1.1' id "org.sonarqube" version "6.1.0.5360" + id 'com.vanniktech.maven.publish' version '0.31.0' } group = 'com.imsweb' -version = '5.7' +version = '5.8-SNAPSHOT' description = 'Java client library for SEER*API' tasks.withType(JavaCompile).configureEach { @@ -24,9 +26,6 @@ tasks.withType(JavaCompile).configureEach { java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 - - withJavadocJar() - withSourcesJar() } repositories { @@ -70,6 +69,11 @@ jar { } } +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' + options.compilerArgs << "-Werror" << "-Xlint:-options" +} + tasks.withType(Javadoc).configureEach { failOnError false options.addStringOption('Xdoclint:none', '-quiet') @@ -77,12 +81,26 @@ tasks.withType(Javadoc).configureEach { options.addStringOption('charSet', 'UTF-8') } +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } +} + test { useJUnitPlatform() } +test.finalizedBy jacocoTestReport + +jacocoTestReport { + reports { + xml.required = true + } +} + checkstyle { - toolVersion '8.29' + toolVersion = '8.29' configFile = file("config/checkstyle/checkstyle.xml") } @@ -90,13 +108,6 @@ spotbugs { excludeFilter = file('config/spotbugs/spotbugs-exclude.xml') } -jacocoTestReport { - reports { - xml.required = true - } -} -test.finalizedBy jacocoTestReport - sonarqube { properties { property "sonar.projectKey", "imsweb_seerapi-client-java" @@ -105,115 +116,51 @@ sonarqube { } } -// Nexus vulnerability scan (see https://github.com/sonatype-nexus-community/scan-gradle-plugin) ossIndexAudit { outputFormat = 'DEPENDENCY_GRAPH' printBanner = false } -def isNonStable = { String version -> - def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } - def regex = /^[0-9,.v-]+(-r)?$/ - return !stableKeyword && !(version ==~ regex) -} +mavenPublishing { + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) -// https://github.com/ben-manes/gradle-versions-plugin -tasks.named("dependencyUpdates").configure { - rejectVersionIf { - isNonStable(it.candidate.version) - } -} + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) + signAllPublications() -wrapper { - gradleVersion = '8.14' - distributionType = Wrapper.DistributionType.ALL -} + pom { + name = 'SEER*API Java Client' + description = 'API mapping for SEER*API in Java' + url = 'https://github.com/imsweb/seerapi-client-java' -// don't try to release a snapshot to a non-snapshot repository, that won't work anyway -if (version.endsWith('-SNAPSHOT')) { - gradle.startParameter.excludedTaskNames += 'signMavenJavaPublication' - gradle.startParameter.excludedTaskNames += 'closeAndReleaseRepository' -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifactId = 'seerapi-client-java' - from components.java - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } - pom { - name = 'SEER*API Java Client' - description = 'API mapping for SEER*API in Java' - url = 'https://github.com/imsweb/seerapi-client-java' - inceptionYear = '2014' - - licenses { - license { - name = 'The MIT License (MIT)' - url = 'http://www.opensource.org/licenses/mit-license.php' - distribution = 'repo' - } - } - - developers { - developer { - id = 'ctmay4' - name = 'Chuck May' - email = 'mayc@imsweb.com' - } - developer { - id = 'depryf' - name = 'Fabian Depry' - email = 'depryf@imsweb.com' - } - } - - scm { - url = 'https://github.com/imsweb/seerapi-client-java' - connection = 'scm:https://github.com/imsweb/seerapi-client-java.git' - developerConnection = 'scm:git@github.com:imsweb/seerapi-client-java.git' - } + licenses { + license { + name = 'The MIT License (MIT)' + url = 'http://www.opensource.org/licenses/mit-license.php' } } - } - repositories { - maven { - def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" - def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - - credentials { - username = project.findProperty('nexusUsername') ?: '' - password = project.findProperty('nexusPassword') ?: '' + + developers { + developer { + id = 'ctmay4' + name = 'Chuck May' + email = 'mayc@imsweb.com' + } + developer { + id = 'depryf' + name = 'Fabian Depry' + email = 'depryf@imsweb.com' } } - } -} - -signing { - def signingKey = project.findProperty('signingKey') ?: '' - def signingPassword = project.findProperty('signingPassword') ?: '' - - useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications.mavenJava -} - -javadoc { - if (JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html5', true) + scm { + url = 'https://github.com/imsweb/seerapi-client-java' + connection = 'scm:https://github.com/imsweb/seerapi-client-java.git' + developerConnection = 'scm:git@github.com:imsweb/seerapi-client-java.git' + } } } -// configure nexus staging plugin -nexusStaging { - numberOfRetries = 50 - delayBetweenRetriesInMillis = 5000 +wrapper { + gradleVersion = '8.14' + distributionType = Wrapper.DistributionType.ALL }