Add junit tag configuration

- Using include/exclude tags was missing so adding
  those into buildSrc.
- Polish it tests workflows
- Relates #1143
This commit is contained in:
Janne Valkealahti
2024-03-14 14:48:47 +00:00
parent fbb6df4e5d
commit 24a3467780
4 changed files with 30 additions and 4 deletions

View File

@@ -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: |

View File

@@ -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: |

View File

@@ -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: |

View File

@@ -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(","));
}
}
}
}
});
});
}