Skip to content

Commit a7346e1

Browse files
committed
Gradle: add a testOn8 task to run tests with Java 8
1 parent 7741bf2 commit a7346e1

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ jobs:
4646
# Build
4747
- name: Build with Gradle
4848
run: ./gradlew build
49+
50+
# Run tests with Java 8
51+
- name: Test with Java 8
52+
run: ./gradlew testOn8

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ To build css4j-dom4j from the code that is currently at the Git repository, Java
2121
You can run a variety of Gradle tasks with the Gradle wrapper (on Windows shells you can omit the `./`):
2222

2323
- `./gradlew build` (normal build)
24-
- `./gradlew build publishToMavenLocal` (to install in local Maven repository)
24+
- `./gradlew publishToMavenLocal` (to install in local Maven repository)
2525
- `./gradlew copyJars` (to copy jar files into a top-level _jar_ directory)
2626
- `./gradlew lineEndingConversion` (to convert line endings of top-level text files to CRLF)
27+
- `./gradlew testOn8` (run tests with Java 8)
2728
- `./gradlew publish` (to deploy to a Maven repository, as described in the `publishing.repositories.maven` block of
2829
[build.gradle](https://github.com/css4j/css4j-dom4j/blob/master/build.gradle))
2930

build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ tasks.register('checkLegacyJava') {
177177

178178
classes.finalizedBy checkLegacyJava
179179

180+
tasks.register('testOn8', Test) {
181+
description = 'Runs tests on Java 8'
182+
dependsOn classes
183+
testClassesDirs = testing.suites.test.sources.output.classesDirs
184+
classpath = testing.suites.test.sources.runtimeClasspath
185+
useJUnitPlatform()
186+
javaLauncher = javaToolchains.launcherFor {
187+
languageVersion = JavaLanguageVersion.of(8)
188+
}
189+
}
190+
180191
// Copy jar files to 'jar' directory
181192
tasks.register('copyJars', Copy) {
182193
description = 'Copy jar files to \'jar\' directory'

0 commit comments

Comments
 (0)