The goal of this assignment is primarily to ensure that you have a working dev environment set up.
-
Download the ZIP file containing the assignment project, or clone it from Github
-
Try to build -- the tests will fail.
On Mac/Linux:
./gradlew build
On Windows:
.\gradlew.bat build
-
In
src/main/java/HelloWorld.java
, follow the instructions markedTODO
. -
Build again, the tests should pass.
-
In
build.gradle.kts
, change theYOUR_NAME
variable to be your name, with_
instead of spaces -
Run the
prepareAssignment
task to build a ZIP file to submit.
Starting from the top:
- Plugins add or enable specific functionality in gradle. Here, we're using the
application
plugin, which basically says "this is a Java project and we're going to want to run a particular class" - Set your name 🙂
group
would be used if we were publishing our jar, but we aren't, so we can just leave this.version
gets used in the name of our jarrepositories
means "look for our dependencies in mavenCentral"- The
dependencies
block (unsurprisingly) defines our dependencies. We have dependencies that belong to two different configurations:testImplementation
are the dependencies we need to implement (i.e. build) our tests.assertj-core
is the library I'm using to make assertions in the tests. JUnit comes with its own assertions library, but AssertJ offers a few more features.junit-jupiter-api
is the JUnit5 library
testRuntimeOnly
are the dependencies that we need to run our tests, btu that we don't actually need at build time. This is just the JUnit5 "engine".
- The
application
block is declaring that the class that should be run from our jar is theHelloWorld
class. - The next section configures the
test
task. First, we tell gradle we should be using JUnit to run our tests. Second, we configure the test logging so that it gives detailed errors. - The next section creates a new gradle task
packageAssignment