Verified Commit d1259ec7 authored by Alexander Staeding's avatar Alexander Staeding
Browse files

Update template

parent ead1b95f
......@@ -77,5 +77,3 @@ out/
gradle-app.setting
!gradle-wrapper.jar
.gradletasknamecache
.git/
plugins {
java
application
}
// do not change assignmentId
val assignmentId: String by extra("H05")
val studentId: String by extra("_not_set_") // TU-ID z.B. ab12cdef
val firstName: String by extra("_not_set_")
val lastName: String by extra("_not_set_")
// !! Achtung !!
// Die studentId (TU-ID) ist keine Matrikelnummer
// Richtig z.B. ab12cdef
// Falsch z.B. 1234567
repositories {
mavenCentral()
}
dependencies {
// JUnit only available in "test" source set (./src/test)
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
application {
mainClass.set("h05.Main")
}
tasks {
create<Jar>("prepareSubmission") {
dependsOn(test) // run tests before creating submission
doFirst {
if (firstName == "_not_set_" || lastName == "_not_set_") {
throw GradleException("firstName or lastName not set!")
if (studentId == "_not_set_" || firstName == "_not_set_" || lastName == "_not_set_") {
throw GradleException("studentId or firstName or lastName not set!")
}
}
// include source files in output jar
from(sourceSets.main.get().allSource)
from(sourceSets.main.get().allSource, sourceSets.test.get().allSource)
// replace placeholders in resource directory
// e.g. the submission-info.json file
filesMatching("submission-info.json") {
......@@ -23,4 +50,7 @@ tasks {
// set the name of the output jar
archiveFileName.set("$assignmentId-$lastName-$firstName-submission.jar")
}
test {
useJUnitPlatform()
}
}
{
"assignmentId": "$assignmentId",
"studentId": "$studentId",
"firstName": "$firstName",
"lastName": "$lastName"
}
package h05;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ExampleJUnitTest {
@Test
public void testAddition() {
assertEquals(2, 1 + 1);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment