-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OZ-462: Ozone distro to repackage the O3 frontend (#42)
- Loading branch information
Showing
7 changed files
with
319 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd"> | ||
<id>zip-scripts-dir</id> | ||
<formats> | ||
<format>zip</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<outputDirectory>.</outputDirectory> | ||
<directory>${project.build.directory}/${project.artifactId}-${project.version}</directory> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
47 changes: 47 additions & 0 deletions
47
scripts/openmrs/frontend_assembly/build-openmrs-frontend.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
Oops, something went wrong.