-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from miniwolf/upgrade-gradle-java-kotlin-fix-t…
…ests Upgrade gradle java kotlin fix tests
- Loading branch information
Showing
36 changed files
with
636 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ users | |
*.config | ||
*.fagi | ||
.gradle/* | ||
*/build/* | ||
*/build/* | ||
buildSrc/.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: java | ||
install: true | ||
jdk: openjdk16 | ||
jdk: openjdk21 | ||
|
||
matrix: | ||
include: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import com.fagi.test.TestResultsService | ||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
|
||
allprojects { | ||
group = "com.fagi" | ||
version = "1.0-snapshot" | ||
} | ||
|
||
subprojects { | ||
apply(plugin = "java") | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
sourceCompatibility = JavaVersion.VERSION_21.toString() | ||
targetCompatibility = JavaVersion.VERSION_21.toString() | ||
} | ||
} | ||
|
||
// Register the custom build service | ||
val testResultsServiceProvider = gradle.sharedServices.registerIfAbsent("testResultsService", TestResultsService::class.java) {} | ||
|
||
// Configure all projects to use the custom build service | ||
allprojects { | ||
tasks.withType<Test> { | ||
testLogging { | ||
events = setOf( | ||
TestLogEvent.FAILED, | ||
TestLogEvent.SKIPPED, | ||
TestLogEvent.STANDARD_OUT, | ||
TestLogEvent.STANDARD_ERROR | ||
) | ||
exceptionFormat = TestExceptionFormat.FULL | ||
showExceptions = true | ||
showCauses = true | ||
showStackTraces = true | ||
} | ||
|
||
// After a test suite is done running this is called to register the result | ||
afterSuite(KotlinClosure2<TestDescriptor, TestResult, Unit>({ desc, result -> | ||
if (desc.parent == null) { | ||
val testResultsService = testResultsServiceProvider.get() | ||
testResultsService.addTestResult(desc, result) | ||
} | ||
})) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.jvm") version "1.9.24" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} |
36 changes: 36 additions & 0 deletions
36
buildSrc/src/main/kotlin/com/fagi/test/TestResultsService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.fagi.test | ||
|
||
import groovy.time.TimeCategory | ||
import org.gradle.api.services.BuildService | ||
import org.gradle.api.services.BuildServiceParameters | ||
import org.gradle.api.tasks.testing.TestDescriptor | ||
import org.gradle.api.tasks.testing.TestResult | ||
import java.util.* | ||
|
||
abstract class TestResultsService : BuildService<BuildServiceParameters.None>, AutoCloseable { | ||
private val testsResults = mutableListOf<String>() | ||
|
||
fun addTestResult(desc: TestDescriptor, result: TestResult) { | ||
val summary = "${desc.name} results: ${result.resultType} " + | ||
"(" + | ||
"${result.testCount} tests, " + | ||
"${result.successfulTestCount} successes, " + | ||
"${result.failedTestCount} failures, " + | ||
"${result.skippedTestCount} skipped" + | ||
") " + | ||
"in ${TimeCategory.minus(Date(result.endTime), Date(result.startTime))}" | ||
testsResults.add(summary) | ||
} | ||
|
||
override fun close() { | ||
if (testsResults.isNotEmpty()) { | ||
printResults(testsResults) | ||
} | ||
} | ||
|
||
private fun printResults(allResults: List<String>) { | ||
println(allResults.joinToString("\n\n") { | ||
it.lines().joinToString("\n") | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
plugins { | ||
id("application") | ||
id("org.openjfx.javafxplugin") version "0.1.0" | ||
} | ||
|
||
application { | ||
mainClass.set("com.fagi.main.FagiApp") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
flatDir { | ||
dirs("libs") | ||
} | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
javafx { | ||
version = "21" | ||
modules = mutableListOf("javafx.controls", "javafx.fxml", "javafx.web", "javafx.graphics") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":shared")) | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2") | ||
testImplementation("org.mockito:mockito-core:5.12.0") | ||
testImplementation("org.hamcrest:hamcrest:2.2") | ||
testImplementation("org.testfx:testfx-core:4.0.18") | ||
testImplementation("org.testfx:testfx-junit5:4.0.18") | ||
testImplementation("org.openjfx:javafx-swing:21.0.3") | ||
testImplementation("org.testfx:openjfx-monocle:21.0.2") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.