diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java index b9c50c92..a8be8884 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java @@ -294,9 +294,9 @@ private String buildDistro(File targetDirectory, Artifact distroArtifact, Distro File owasDir = new File(tempDir, "bundledOwas"); owasDir.mkdir(); - downloadOWAs(targetDirectory, distroProperties, owasDir); - downloadContents(web, distroProperties); + downloadOWAs(targetDirectory, distroProperties, owasDir); spaInstaller.installFromDistroProperties(tempDir, distroProperties, ignorePeerDependencies, overrideReuseNodeCache); + installContentConfiguration(web, distroProperties); File frontendDir = new File(tempDir, "frontend"); if(frontendDir.exists()) { frontendDir.renameTo(new File(tempDir, "bundledFrontend")); @@ -325,7 +325,7 @@ private String buildDistro(File targetDirectory, Artifact distroArtifact, Distro File configDir = new File(web, SDKConstants.OPENMRS_SERVER_CONFIGURATION); configDir.mkdir(); setConfigFolder(configDir, distroProperties, distroArtifact); - downloadContents(web, distroProperties); + installContentConfiguration(web, distroProperties); spaInstaller.installFromDistroProperties(web, distroProperties, ignorePeerDependencies, overrideReuseNodeCache); File owasDir = new File(web, "owa"); @@ -622,7 +622,7 @@ public boolean accept(File dir, String name) { } } - private void downloadContents(File web, DistroProperties distroProperties) throws MojoExecutionException { + private void installContentConfiguration(File web, DistroProperties distroProperties) throws MojoExecutionException { ContentHelper contentHelper = new ContentHelper(web); File tempContentDirectory = new File(web, "temp_content"); 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 3df0cc82..205080d9 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 @@ -14,6 +14,7 @@ import org.openmrs.maven.plugins.model.DistroProperties; import org.openmrs.maven.plugins.model.Server; import org.openmrs.maven.plugins.model.Version; +import org.openmrs.maven.plugins.utility.ContentHelper; import org.openmrs.maven.plugins.utility.DBConnector; import org.openmrs.maven.plugins.utility.DistroHelper; import org.openmrs.maven.plugins.utility.SDKConstants; @@ -279,6 +280,7 @@ public void setup(Server server, DistroProperties distroProperties) throws MojoE distroHelper.parseContentProperties(distroProperties); moduleInstaller.installModulesForDistro(server, distroProperties, distroHelper); setConfigFolder(server, distroProperties); + installContentConfiguration(server, distroProperties); if (spaInstaller != null) { spaInstaller.installFromDistroProperties(server.getServerDirectory(), distroProperties, ignorePeerDependencies, overrideReuseNodeCache); } @@ -330,7 +332,7 @@ private void installOWAs(Server server, DistroProperties distroProperties) throw owasDir.mkdir(); downloadOWAs(server.getServerDirectory(), distroProperties, owasDir); } - } + } private void downloadOWAs(File targetDirectory, DistroProperties distroProperties, File owasDir) throws MojoExecutionException { @@ -343,7 +345,24 @@ private void downloadOWAs(File targetDirectory, DistroProperties distroPropertie } } } - + + private void installContentConfiguration(Server server, DistroProperties distroProperties) throws MojoExecutionException { + if (distroProperties != null) { + File tempContentDir = new File(server.getServerDirectory(), "temp-content"); + tempContentDir.mkdir(); + List contents = distroProperties.getContentArtifacts(distroHelper, tempContentDir); + ContentHelper contentHelper = new ContentHelper(server.getServerDirectory()); + + if (!contents.isEmpty()) { + for (Artifact content : contents) { + wizard.showMessage("Downloading Content: " + content + "\n"); + contentHelper.downloadContent(content, moduleInstaller, tempContentDir); + } + } + FileUtils.deleteQuietly(tempContentDir); + } + } + /** * Sets the configuration folder for the specified server using the provided distro properties. *