diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java index 8f310dea..0c7970cd 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java @@ -145,6 +145,9 @@ public class Setup extends AbstractServerTask { @Parameter(property = "appShellVersion") private String appShellVersion; + @Parameter(property = "ignorePeerDependencies", defaultValue = "false") + private boolean ignorePeerDependencies; + private ServerHelper serverHelper; public Setup() { @@ -285,7 +288,7 @@ public void setup(Server server, DistroProperties distroProperties) throws MojoE moduleInstaller.installModulesForDistro(server, distroProperties, distroHelper); setConfigFolder(server, distroProperties); if (spaInstaller != null) { - spaInstaller.installFromDistroProperties(server.getServerDirectory(), distroProperties); + spaInstaller.installFromDistroProperties(server.getServerDirectory(), distroProperties, ignorePeerDependencies); } installOWAs(server, distroProperties); } else { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/NodeHelper.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/NodeHelper.java index db2316ea..7e7bb900 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/NodeHelper.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/NodeHelper.java @@ -59,23 +59,27 @@ public void installNodeAndNpm(String nodeVersion, String npmVersion) throws Mojo } public void runNpx(String arguments) throws MojoExecutionException { - String npmExec = "exec -- " + arguments; - + runNpx(arguments, ""); + } + + public void runNpx(String arguments, String legacyPeerDeps) throws MojoExecutionException { + String npmExec = legacyPeerDeps + " exec -- " + arguments; + // it's a little weird to use a custom NPM cache for this; however, it seems to be necessary to get things working on Bamboo // hack added in December 2021; it's use probably should be re-evaluated at some point // additional hack: we do not use --cache on macs due to https://github.com/npm/cli/issues/3256 if (mavenProject != null && mavenProject.getBuild() != null && !SystemUtils.IS_OS_MAC_OSX) { npmExec = - " --cache=" + tempDir.resolve("npm-cache").toAbsolutePath() + " exec -- " + arguments; + legacyPeerDeps + " --cache=" + tempDir.resolve("npm-cache").toAbsolutePath() + " exec -- " + arguments; } - + List configuration = new ArrayList<>(3); configuration.add(element("arguments", npmExec)); - + if (mavenProject != null && mavenProject.getBuild() != null) { configuration.add(element("installDirectory", tempDir.toAbsolutePath().toString())); } - + runFrontendMavenPlugin("npm", configuration); } diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SpaInstaller.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SpaInstaller.java index b5462d8b..797ce02d 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SpaInstaller.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SpaInstaller.java @@ -47,6 +47,12 @@ public SpaInstaller(DistroHelper distroHelper, public void installFromDistroProperties(File appDataDir, DistroProperties distroProperties) throws MojoExecutionException { + installFromDistroProperties(appDataDir, distroProperties, false); + } + + public void installFromDistroProperties(File appDataDir, DistroProperties distroProperties, boolean ignorePeerDependencies) + throws MojoExecutionException { + // We find all the lines in distro properties beginning with `spa` and convert these // into a JSON structure. This is passed to the frontend build tool. // If no SPA elements are present in the distro properties, the SPA is not installed. @@ -74,14 +80,15 @@ public void installFromDistroProperties(File appDataDir, DistroProperties distro nodeHelper.installNodeAndNpm(nodeVersion, npmVersion); File buildTargetDir = new File(appDataDir, BUILD_TARGET_DIR); - + String program = "openmrs@" + coreVersion; + String legacyPeerDeps = ignorePeerDependencies ? "--legacy-peer-deps" : ""; // print frontend tool version number - nodeHelper.runNpx(String.format("%s --version", program)); + nodeHelper.runNpx(String.format("%s --version", program), legacyPeerDeps); nodeHelper.runNpx( - String.format("%s build --target %s --build-config %s", program, buildTargetDir, spaConfigFile)); + String.format("%s build --target %s --build-config %s", program, buildTargetDir, spaConfigFile), legacyPeerDeps); nodeHelper.runNpx( - String.format("%s assemble --target %s --mode config --config %s", program, buildTargetDir, spaConfigFile)); + String.format("%s assemble --target %s --mode config --config %s", program, buildTargetDir, spaConfigFile), legacyPeerDeps); } }