diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2f934f9..8f876255 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Release - run: ./gradlew release -Prelease.disableChecks -Prelease.pushTagsOnly -Prelease.customUsername=${{ github.actor }} -Prelease.customPassword=${{ github.token }} + run: ./gradlew clean publishToSonatype closeAndReleaseSonatypeStagingRepository env: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNINGKEY }} ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNINGKEYID }} diff --git a/build.gradle b/build.gradle index 2d05eb72..0995b260 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat plugins { id "java" + id "jvm-test-suite" id "groovy" id "jacoco" id "maven-publish" @@ -46,25 +47,10 @@ compileJava { configurations.implementation.transitive = false dependencies { - implementation SLF4J_API implementation BCPROV_JDK15ON implementation MBASSADOR implementation ASN_ONE - testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.7.0") - - testImplementation GROOVY_ALL - testRuntimeOnly CGLIB_NODEP - testRuntimeOnly OBJENESIS - testImplementation SPOCK_CORE - testImplementation COMMONS_IO - testRuntimeOnly LOGBACK_CLASSIC -} - -tasks.withType(Test) { - useJUnitPlatform() } license { @@ -99,39 +85,71 @@ if (JavaVersion.current().isJava8Compatible()) { } } -configurations { - integrationTestImplementation.extendsFrom testImplementation - integrationTestRuntime.extendsFrom testRuntime -} +testing { + suites { + configureEach { + useJUnitJupiter() + dependencies { + implementation SLF4J_API + implementation GROOVY_ALL + runtimeOnly CGLIB_NODEP + runtimeOnly OBJENESIS + implementation SPOCK_CORE + implementation COMMONS_IO + runtimeOnly LOGBACK_CLASSIC + } -sourceSets { - integrationTest { - groovy { - compileClasspath += sourceSets.main.output + sourceSets.test.output - runtimeClasspath += sourceSets.main.output + sourceSets.test.output - srcDir file('src/it/groovy') + targets { + all { + testTask.configure { + testLogging { + exceptionFormat = 'full' + } + include "**/*Test.*" + include "**/*Spec.*" + afterSuite { descriptor, result -> + def indicator = "\u001B[32m✓\u001b[0m" + if (result.failedTestCount > 0) { + indicator = "\u001B[31m✘\u001b[0m" + } + logger.lifecycle("$indicator Test ${descriptor.name}; Executed: ${result.testCount}/\u001B[32m${result.successfulTestCount}\u001B[0m/\u001B[31m${result.failedTestCount}\u001B[0m") + } + } + } + } } - resources.srcDir file('src/it/resources') - } -} -task integrationTest(type: Test) { - testClassesDirs = sourceSets.integrationTest.output.classesDirs - classpath = sourceSets.integrationTest.runtimeClasspath -} + test { + sources { + groovy { + srcDirs = ['src/test/groovy'] + } + } + } -tasks.withType(Test) { - testLogging { - exceptionFormat = 'full' - } - include "**/*Test.*" - include "**/*Spec.*" - afterSuite { descriptor, result -> - def indicator = "\u001B[32m✓\u001b[0m" - if (result.failedTestCount > 0) { - indicator = "\u001B[31m✘\u001b[0m" + integrationTest(JvmTestSuite) { + dependencies { + implementation project() + } + + sources { + groovy { + srcDirs = ['src/it/groovy'] + } + + resources { + srcDirs = ['src/it/resources'] + } + } + + targets { + all { + testTask.configure { + shouldRunAfter(test) + } + } + } } - logger.lifecycle("$indicator Test ${descriptor.name}; Executed: ${result.testCount}/\u001B[32m${result.successfulTestCount}\u001B[0m/\u001B[31m${result.failedTestCount}\u001B[0m") } } @@ -235,13 +253,7 @@ task stopItestContainer(type: DockerStopContainer) { project.tasks.integrationTest.dependsOn(startItestContainer) project.tasks.integrationTest.finalizedBy(stopItestContainer) -task forkedUploadRelease(type: GradleBuild) { - buildFile = project.buildFile - tasks = ["clean", "publishToSonatype", "closeAndReleaseSonatypeStagingRepository"] -} - project.tasks.release.dependsOn([project.tasks.integrationTest, project.tasks.build]) -project.tasks.release.finalizedBy(project.tasks.forkedUploadRelease) project.tasks.jacocoTestReport.dependsOn(project.tasks.test) project.tasks.check.dependsOn(project.tasks.jacocoTestReport) diff --git a/src/test/groovy/com/hierynomus/smbj/LoggingProgressListener.groovy b/src/it/groovy/com/hierynomus/smbj/LoggingProgressListener.groovy similarity index 100% rename from src/test/groovy/com/hierynomus/smbj/LoggingProgressListener.groovy rename to src/it/groovy/com/hierynomus/smbj/LoggingProgressListener.groovy