Skip to content

Commit d10c83d

Browse files
committed
migrated entire project to Gradle Kotlin syntax
Signed-off-by: Konstantin Läufer <laufer@cs.luc.edu>
1 parent 8d61989 commit d10c83d

13 files changed

Lines changed: 865 additions & 150 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
- name: Run tests
30+
run: ./gradlew test
31+
- name: Create standalone JAR
32+
run: ./gradlew shadowJar

.github/workflows/maven.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
1+
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
33

4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Java CI with Maven
4+
name: Java CI with Gradle
105

116
on:
127
push:
@@ -19,12 +14,19 @@ jobs:
1914

2015
runs-on: ubuntu-latest
2116

17+
permissions:
18+
contents: read
19+
2220
steps:
2321
- uses: actions/checkout@v4
24-
- name: Setup Maven Action
25-
uses: s4u/setup-maven-action@v1.18.0
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v4
2624
with:
2725
java-version: '21'
28-
java-distribution: 'temurin'
29-
- name: Build with Maven
30-
run: mvn -B package --file pom.xml
26+
distribution: 'temurin'
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
- name: Run tests
30+
run: ./gradlew test
31+
- name: Create standalone JAR
32+
run: ./gradlew shadowJar

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ gen/
1414
logs/
1515
proguard_cache/
1616
target/
17+
build/
18+
.gradle/
1719
tmp/
1820

1921
# Local configuration file (sdk path, etc)

.gitpod.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ By entering customers' names at different rates, try to create scenarios where c
4040

4141
To run the tests:
4242

43-
mvn verify
43+
./gradlew test
4444

4545
To run the main program:
4646

47-
mvn exec:java
47+
./gradlew run
48+
49+
For more Gradle commands and migration details, see [doc/GRADLE-MIGRATION.md](doc/GRADLE-MIGRATION.md).
4850

4951
## Grading (total 6 points)
5052

build.gradle.kts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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

Comments
 (0)