Upgrade grading for an existing Java Gradle exercise
Use this guide for a plain Java Gradle exercise with Ares 2 and LocalCI. Artemis stores each exercise’s grading files in its Test repository and its phase commands in its build plan. An Artemis upgrade leaves both in place. Updating them speeds up future builds on the regular Java image. Students keep their repositories and can continue submitting as usual.
Record the starting point
- Open the exercise in course management. Under Repositories and builds, open Edit build plan. Save the current image tag, phase scripts, inclusion conditions, result paths and Tests expected settings. Note which phases run after a failure.
- Record the current commit of the Test repository. Rebuild the solution and template. Save their test names, scores and, if enabled, static analysis findings.
- To measure the speedup, rebuild the same solution several times. Record the Duration in Finished Build Jobs, the build agent and the times for compile, test and static analysis. Keep the image tag, solution revision and exercise settings fixed for the comparison.
Update the Test repository
Create a temporary reference exercise on an Artemis instance with the updated template. Choose the same Java Gradle project type, checkout paths, static analysis and sequential-test settings as the existing exercise. If your production instance is awaiting the update, you can generate the reference on an updated test instance. The template source on GitHub contains placeholders that Artemis fills during exercise creation.
Compare the two Test repositories and port the relevant changes to the existing exercise’s build.gradle:
- Remove the Teamscale coverage plugin and its coverage configuration if the exercise uses the standard JUnit grading reports. If a custom grading task reads coverage data, check that dependency before removing coverage.
- Keep the Ares agent, Ares dependencies on the compile and runtime classpaths, and the reserved-package checks. The updated script puts only the Ares JAR from its dependency tree on the AspectJ aspect path. Preserve any aspects your exercise adds separately.
- For static analysis, port the matching configuration from the reference, including its plugin classpath settings. Keep the existing rules, source sets, tests,
SecurityPolicy.yaml, custom dependencies and configured repository mirror.
Review the diff, commit it and push it to the existing Test repository. A push can trigger grading, so review the build plan as part of the same update.
Update the LocalCI phases
In Repositories and builds → Edit build plan, keep the current Java image. Paste each script into its own phase. Preserve each Inclusion condition, especially After due date for deferred tests. These commands use the JVM settings supplied by the instructor when present.
Compile
Leave Tests expected off.
chmod +x ./gradlew
JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:--XX:TieredStopAtLevel=1 -XX:+UseSerialGC}" ./gradlew clean compileJava compileTestJava
Test
Turn Tests expected on and set Result paths to **/test-results/test/*.xml. For sequential or custom test suites, keep their individual tasks, source sets, result paths and inclusion conditions. Apply the same JVM options to each corresponding Gradle command.
chmod +x ./gradlew
JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:--XX:TieredStopAtLevel=1 -XX:+UseSerialGC}" ./gradlew test
Static code analysis, when enabled
Keep Execute at end regardless of previous failures enabled and retain the existing analysis result paths. The standard plan collects target/spotbugsXml.xml, target/checkstyle-result.xml, target/pmd.xml and target/cpd.xml.
chmod +x ./gradlew
JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:--XX:TieredStopAtLevel=1 -XX:+UseSerialGC}" ./gradlew check -x test
Save the plan. These commands allow Gradle to fetch missing plugins or dependencies from the configured repositories when network access permits. For an exercise that requires offline builds, verify all phases in a fresh container with networking disabled and --offline immediately after ./gradlew. The chosen image must contain the distribution and the direct and transitive dependencies for every enabled phase.
Verify the upgrade
| Check | What to compare |
|---|---|
| Solution and template | Rebuild both and compare test names, scores and static analysis findings with the saved results. |
| Compile and test feedback | On a disposable copy, a syntax error should produce a file and line in Compile. A failed assertion should reach Test and name the failing test. |
| Timing | Repeat the same solution builds and compare median whole-job and phase durations. Note image pulls or unusually busy agents. |
If grading changes unexpectedly, revert the grading-file commit in the Test repository, restore the saved build plan and image, and rebuild the solution and template to confirm the previous results.
Optional prepared image
For the standard two-phase plan, an administrator can supply a matching, versioned <release>-gradle image. First verify the upgrade on the regular Java image. To use the prepared image, align build.gradle, settings.gradle, the wrapper and applied scripts with the generated reference. Select the image in Edit build plan and rebuild the solution. Look for Reusing configuration cache in both phase logs. Custom mirrors, tasks and plugins can prevent reuse. Use the regular Java image for exercises with static analysis.