Skip to content

Commit

Permalink
Installing OWAs on Setup - SDK-250
Browse files Browse the repository at this point in the history
  • Loading branch information
dkayiwa committed Feb 10, 2020
1 parent cdf9372 commit a7a5334
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.openmrs.maven.plugins.utility.DistroHelper;
import org.openmrs.maven.plugins.utility.SDKConstants;
import org.openmrs.maven.plugins.utility.ServerHelper;
import org.openmrs.maven.plugins.bintray.OpenmrsBintray;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -175,9 +176,11 @@ public String setup(Server server, boolean isCreatePlatform, boolean isCopyDepen
distroProperties = distroHelper.downloadDistroProperties(serverPath, platform);
distroProperties.saveTo(server.getServerDirectory());
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties, distroHelper);
installOWAs(server, distroProperties);
} catch (MojoExecutionException e) {
getLog().info("Fetching openmrs war file in version " + server.getPlatformVersion());
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties, distroHelper);
installOWAs(server, distroProperties);
}
} else {
wizard.promptForRefAppVersionIfMissing(server, versionsHelper);
Expand All @@ -186,6 +189,7 @@ public String setup(Server server, boolean isCreatePlatform, boolean isCopyDepen
}
} else {
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties, distroHelper);
installOWAs(server, distroProperties);
distroProperties.saveTo(server.getServerDirectory());
}
distroHelper.savePropertiesToServer(distroProperties, server);
Expand Down Expand Up @@ -247,6 +251,7 @@ public String setup(Server server, boolean isCreatePlatform, boolean isCopyDepen
}
} else {
moduleInstaller.installModule(SDKConstants.H2_ARTIFACT, server.getServerDirectory().getPath());
installOWAs(server, distroProperties);
wizard.showMessage("The specified database "+server.getDbName()+" does not exist and it will be created for you.");
}
}
Expand Down Expand Up @@ -276,6 +281,24 @@ public String setup(Server server, boolean isCreatePlatform, boolean isCopyDepen
throw new MojoExecutionException("Failed to setup server", e);
}
}

private void installOWAs(Server server, DistroProperties distroProperties) throws MojoExecutionException {
File owasDir = new File(server.getServerDirectory(), "owa");
owasDir.mkdirs();
downloadOWAs(server.getServerDirectory(), distroProperties, owasDir);
}

private void downloadOWAs(File targetDirectory, DistroProperties distroProperties, File owasDir) throws MojoExecutionException {
List<Artifact> owas = distroProperties.getOwaArtifacts(distroHelper, targetDirectory);
OpenmrsBintray openmrsBintray = new OpenmrsBintray(getProxyFromSettings());

if (!owas.isEmpty()) {
wizard.showMessage("Downloading OWAs...\n");
for (Artifact owa: owas) {
openmrsBintray.downloadOWA(owasDir, owa.getArtifactId(), owa.getVersion());
}
}
}

private void wipeDatabase(Server server) throws MojoExecutionException {
String uri = server.getDbUri();
Expand Down Expand Up @@ -350,6 +373,7 @@ private DistroProperties extractDistroToServer(Server server, boolean isCreatePl
distroProperties = distroHelper.downloadDistroProperties(serverPath, server);
}
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties, distroHelper);
installOWAs(server, distroProperties);
return distroProperties;
}

Expand Down

0 comments on commit a7a5334

Please sign in to comment.