diff --git a/distro/pom.xml b/distro/pom.xml
index 01df51c..d21c262 100644
--- a/distro/pom.xml
+++ b/distro/pom.xml
@@ -28,7 +28,7 @@
UTF-8
- 3.0.0-beta.16
+ 3.0.0-SNAPSHOT
2.1.0
1.4.0-SNAPSHOT
2.2.0
@@ -52,6 +52,13 @@
${referenceapplicationDistroVersion}
+
+ org.openmrs.distro
+ referenceapplication-frontend
+ zip
+ ${referenceapplicationDistroVersion}
+
+
net.mekomsolutions.odoo
@@ -96,7 +103,6 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.2.0
Copy Odoo Initializer add-on
@@ -183,6 +189,18 @@
+
+ Unpack OpenMRS Ref App frontend configuration
+ generate-resources
+
+ unpack-dependencies
+
+
+ true
+ ${project.build.directory}/openmrs_frontend
+ referenceapplication-frontend
+
+
@@ -310,6 +328,26 @@
+
+ Rename spa-assemble-config.json to reference-application-spa-assemble-config.json
+ generate-resources
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run
+
+
+
Copy filtered OpenMRS configuration
prepare-package
@@ -326,6 +364,7 @@
run
+
Copy filtered OpenMRS modules
prepare-package
@@ -362,6 +401,25 @@
+
+ org.codehaus.gmavenplus
+ gmavenplus-plugin
+
+
+ Build OpenMRS Frontend
+
+ execute
+
+ process-resources
+
+
+
+
+
+
+
+
+
org.apache.maven.plugins
diff --git a/maven-commons/pom.xml b/maven-commons/pom.xml
index 1229799..f490c44 100644
--- a/maven-commons/pom.xml
+++ b/maven-commons/pom.xml
@@ -27,6 +27,7 @@
UTF-8
8
8
+ 4.0.18
@@ -61,6 +62,31 @@
build-helper-maven-plugin
3.5.0
+
+ org.codehaus.gmavenplus
+ gmavenplus-plugin
+ 3.0.2
+
+
+ org.apache.groovy
+ groovy
+ ${maven.groovy.version}
+ runtime
+
+
+ org.apache.groovy
+ groovy-ant
+ ${maven.groovy.version}
+ runtime
+
+
+ org.apache.groovy
+ groovy-json
+ ${maven.groovy.version}
+ runtime
+
+
+
org.openmrs.maven.plugins
openmrs-packager-maven-plugin
diff --git a/maven-parent/pom.xml b/maven-parent/pom.xml
index 2839381..8f57505 100644
--- a/maven-parent/pom.xml
+++ b/maven-parent/pom.xml
@@ -40,6 +40,12 @@
zip
${ozone.version}
+
+ com.ozonehis
+ ozone-scripts
+ zip
+ ${ozone.version}
+
@@ -61,6 +67,18 @@
ozone
+
+ Unpack Ozone Scripts
+ generate-resources
+
+ unpack-dependencies
+
+
+ true
+ ${project.build.directory}
+ ozone-scripts
+
+
@@ -94,6 +112,49 @@
+
+
+ Copy reference-application-spa-assemble-config.json to local working directory
+ generate-resources
+
+ copy-resources
+
+
+ ${project.build.directory}/openmrs_frontend
+ true
+
+
+ ${project.build.directory}/ozone/distro/configs/openmrs/frontend_assembly
+ false
+
+
+
+
+
+
+
+ Copy spa-assemble-config.json
+ generate-resources
+
+ copy-resources
+
+
+
+ ${project.build.directory}/openmrs_frontend
+
+ true
+
+
+ ${project.basedir}/configs/openmrs/frontend_assembly
+
+ spa-assemble-config.json
+
+ false
+
+
+
+
+
Copy and substitute some helper files
@@ -182,6 +243,25 @@
+
+
+ org.codehaus.gmavenplus
+ gmavenplus-plugin
+
+
+ Rebuild OpenMRS Frontend if necessary
+
+ execute
+
+ process-resources
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index bb08dd6..5973af8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,6 +40,7 @@
maven-commons
maven-parent
+ scripts
distro
diff --git a/scripts/assembly.xml b/scripts/assembly.xml
new file mode 100644
index 0000000..ffdc272
--- /dev/null
+++ b/scripts/assembly.xml
@@ -0,0 +1,16 @@
+
+
+ zip-scripts-dir
+
+ zip
+
+ false
+
+
+ .
+ ${project.build.directory}/${project.artifactId}-${project.version}
+
+
+
\ No newline at end of file
diff --git a/scripts/openmrs/frontend_assembly/build-openmrs-frontend.groovy b/scripts/openmrs/frontend_assembly/build-openmrs-frontend.groovy
new file mode 100644
index 0000000..980c844
--- /dev/null
+++ b/scripts/openmrs/frontend_assembly/build-openmrs-frontend.groovy
@@ -0,0 +1,47 @@
+import java.nio.file.Paths
+
+log.info("Checking for frontend customizations in ${Paths.get("${project.build.directory}", "openmrs_frontend", "spa-assemble-config.json").toString()}")
+
+def refAppConfigFile = Paths.get("${project.build.directory}", "openmrs_frontend", "reference-application-spa-assemble-config.json").toFile()
+def slurper = new groovy.json.JsonSlurper()
+def refAppConfig = slurper.parse(refAppConfigFile)
+def openmrsVersion = refAppConfig["coreVersion"] ?: "next"
+
+def assembleCommand = "npx --legacy-peer-deps openmrs@${openmrsVersion} assemble --manifest --mode config --target ${project.build.directory}/${project.artifactId}-${project.version}/binaries/openmrs/frontend --config ${refAppConfigFile.getAbsolutePath()}"
+log.info("Project: ${project.groupId}:${project.artifactId}")
+// by default, we build the frontend as part of Ozone and only rebuild if there are local customizations
+def shouldBuildFrontend = "${project.groupId}" == "com.ozonehis" && "${project.artifactId}" == "ozone-distro"
+
+if (!shouldBuildFrontend) {
+ frontendCustomizationsFile = Paths.get("${project.build.directory}", "openmrs_frontend", "spa-assemble-config.json").toFile()
+ if (frontendCustomizationsFile.exists()) {
+ log.info("Found frontend customizations. Rebuilding frontend...")
+
+ assembleCommand += "--config ${frontendCustomizationsFile.getAbsolutePath()}"
+ shouldBuildFrontend = true
+ }
+}
+
+if (shouldBuildFrontend) {
+ log.info("Running assemble command...")
+
+ def assembleProcess = assembleCommand.execute()
+ assembleProcess.consumeProcessOutput(System.out, System.err)
+ assembleProcess.waitFor()
+
+ if (assembleProcess.exitValue() != 0) {
+ throw new RuntimeException("'openmrs assemble' step failed. See previous messages for details.")
+ }
+
+ log.info("Running build command...")
+
+ def buildProcess = "npx --legacy-peer-deps openmrs@${openmrsVersion} build --config-url \$SPA_CONFIG_URLS --default-locale \$SPA_DEFAULT_LOCALE --target ${project.build.directory}/${project.artifactId}-${project.version}/binaries/openmrs/frontend".execute()
+ buildProcess.consumeProcessOutput(System.out, System.err)
+ buildProcess.waitFor()
+
+ if (buildProcess.exitValue() != 0) {
+ throw new RuntimeException("'openmrs build' step failed. See previous messages for details.")
+ }
+} else {
+ log.info("No need to re-build the frontend detected")
+}
\ No newline at end of file
diff --git a/scripts/pom.xml b/scripts/pom.xml
new file mode 100644
index 0000000..846844e
--- /dev/null
+++ b/scripts/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+
+ com.ozonehis
+ maven-commons
+ 1.0.0-SNAPSHOT
+ ../maven-commons
+
+
+ ozone-scripts
+ Ozone Scripts
+ Shared utility scripts for Ozone
+ pom
+
+
+ Ozone HIS
+ https://www.ozone-his.com
+
+
+
+ Mekom Solutions
+ https://www.mekomsolutions.com
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+
+ Copy local scripts
+ prepare-package
+
+ copy-resources
+
+
+
+ ${project.build.directory}/${project.artifactId}-${project.version}
+ true
+
+
+ ${project.basedir}/../scripts
+
+
+ openmrs/frontend_assembly/build-openmrs-frontend.groovy
+
+
+ go-to-scripts-dir.sh
+
+
+ set-ozone-dir.sh
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ Package scripts artifact
+ package
+
+ single
+
+
+ false
+
+ assembly.xml
+
+
+
+
+
+
+
+
\ No newline at end of file