From 23f96e5769d9dd5d81d7edefc469aa29b4e2c7cd Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 13 Oct 2024 11:41:59 +0200 Subject: [PATCH] Define GitHub Actions workflows and update Gradle (#208) update Gradle version so that it can run on newer Java versions - Maven Central publishing will need to be configured from scratch since `maven` Gradle plugin is no longer alive --- .github/workflows/build.yml | 61 ++++++++++++++++ build.gradle | 91 ++++++++---------------- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 90 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e91bbce --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +name: build and test +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + validation: + name: "Gradle Wrapper Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: gradle/wrapper-validation-action@v1 + build: + name: "Compile against JDKs and OSes" + needs: [ validation ] + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + java: [ 8, 11, 17, 21, 23 ] + exclude: + - java: 8 + os: macos-latest + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ matrix.java }} + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Execute Gradle build + run: ./gradlew build + + test: + name: "Test" + needs: [ build ] + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 8, 11, 17, 21, 23 ] + fasterxmlVersion: [ 2.8.11, 2.9.10, 2.10.4, 2.11.3, 2.12.3, 2.13.4, 2.14.1 ] + fail-fast: false + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: temurin + cache: gradle + - run: | + ./gradlew clean check --refresh-dependencies -PfasterxmlVersion=${{ matrix.fasterxmlVersion }} + ./gradlew codeCoverageReport diff --git a/build.gradle b/build.gradle index f8d906b..96c7d58 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { id 'java' - id 'maven' id 'jacoco' + id 'maven-publish' id 'checkstyle' - id 'com.bmuschko.nexus' version '2.3.1' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 +} group = 'io.vavr' version = '0.10.5-SNAPSHOT' @@ -20,35 +20,39 @@ repositories { } dependencies { - compile "io.vavr:vavr:${vavrVersion}" - compile "com.fasterxml.jackson.core:jackson-databind:${fasterxmlVersion}" - testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" + implementation "io.vavr:vavr:${vavrVersion}" + implementation "com.fasterxml.jackson.core:jackson-databind:${fasterxmlVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}" - testCompile "javax.xml.bind:jaxb-api:${jaxbVersion}" - testCompile "com.squareup:javapoet:${javapoetVersion}" - testCompile "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:${fasterxmlVersion}" - testCompile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${fasterxmlVersion}" - testCompile "com.fasterxml.jackson.datatype:jackson-datatype-joda:${fasterxmlVersion}" - testCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${fasterxmlVersion}" - testCompile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${fasterxmlVersion}" - testCompile "com.fasterxml.jackson.module:jackson-module-scala_2.11:${fasterxmlVersion}" + testImplementation "javax.xml.bind:jaxb-api:${jaxbVersion}" + testImplementation "com.squareup:javapoet:${javapoetVersion}" + testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:${fasterxmlVersion}" + testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${fasterxmlVersion}" + testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:${fasterxmlVersion}" + testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${fasterxmlVersion}" + testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${fasterxmlVersion}" + testImplementation "com.fasterxml.jackson.module:jackson-module-scala_2.11:${fasterxmlVersion}" } -task codeCoverageReport(type: JacocoReport) { - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") +tasks.register('codeCoverageReport', JacocoReport) { + dependsOn tasks.test + executionData.setFrom(fileTree(project.rootDir).include("**/build/jacoco/*.exec")) - sourceSets sourceSets.main + sourceDirectories.setFrom(files(sourceSets.main.allSource.srcDirs)) + classDirectories.setFrom(fileTree("build/classes/java/main") { + exclude '**/SomeExcludedClass.class' + }) reports { - xml.enabled = true - xml.destination file("${buildDir}/reports/jacoco/report.xml") - html.enabled = true - csv.enabled = false + xml.required.set(true) + xml.outputLocation.set(file("${buildDir}/reports/jacoco/report.xml")) + html.required.set(true) + csv.required.set(false) } } -codeCoverageReport.dependsOn { - project.test +tasks.test { + finalizedBy tasks.codeCoverageReport } jar { @@ -59,45 +63,6 @@ jar { } } -modifyPom { - project { - name 'Vavr-Jackson' - description 'Jackson datatype module for Vavr.io' - url 'http://vavr.io' - inceptionYear '2016' - - scm { - connection 'scm:git:git@github.com:vavr-io/vavr-jackson.git' - developerConnection 'scm:git:git@github.com:vavr-io/vavr-jackson.git' - url 'git@github.com:vavr-io/vavr-jackson.git' - } - - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - id 'ruslansennov' - name 'Ruslan Sennov' - email 'ruslan.sennov@gmail.com' - } - developer { - id 'minconghuang' - name 'Mincong Huang' - email 'mincong.h@gmail.com' - } - } - } -} - -nexus { - sign = !version.endsWith("SNAPSHOT") -} - test { useJUnitPlatform() } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6623300..18330fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists