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 0bbc8a27..fb2a91e4 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 @@ -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); diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java index a7fcc4c4..65e0e605 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/DistroHelper.java @@ -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; @@ -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; + } } /** diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/ModuleInstaller.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/ModuleInstaller.java index 76750b95..329f3102 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/ModuleInstaller.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/ModuleInstaller.java @@ -44,7 +44,7 @@ public ModuleInstaller(MavenProject mavenProject, public void installCoreModules(Server server, boolean isCreatePlatform, DistroProperties properties) throws MojoExecutionException, MojoFailureException { List 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())); diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java index 44199c93..e39a1c4b 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java @@ -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 WEBAPP_VERSIONS = new HashMap() {{ put("2.0", "1.9.7"); put("2.1", "1.10.0");