Skip to content

STAND-129: Fix build-distro SNAPSHOT resolution in 3.x Standalone#87

Merged
dkayiwa merged 11 commits intoopenmrs:openmrs-emr3from
Muta-Jonathan:STAND-129
Aug 15, 2025
Merged

STAND-129: Fix build-distro SNAPSHOT resolution in 3.x Standalone#87
dkayiwa merged 11 commits intoopenmrs:openmrs-emr3from
Muta-Jonathan:STAND-129

Conversation

@Muta-Jonathan
Copy link
Member

@Muta-Jonathan Muta-Jonathan commented Aug 14, 2025

See https://openmrs.atlassian.net/browse/STAND-129

Description

Problem:

The OpenMRS SDK Maven Plugin build-distro fails for SNAPSHOT versions (e.g., 3.6.0-SNAPSHOT) in CI due to missing directories or unresolved SNAPSHOT artifacts.

Locally, builds may succeed because Maven caches artifacts, but CI consistently fails with artifact null errors.

Solution:

This PR implements a robust approach that works for both local and CI builds:

Pre-create directories for distro artifacts using maven-antrun-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>create-directories</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <mkdir dir="${project.build.directory}/openmrs3x"/>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>

Configure openmrs-sdk-maven-plugin for generate-distro and build-distro:

<plugin>
    <groupId>org.openmrs.maven.plugins</groupId>
    <artifactId>openmrs-sdk-maven-plugin</artifactId>
    <version>6.5.0</version>
    <executions>
        <execution>
            <id>generate-distro</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate-distro</goal>
            </goals>
            <configuration>
                <outputLocation>${project.build.directory}/openmrs3x</outputLocation>
                <batchAnswers>
                    <batchAnswer>Reference Application 3.x</batchAnswer>
                    <batchAnswer>${refapp.version}</batchAnswer>
                </batchAnswers>
                <testMode>true</testMode>
            </configuration>
        </execution>
        <execution>
            <id>openmrs-sdk:build-distro</id>
            <goals>
                <goal>build-distro</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <distro>${project.build.directory}/openmrs3x/openmrs-distro.properties</distro>
                <dir>${project.build.directory}/distro</dir>
            </configuration>
        </execution>
    </executions>
</plugin>

CI pre-run step:

Before running Maven goals in CI, ensure the SDK is set up non-interactively with proper settings:

- name: Pre-run OpenMRS SDK Plugin
  run: mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:6.5.0:setup-sdk -B --settings .github/maven-settings.xml -DinteractiveMode=false -DstatsEnabled=false

Benefits:

  • Works consistently for SNAPSHOT and release versions locally and in CI.

  • Eliminates artifact null errors.

  • Does not change the developer workflow for local builds.

Testing:

  • ✅ Local build: mvn clean package -Drefapp.version=3.6.0-SNAPSHOT succeeds.

  • ✅ Local build: mvn clean package -Drefapp.version=3.6.0-SNAPSHOT succeeds.

  • ✅ CI build passes after pre-running setup-sdk.

@Muta-Jonathan Muta-Jonathan marked this pull request as draft August 14, 2025 14:12
@Muta-Jonathan Muta-Jonathan changed the title Testing out the snapShot Error Not fetching STAND-129: Fix build-distro SNAPSHOT resolution in 3.x Standalone Aug 15, 2025
@Muta-Jonathan Muta-Jonathan marked this pull request as ready for review August 15, 2025 04:43
@Muta-Jonathan
Copy link
Member Author

cc @wikumChamith @dkayiwa @mherman22

Co-authored-by: Herman Muhereza <hermanmuhereza22@gmail.com>
run: docker compose version

- name: Pre-run OpenMRS SDK Plugin
run: mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:6.5.0:setup-sdk -B --settings .github/maven-settings.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intentionally hard code 6.5.0?

Copy link
Member Author

@Muta-Jonathan Muta-Jonathan Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes because by default this was fetching 5.5.4 version instead of the latest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we shall be updating this everytime the sdk is released?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh makes sense should be this way let me see how to specify it in a generic way

@Muta-Jonathan
Copy link
Member Author

cc @dkayiwa this change fixes the issue

- name: Verify Docker Compose installation
run: docker compose version

- name: Pre-run OpenMRS SDK Plugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we now need this in the standalone but not in the SDK?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the Standalone build uses the SDK Maven plugin to generate and build the distro, it needs a pre-configured SDK environment — which the local machine already has but CI doesn’t. The SDK project itself just builds the tool, so it doesn’t require that setup to compile.

@dkayiwa dkayiwa merged commit c43fe9c into openmrs:openmrs-emr3 Aug 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants