Skip to content

Alternative Configuration Mechanisms

Ben Nordick edited this page May 14, 2020 · 2 revisions

Throughout this tutorial we used the checkpoint and useProvided settings in a student configuration YAML file to set which/whether provided components were enabled. This is likely the most convenient approach, especially if integrating with GradleGrader. There are, however, alternative ways to set which functionality to swap out, and I document them here for completeness.

Property-based configuration

Gradle has several ways to pass properties to the project when performing a build. If an empire.replace project property exists, eMPire will treat its value as a comma-separated list of segments to enable. For example, if running from the command line:

gradlew :app:testDebugUnitTest -Pempire.replace=arithmetic,welcome

It is not necessary to define any checkpoints if using this strategy. If you want to specify a checkpoint—which you must to enable opportunistic compilation—you can instead pass its ID as the value of the empire.checkpoint property.

YAML-based configuration

The useProvided property is technically optional and defaults to true. Of course, if it is set to false, no replacements will be done regardless of the other contents of the file.

You can, instead of a checkpoint property, have a segments property that is a map of segment IDs to whether they should be enabled, i.e. have their functionality provided. Segments missing from this map will be disabled. For example:

segments:
  arithmetic: true
  accumulator: false
  polynomial: false
  welcome: false

While more flexible, this strategy allows a combinatorial explosion of possibilities which may be very time-consuming for you to test. If one class is revised in multiple checkpoints, you might provide mutually exclusive segments (representing different versions of the class) that students shouldn't be able to enable simultaneously. You must also be careful that students cannot enable provided components for the part of the project you're currently grading. Therefore, the student segments map is ignored unless you call allowArbitrarySegmentCombination() in the eMPire Gradle configuration block.

Clone this wiki locally