-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OZ-462: Ozone distro to repackage the O3 frontend #42
Merged
rbuisson
merged 6 commits into
ozone-his:main
from
ibacher:ozone-to-allow-frontend-overrides
Feb 16, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9964f58
OZ-462: Ozone distro to repackage the O3 frontend
ibacher 5c52ea3
Update build to include environment variables
ibacher 0f545b2
(partial) Ozone now builds the frontend locally
ibacher 77ada67
Merge remote-tracking branch 'origin/main' into ozone-to-allow-fronte…
ibacher 7b58297
Refactor - scripts package
ibacher 69212db
Update description
ibacher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this path correct?
I thought the frontend assembly config file was moved to
scripts/
.Anyway, I don't see it in
/configs/openmrs/frontend_assembly
either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step copies the implementation-specific
spa-assemble-config.json
file, if any. I didn't change that location, but I can if it makes more sense inscripts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK we can leave it at this place.
But shouldn't this be
distro/configs/openmrs/frontend_assembly
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the implementation-specific projects, we usually don't have a
distro
sub-folder...