Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-3776: Fix Content Package Template Creation #287

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@

<properties>
<openmrsPlatformVersion>1.11.6</openmrsPlatformVersion>
<openmrsContentPackageVersion>1.0.0-SNAPSHOT</openmrsContentPackageVersion>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ public void createProject_shouldCreatePlatformModuleProject() throws Exception{
assertProjectCreated();
}

@Test
public void createProject_shouldCreateContentPackageModuleProject() throws Exception{
addTaskParam("type", "content-package");

addTaskParam("moduleId", "test");
addTaskParam("moduleName", "Test");
addTaskParam("moduleDescription", "none");
addTaskParam("groupId", "org.openmrs.content");
addTaskParam("version", "1.0.0-SNAPSHOT");

addAnswer("1.0.0");

addTaskParam(BATCH_ANSWERS, getAnswers()); //only to set interactive mode to false

executeTask("create-project");
assertSuccess();
assertContentPackageCreated();
}

@Test
public void createProject_shouldCreateContentPackageProjectUsingBatchAnswers() throws Exception{
addAnswer("Content Package");
addAnswer("test");
addAnswer("Test");
addAnswer("none");
addAnswer("org.openmrs.content");
addAnswer("1.0.0-SNAPSHOT");
addAnswer("1.0.0");

executeTask("create-project");
assertSuccess();
assertContentPackageCreated();
}

private void assertProjectCreated() {
//check only basic structure of module project and pom existence, not coupled with archetype itself
assertFilePresent("test");
Expand All @@ -82,4 +116,14 @@ private void assertProjectCreated() {
assertFilePresent("test", "omod");
assertFilePresent("test", "pom.xml");
}

private void assertContentPackageCreated() {
assertFilePresent("test");
assertFilePresent("test", ".github");
assertFilePresent("test", "configuration");
assertFilePresent("test", "README.md");
assertFilePresent("test", "assembly.xml");
assertFilePresent("test", "content.properties");
assertFilePresent("test", "pom.xml");
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package org.openmrs.maven.plugins;

import static org.openmrs.maven.plugins.utility.PropertiesUtils.loadPropertiesFromResource;
import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
import static org.twdata.maven.mojoexecutor.MojoExecutor.element;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
import static org.twdata.maven.mojoexecutor.MojoExecutor.goal;
import static org.twdata.maven.mojoexecutor.MojoExecutor.groupId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.name;
import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin;
import static org.twdata.maven.mojoexecutor.MojoExecutor.version;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -25,6 +13,18 @@
import java.util.Arrays;
import java.util.Properties;

import static org.openmrs.maven.plugins.utility.PropertiesUtils.loadPropertiesFromResource;
import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
import static org.twdata.maven.mojoexecutor.MojoExecutor.element;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
import static org.twdata.maven.mojoexecutor.MojoExecutor.goal;
import static org.twdata.maven.mojoexecutor.MojoExecutor.groupId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.name;
import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin;
import static org.twdata.maven.mojoexecutor.MojoExecutor.version;

/**
* Creates a new OpenMRS project from an archetype
*/
Expand Down Expand Up @@ -281,6 +281,7 @@ private void createModule() throws MojoExecutionException {
"2.4");
archetypeArtifactId = SDKConstants.REFAPP_ARCH_ARTIFACT_ID;
} else if (TYPE_CONTENT_PACKAGE.equals(type)) {
contentpackage = wizard.promptForValueIfMissingWithDefault("What version of the content package (-D%s) do you want to support?", contentpackage, "contentpackage", "1.0.0");
archetypeArtifactId = SDKConstants.CONTENT_PACKAGE_ARCH_ARTIFACT_ID;
} else {
throw new MojoExecutionException("Invalid project type");
Expand Down
Loading