Changed the build.gradle to have an automatic build script, added the README
This commit is contained in:
40
README.md
40
README.md
@@ -1,2 +1,40 @@
|
|||||||
# Temp-Java-Gradle
|
@Author Kevin Schoenmayer, Riley Schneider, Can Oezdemir, Lasse Grosshans
|
||||||
|
|
||||||
|
Volle Dokumentation mit Bildern, Vorbereitungen und Klassendiagramm unter
|
||||||
|
https://docs.google.com/document/d/1iPl3XoZdvn1zqYCNlzHklEf_bRBGnQm41bAEaWz_s0w/edit?usp=sharing
|
||||||
|
|
||||||
|
|
||||||
|
Voraussetzungen:
|
||||||
|
Docker (inkl. Docker Compose)
|
||||||
|
Java 17
|
||||||
|
Git
|
||||||
|
|
||||||
|
Projekt bauen, testen und starten:
|
||||||
|
|
||||||
|
1. Projekt klonen:
|
||||||
|
git clone https://home.luithardt.cloud:5400/KevinSchoenmayer/GseTDDUebungKCLR
|
||||||
|
|
||||||
|
2. Zu ...\GseTDDUebungKCLR\docker in cmd navigieren
|
||||||
|
Docker starten:
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
3. Tabellenerstellung fuer die Testumgebung:
|
||||||
|
Verbinden Sie sich mit dem Programm Ihrer Wahl mit der Datenbank (z.B. HeidiSQL). Die Anmeldeinformationen finden Sie in der compose.yml-Datei.
|
||||||
|
Fuehren Sie nun auf der Datenbank folgende SQL-Befehle aus dieser Dateien aus:
|
||||||
|
resources\sql\createTaskTable.sql
|
||||||
|
resources\sql\createWorkerTable.sql
|
||||||
|
Sie sollten in Ihrer Datenbank nun zwei neue Tabellen sehen: Task und Worker. Wenn dem so sei, koennen Sie mit Punkt (6) fortfahren.
|
||||||
|
|
||||||
|
4. Projekt starten:
|
||||||
|
gradle cleanRun --console=plain --quiet
|
||||||
|
Jetzt werden die Tests durchgefuehrt und in
|
||||||
|
...\GseTDDUebungKCLR\build\reports\tests\index.html
|
||||||
|
gespeichert (genaue Adresse fuer .html wird automatisch angegeben),
|
||||||
|
die Jacoco Test Coverage erzeugt und in
|
||||||
|
...\GseTDDUebungKCLR\build\reports\jacoco\html\index.html
|
||||||
|
gespeichert (genaue Adresse fuer .html wird automatisch angegeben),
|
||||||
|
und das Programm in der Command Line gestartet.
|
||||||
|
|
||||||
|
Nutze ?, um dir die Befehle anzeigen zu lassen.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
104
build.gradle
104
build.gradle
@@ -18,11 +18,6 @@ dependencies {
|
|||||||
implementation 'com.mysql:mysql-connector-j:9.5.0'
|
implementation 'com.mysql:mysql-connector-j:9.5.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = '0.8.13'
|
|
||||||
reportsDirectory.set(layout.buildDirectory.dir('customJacocoReportDir'))
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
@@ -36,6 +31,7 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test configuration
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
testLogging {
|
testLogging {
|
||||||
@@ -43,19 +39,105 @@ test {
|
|||||||
exceptionFormat "full"
|
exceptionFormat "full"
|
||||||
showStandardStreams = true
|
showStandardStreams = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate test reports in a specific location
|
||||||
|
reports {
|
||||||
|
html.outputLocation.set(layout.buildDirectory.dir("reports/tests"))
|
||||||
|
junitXml.outputLocation.set(layout.buildDirectory.dir("reports/tests"))
|
||||||
|
}
|
||||||
|
|
||||||
finalizedBy jacocoTestReport
|
finalizedBy jacocoTestReport
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jacoco configuration
|
||||||
|
jacoco {
|
||||||
|
toolVersion = '0.8.13'
|
||||||
|
reportsDirectory.set(layout.buildDirectory.dir('reports/jacoco'))
|
||||||
|
}
|
||||||
|
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
dependsOn test
|
dependsOn test
|
||||||
reports {
|
reports {
|
||||||
xml.required = false
|
xml.required = true
|
||||||
csv.required = false
|
csv.required = false
|
||||||
html.outputLocation.set(layout.buildDirectory.dir('jacocoHtml'))
|
html.required = true
|
||||||
|
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/html"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jacocoTestCoverageVerification {
|
|
||||||
dependsOn test
|
// Application configuration
|
||||||
}
|
|
||||||
application {
|
application {
|
||||||
mainClass = "hhn.temp.project.Main"
|
mainClass = "hhn.temp.project.Main"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom task to print information after build
|
||||||
|
task printInfo {
|
||||||
|
dependsOn test, jacocoTestReport
|
||||||
|
doLast {
|
||||||
|
println("\n" + "="*50)
|
||||||
|
println("BUILD AND TESTS COMPLETED SUCCESSFULLY!")
|
||||||
|
println("="*50)
|
||||||
|
println("\nTest Results Location:")
|
||||||
|
println(" HTML: ${layout.buildDirectory.get()}/reports/tests/index.html")
|
||||||
|
println(" XML: ${layout.buildDirectory.get()}/reports/tests/TEST-*.xml")
|
||||||
|
|
||||||
|
println("\nJacoco Coverage Reports:")
|
||||||
|
println(" HTML: ${layout.buildDirectory.get()}/reports/jacoco/html/index.html")
|
||||||
|
println(" XML: ${layout.buildDirectory.get()}/reports/jacoco/test/jacocoTestReport.xml")
|
||||||
|
|
||||||
|
println("\nTo run the application:")
|
||||||
|
println(" gradle run --console=plain")
|
||||||
|
println("\nTo run tests and generate coverage reports:")
|
||||||
|
println(" gradle test jacocoTestReport")
|
||||||
|
println("="*50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom task that combines clean, test, jacocoTestReport
|
||||||
|
task cleanTestReport {
|
||||||
|
dependsOn clean, test, jacocoTestReport
|
||||||
|
description = 'Clean build and run tests with coverage reports'
|
||||||
|
group = 'verification'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure the standard run task
|
||||||
|
run {
|
||||||
|
dependsOn test, jacocoTestReport
|
||||||
|
standardInput = System.in
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
println("\n" + "="*50)
|
||||||
|
println("TESTS COMPLETED - STARTING APPLICATION...")
|
||||||
|
println("="*50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an alias task
|
||||||
|
task cleanRun {
|
||||||
|
dependsOn clean, run
|
||||||
|
description = 'Clean build, run tests with coverage, then run the application'
|
||||||
|
group = 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alternative: Create a separate task that doesn't chain dependencies
|
||||||
|
task startApp(type: JavaExec) {
|
||||||
|
description = 'Start the application (without running tests first)'
|
||||||
|
group = 'application'
|
||||||
|
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
mainClass = application.mainClass
|
||||||
|
standardInput = System.in
|
||||||
|
standardOutput = System.out
|
||||||
|
|
||||||
|
// Configure to run in foreground
|
||||||
|
systemProperties System.getProperties()
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
println("\n" + "="*50)
|
||||||
|
println("STARTING APPLICATION...")
|
||||||
|
println("="*50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make test and jacocoTestReport trigger the info print
|
||||||
|
test.finalizedBy printInfo
|
||||||
Reference in New Issue
Block a user