OpenMRS Maven Parent

OpenMRS Maven modules are often based on the Maven Parent we publish. You can recognize this if the base POM of your module has something like this:

    <parent>
        <groupId>org.openmrs.maven.parents</groupId>
        <artifactId>maven-parent-openmrs-module</artifactId>
        <version>...</version>
    </parent>

This parent project ensures some basic sanity and, most importantly, that the OMOD plugin is part of the standard build cycle. However, this parent project has not had substantive updates since 2016, though it has had some minor updates. Obviously, that’s less than ideal.

So, the point of this post is to announce two new versions of the parent currently available and a strategy to maintain this going forward.

The two versions

So today, there are now two new versions: 1.1.2 and 2.0.0-SNAPSHOT.

1.1.2

1.1.2 is a minor adjustment to the current widely-used version 1.1.1. Basically, it refactored things so that modules inherit test dependencies (JUnit, Mockito, PowerMock, etc.) from the version of the platform they are built for rather than the previous behaviour where the parent held these at fixed (and very old) versions.

The one two slightly breaking changes are that 1.1.2 requires Java 8 as a minimum and assumes you are running platform 2.0.0 or higher. The first assumption is a “hard” requirement. The second assumption is overrideable, and it should be possible to use 1.1.2 with pre-2.0.0 platforms as long as they support Java 8.

2.0.0-SNAPSHOT

Despite the version number bump, 2.0.0-SNAPSHOT is mostly backwards-compatible with the 1.x line and is primarily about ensuring that: 1) all Maven plugins have defined versions, as Maven recommends and 2) that these plugins are updated to the latest versions. However, there are three changes that module authors should be aware of:

  1. The 1.x parent used the Google Formatter Maven plugin (at least theoretically) to ensure that code is formatted according to our published formatter. This plugin has been deprecated as Google themselves have largely moved to a newer system called Spotless. 2.0.0-SNAPSHOT adopts Spotless for formatting. Nominally, this should be a change without a difference as it uses the exact same formatter definition, but there may be some changes due to this (mostly I’ve noticed the old formatter doesn’t always seem to be bound to the lifecycle correctly).
  2. The 1.x line of modules used javaCompilerSource and javaCompilerTarget to set the Maven Compiler Version. Support for these properties has been dropped in favour of the maven.source.version and maven.target.version properties that are the standard mechanism for controlling these variables.
  3. There is a setting openmrsPlatformToolsVersion which controls the “tooling version” of the platform, which mostly is about the version of the formatter the module uses. In 1.x, this property was independent of the openmrsPlatformVersion, which controls the version of the openmrs-api and openmrs-web packages available. In 2.x, by default the openmrsPlatformToolsVersion is identical to the openmrsPlatformVersion, though it remains overrideable.

Some adaptations to the SDK’s archetypes will be needed to properly work with 2.0.0-SNAPSHOT and some adjustments to the parent may be necessary to do this in the most repeatable way. Once those SDK changes are available and tested, we’ll likely release the “2.0.0” version of the parent and start migrating modules to it. We’ll also be configuring the 2.0.0 branch to track the latest versions of Maven plugins at least for pre-Maven 4 plugins (Maven 4 will likely require additional migration effort).

3 Likes