|
| 1 | +plugins { |
| 2 | + java |
| 3 | + application |
| 4 | + jacoco |
| 5 | + id("com.gradleup.shadow") version "9.3.1" |
| 6 | +} |
| 7 | + |
| 8 | +group = "edu.luc.cs" |
| 9 | +version = "1.0-SNAPSHOT" |
| 10 | + |
| 11 | +java { |
| 12 | + toolchain { |
| 13 | + languageVersion.set(JavaLanguageVersion.of(21)) |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +repositories { |
| 18 | + mavenCentral() |
| 19 | +} |
| 20 | + |
| 21 | +dependencies { |
| 22 | + testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4") |
| 23 | + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4") |
| 24 | + testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4") |
| 25 | + testImplementation("net.jqwik:jqwik:1.9.2") |
| 26 | +} |
| 27 | + |
| 28 | +application { |
| 29 | + mainClass.set("edu.luc.cs335.arrayqueue.SingleQueueService") |
| 30 | +} |
| 31 | + |
| 32 | +tasks.test { |
| 33 | + useJUnitPlatform { |
| 34 | + includeEngines("jqwik", "junit-jupiter") |
| 35 | + } |
| 36 | + finalizedBy(tasks.jacocoTestReport) |
| 37 | +} |
| 38 | + |
| 39 | +jacoco { |
| 40 | + toolVersion = "0.8.12" |
| 41 | +} |
| 42 | + |
| 43 | +tasks.jacocoTestReport { |
| 44 | + dependsOn(tasks.test) |
| 45 | + reports { |
| 46 | + xml.required.set(true) |
| 47 | + html.required.set(true) |
| 48 | + } |
| 49 | + classDirectories.setFrom( |
| 50 | + files(classDirectories.files.map { |
| 51 | + fileTree(it) { |
| 52 | + exclude("**/*Main.*") |
| 53 | + exclude("**/SingleQueueService.*") |
| 54 | + } |
| 55 | + }) |
| 56 | + ) |
| 57 | +} |
| 58 | + |
| 59 | +// Configure JaCoCo coverage thresholds to match Maven config |
| 60 | +tasks.jacocoTestCoverageVerification { |
| 61 | + dependsOn(tasks.jacocoTestReport) |
| 62 | + violationRules { |
| 63 | + rule { |
| 64 | + element = "BUNDLE" |
| 65 | + limit { |
| 66 | + counter = "INSTRUCTION" |
| 67 | + value = "COVEREDRATIO" |
| 68 | + minimum = "0.90".toBigDecimal() |
| 69 | + } |
| 70 | + limit { |
| 71 | + counter = "METHOD" |
| 72 | + value = "COVEREDRATIO" |
| 73 | + minimum = "1.00".toBigDecimal() |
| 74 | + } |
| 75 | + limit { |
| 76 | + counter = "BRANCH" |
| 77 | + value = "COVEREDRATIO" |
| 78 | + minimum = "0.90".toBigDecimal() |
| 79 | + } |
| 80 | + limit { |
| 81 | + counter = "COMPLEXITY" |
| 82 | + value = "COVEREDRATIO" |
| 83 | + minimum = "0.90".toBigDecimal() |
| 84 | + } |
| 85 | + limit { |
| 86 | + counter = "LINE" |
| 87 | + value = "COVEREDRATIO" |
| 88 | + minimum = "0.90".toBigDecimal() |
| 89 | + } |
| 90 | + limit { |
| 91 | + counter = "CLASS" |
| 92 | + value = "COVEREDRATIO" |
| 93 | + minimum = "1.00".toBigDecimal() |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + classDirectories.setFrom( |
| 98 | + files(classDirectories.files.map { |
| 99 | + fileTree(it) { |
| 100 | + exclude("**/*Main.*") |
| 101 | + exclude("**/SingleQueueService.*") |
| 102 | + } |
| 103 | + }) |
| 104 | + ) |
| 105 | +} |
| 106 | + |
| 107 | +tasks.check { |
| 108 | + dependsOn(tasks.jacocoTestCoverageVerification) |
| 109 | +} |
| 110 | + |
| 111 | +// Configure shadow JAR for standalone execution |
| 112 | +tasks.shadowJar { |
| 113 | + archiveBaseName.set(project.name) |
| 114 | + archiveClassifier.set("all") |
| 115 | + archiveVersion.set(project.version.toString()) |
| 116 | + manifest { |
| 117 | + attributes["Main-Class"] = application.mainClass.get() |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +// Add task aliases for Maven users |
| 122 | +tasks.register("package") { |
| 123 | + dependsOn(tasks.shadowJar) |
| 124 | + group = "build" |
| 125 | + description = "Creates a standalone executable JAR (alias for shadowJar)" |
| 126 | +} |
| 127 | + |
| 128 | +tasks.register<JavaExec>("exec") { |
| 129 | + group = "application" |
| 130 | + description = "Executes the main class (alias for run)" |
| 131 | + classpath = sourceSets.main.get().runtimeClasspath |
| 132 | + mainClass.set(application.mainClass) |
| 133 | +} |
0 commit comments