diff --git a/.github/workflows/mongodb.yml b/.github/workflows/mongodb.yml index 10813489..11f34b7c 100644 --- a/.github/workflows/mongodb.yml +++ b/.github/workflows/mongodb.yml @@ -36,7 +36,7 @@ jobs: java-version: ${{ matrix.java }} cache: gradle - name: Build with Gradle - run: ./gradlew clean build -PstatemachineIncludeTags=mongodb -PstatemachineTestResults=true + run: ./gradlew clean build -PstatemachineIncludeTags=mongodb - name: Tar Build Logs if: ${{ failure() }} run: | diff --git a/.github/workflows/redis.yml b/.github/workflows/redis.yml index 8e17a844..01d166a7 100644 --- a/.github/workflows/redis.yml +++ b/.github/workflows/redis.yml @@ -36,7 +36,7 @@ jobs: java-version: ${{ matrix.java }} cache: gradle - name: Build with Gradle - run: ./gradlew clean build -PstatemachineIncludeTags=redis -PstatemachineTestResults=true + run: ./gradlew clean build -PstatemachineIncludeTags=redis - name: Tar Build Logs if: ${{ failure() }} run: | diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 89fd56ed..9cd42917 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -30,7 +30,7 @@ jobs: java-version: ${{ matrix.java }} cache: gradle - name: Build with Gradle - run: ./gradlew clean build -PstatemachineIncludeTags=smoke -PstatemachineTestResults=true + run: ./gradlew clean build -PstatemachineIncludeTags=smoke - name: Tar Build Logs if: ${{ failure() }} run: | diff --git a/buildSrc/src/main/java/org/springframework/statemachine/gradle/JavaConventions.java b/buildSrc/src/main/java/org/springframework/statemachine/gradle/JavaConventions.java index 49bf8822..5d55c94b 100644 --- a/buildSrc/src/main/java/org/springframework/statemachine/gradle/JavaConventions.java +++ b/buildSrc/src/main/java/org/springframework/statemachine/gradle/JavaConventions.java @@ -39,6 +39,8 @@ import org.gradle.external.javadoc.CoreJavadocOptions; class JavaConventions { private static final String SOURCE_AND_TARGET_COMPATIBILITY = "17"; + private static final String INCLUDE_TAGS = "statemachineIncludeTags"; + private static final String EXCLUDE_TAGS = "statemachineExcludeTags"; void apply(Project project) { project.getPlugins().withType(JavaBasePlugin.class, java -> { @@ -84,7 +86,31 @@ class JavaConventions { private void configureTestConventions(Project project) { project.getTasks().withType(Test.class, test -> { - test.useJUnitPlatform(); + boolean hasIncludeTags = project.hasProperty(INCLUDE_TAGS); + boolean hasExcludeTags = project.hasProperty(EXCLUDE_TAGS); + test.useJUnitPlatform(options -> { + if (!hasIncludeTags && !hasExcludeTags) { + options.excludeTags("smoke"); + } + else { + if (hasIncludeTags) { + Object includeTagsProperty = project.property(INCLUDE_TAGS); + if (includeTagsProperty instanceof String p) { + if (p.length() > 0) { + options.includeTags(p.split(",")); + } + } + } + if (hasExcludeTags) { + Object excludeTagsProperty = project.property(EXCLUDE_TAGS); + if (excludeTagsProperty instanceof String p) { + if (p.length() > 0) { + options.excludeTags(p.split(",")); + } + } + } + } + }); }); }