Skip to content

Commit

Permalink
Merge pull request #118 from AdamGrzybkowski/SDK-179
Browse files Browse the repository at this point in the history
SDK-179 Fetch different versions of openmrs-distro.properties for the…
  • Loading branch information
rkorytkowski authored Dec 7, 2016
2 parents 29bedfe + a0d8700 commit 736d60a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
14 changes: 11 additions & 3 deletions maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,17 @@ public String setup(Server server, boolean isCreatePlatform, boolean isCopyDepen
try {
if (distroProperties == null) {
if(isCreatePlatform){
Artifact webapp = new Artifact(SDKConstants.WEBAPP_ARTIFACT_ID, SDKConstants.SETUP_DEFAULT_PLATFORM_VERSION, Artifact.GROUP_WEB);
wizard.promptForPlatformVersionIfMissing(server, versionsHelper.getVersionAdvice(webapp, 6));
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties);
Artifact platform = new Artifact(SDKConstants.PLATFORM_ARTIFACT_ID, SDKConstants.SETUP_DEFAULT_PLATFORM_VERSION, Artifact.GROUP_DISTRO);
wizard.promptForPlatformVersionIfMissing(server, versionsHelper.getVersionAdvice(platform, 6));
platform.setVersion(server.getPlatformVersion());
try {
distroProperties = distroHelper.downloadDistroProperties(serverPath, platform);
distroProperties.saveTo(server.getServerDirectory());
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties);
} catch (MojoExecutionException e) {
getLog().info("Fetching openmrs war file in version " + server.getPlatformVersion());
moduleInstaller.installCoreModules(server, isCreatePlatform, distroProperties);
}
} else {
wizard.promptForRefAppVersionIfMissing(server, versionsHelper);
distroProperties = extractDistroToServer(server, isCreatePlatform, serverPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -239,7 +240,11 @@ public DistroProperties downloadDistroProperties(File path, Artifact artifact) t

public DistroProperties downloadDistroProperties(File serverPath, Server server) throws MojoExecutionException {
Artifact artifact = new Artifact(server.getDistroArtifactId(), server.getVersion(), server.getDistroGroupId(), "jar");
return downloadDistroProperties(serverPath, artifact);
if (StringUtils.isNotBlank(artifact.getArtifactId())) {
return downloadDistroProperties(serverPath, artifact);
} else {
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ModuleInstaller(MavenProject mavenProject,
public void installCoreModules(Server server, boolean isCreatePlatform, DistroProperties properties) throws MojoExecutionException, MojoFailureException {
List<Artifact> coreModules;
// install other modules
if (!isCreatePlatform && properties != null) {
if (properties != null) {
coreModules = properties.getWarArtifacts();
if (coreModules == null) {
throw new MojoExecutionException(String.format("Invalid version: '%s'", server.getVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class SDKConstants {
public static final String TMP = "tmp";
// non-platform web app versions
public static final String WEBAPP_ARTIFACT_ID = "openmrs-webapp";
public static final String PLATFORM_ARTIFACT_ID = "platform";
public static final Map<String,String> WEBAPP_VERSIONS = new HashMap<String, String>() {{
put("2.0", "1.9.7");
put("2.1", "1.10.0");
Expand Down

0 comments on commit 736d60a

Please sign in to comment.