From e7310bd0b3bde153880451b75e911737a23a38e0 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 26 Aug 2024 19:54:21 +0300 Subject: [PATCH 1/2] Fix Content Package Template Creation --- .../resources/archetype-resources/pom.xml | 1 - .../openmrs/maven/plugins/CreateProject.java | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml index 688b25061..b86e2fd28 100644 --- a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml @@ -67,6 +67,5 @@ 1.11.6 - 1.0.0-SNAPSHOT diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateProject.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateProject.java index 13d92e3bc..e776f4840 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateProject.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateProject.java @@ -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; @@ -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 */ @@ -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"); From 267b094f9fbe9e96191dd4b510d675e924fe6f5c Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 26 Aug 2024 20:35:13 +0300 Subject: [PATCH 2/2] add test cases --- .../plugins/CreateProjectIntegrationTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java index 37e315380..974ff87f5 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/CreateProjectIntegrationTest.java @@ -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"); @@ -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"); + } }