Building the code

This is a java code base originally built with Netbeans IDE 12.3, Java openjdk 11.0.11 but it should be buildable with any IDE. Java 8 is the minimum required JDK since features such as streams are used. For no other reason than to get practice with them. Building is by the Maven tool controlled by the top level pom.xml file.

Obtain a copy

Git clone the codebase from the bitbucket repository This should create a directory “zodiac-empire” with subdirectories “src”, “target”

All of the required source code, resources and documents (including these instructions) are in under the src folder, running maven creates everything in the target directory.

Load the project into your IDE using the maven pom.xml. Doing so should update your local Maven repository with required libraries and dependencies.

Directory structure

The structure is a standard Maven layout, key locations are:

  • src/main/java/ = source code
  • src/main/resources/ = deliverable resources for the game, images, configs etc.
  • zodiac.xml = game configuration
  • src/site/ = source code of documentation
  • dia/ = Dia diagrams, built into PNG images for use in documentation
  • markdown/ = these markdown documentation files built into HTML
  • site.xml = configures the site layout
  • doxygen.cfg = manually build a doxygen with “doxygen doxygen.cfg”, this can be another tool to understand the code structure.
  • src/test/java/ = source code of test packages
  • src/test/resources/ = resources specific for testing in the same layout as src/main/resources

which is compiled or built into the target directories

  • target/

Compiling

Use the IDE to compile the project, it creates a finished product “zodiac-empire.jar” in the “target” directory, this can be run as any Java program.

Before modifying any code it’s a very good idea to ensure a clean build and that all unit tests pass. That way you know problems are in your modified code.

Testing

There are unit tests available using JUnit5.

Most classes have associated JUnit test classes under the src/test directory and as a byproduct the tests also provide examples of how to make use of the various classes.

In modern software development, tests are part of the product and while there is debate about when they should be written, there is little debate about the fact they should be. In developing this code the tests were written in parallel with classes to explore potential designs, the tests expose how a class might actually be used. This can suggest a more efficient interface for practical usage.

Unit tests are designed to be quick and focused on a single class and aim to have minimal dependencies.

TestSuites exist to allow subsets of the codebase to be tested.

Integration testing

These are unit tests using JUnit5 that take longer to complete and typically involve a combination of classes. They are alongside the unit tests but are named with a ‘IT.java’ suffix.

Documentation and site building

The documentation is built as part of the Maven process using the maven-javadoc-plugin reporting plugin. Javadoc is built into target/site/zodiac-empire/apidocs directory. Note the extra sub-directory, this is to facilitate the maven-scm-publish-plugin.

The site documentation is also built using Maven maven-site-plugin generating into target/site/zodiac-empire. The Maven POM also ensures among other tasks, that any .dia diagrams in the src/site/dia folder are converted into .png and placed under the target folder ready for use in the site documentation.

The site documentation is deployed to a HTML website via the maven-scm-publish-plugin.

License

License management is provided by the license-maven-plugin. It uses provided templates src/site/resources/license to add license details to each file when run.

Hints

Maven