From c2401529363cf63857cffe07108a13c4d206ff90 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Wed, 25 Sep 2024 10:51:00 +0300 Subject: [PATCH 1/3] O3-3776: Add fix for content package archetype --- .../META-INF/maven/archetype-metadata.xml | 1 - .../resources/archetype-resources/pom.xml | 3 +- .../projects/basic/archetype.properties | 3 +- .../projects/basic/reference/pom.xml | 3 +- .../openmrs/maven/plugins/CreateProject.java | 40 +++++++++++++------ 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml index 611a77ae..9933cdf3 100644 --- a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -18,7 +18,6 @@ - diff --git a/archetype-module-content/src/main/resources/archetype-resources/pom.xml b/archetype-module-content/src/main/resources/archetype-resources/pom.xml index ca113c39..cf649283 100644 --- a/archetype-module-content/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-content/src/main/resources/archetype-resources/pom.xml @@ -3,8 +3,9 @@ ${groupId} ${artifactId} ${version} - {moduleName} pom + ${moduleName} + ${moduleDescription} OpenMRS diff --git a/archetype-module-content/src/test/resources/projects/basic/archetype.properties b/archetype-module-content/src/test/resources/projects/basic/archetype.properties index 06b3357f..4dc32909 100644 --- a/archetype-module-content/src/test/resources/projects/basic/archetype.properties +++ b/archetype-module-content/src/test/resources/projects/basic/archetype.properties @@ -1,7 +1,6 @@ -moduleName=basic +moduleName=content package moduleDescription=Basic Content Package Module. Useful for creating other Content Packages i.e hiv,... groupId=org.openmrs.content artifactId=content-package -openmrsContentPackageVersion=1.0.0 package=org.openmrs.content.content-package version=1.0.0-SNAPSHOT diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml index f8e1ef12..967acd62 100644 --- a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml +++ b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml @@ -3,8 +3,9 @@ org.openmrs.content content-package 1.0.0-SNAPSHOT - {moduleName} pom + content package + Basic Content Package Module. Useful for creating other Content Packages i.e hiv,... OpenMRS 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 e776f484..e60cf636 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 @@ -68,6 +68,13 @@ public class CreateProject extends AbstractTask { "as an artifactId. The version should follow maven versioning convention, \n" + "which in short is: major.minor.maintenance(-SNAPSHOT)."; + private static final String CONTENT_MAVEN_INFO = + "GroupId, artifactId and version combined together identify your module in the maven repository. \n\n" + + "By convention the OpenMRS Content Packages modules use 'org.openmrs.content' as a groupId \n" + + "(must follow convention for naming java packages) and the module id \n" + + "as an artifactId. The version should follow maven versioning convention, \n" + + "which in short is: major.minor.maintenance(-SNAPSHOT)."; + private static final String DESCRIPTION_PROMPT_TMPL = "Describe your module in a few sentences"; private static final String GROUP_ID_PROMPT_TMPL = "Please specify %s"; @@ -255,14 +262,26 @@ private void createModule() throws MojoExecutionException { moduleDescription = wizard .promptForValueIfMissingWithDefault(DESCRIPTION_PROMPT_TMPL, moduleDescription, "", "no description"); - wizard.showMessage(MAVEN_INFO); - groupId = wizard.promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); - while (!groupId.matches("[a-z][a-z0-9.]*")) { - wizard.showError("The specified groupId " + groupId - + " is not valid. It must start from a letter and can contain only alphanumerics and dots."); - groupId = null; - groupId = wizard - .promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); + if (TYPE_CONTENT_PACKAGE.equals(type)) { + wizard.showMessage(CONTENT_MAVEN_INFO); + groupId = wizard.promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.content"); + while (!groupId.matches("[a-z][a-z0-9.]*")) { + wizard.showError("The specified groupId " + groupId + + " is not valid. It must start from a letter and can contain only alphanumerics and dots."); + groupId = null; + groupId = wizard + .promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.content"); + } + } else { + wizard.showMessage(MAVEN_INFO); + groupId = wizard.promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); + while (!groupId.matches("[a-z][a-z0-9.]*")) { + wizard.showError("The specified groupId " + groupId + + " is not valid. It must start from a letter and can contain only alphanumerics and dots."); + groupId = null; + groupId = wizard + .promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); + } } artifactId = moduleId; @@ -281,14 +300,13 @@ 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"); } archetypeVersion = getSdkVersion(); - packageName = "org.openmrs.module." + artifactId; + packageName = TYPE_CONTENT_PACKAGE.equals(type) ? "org.openmrs.content." + artifactId : "org.openmrs.module." + artifactId; Properties properties = new Properties(); properties.setProperty("artifactId", artifactId); @@ -303,8 +321,6 @@ private void createModule() throws MojoExecutionException { } else if (refapp != null) { properties.setProperty("openmrsRefappVersion", refapp); properties.setProperty("moduleClassnamePrefix", moduleClassnamePrefix); - } else if (contentpackage != null) { - properties.setProperty("openmrsContentPackageVersion", contentpackage); } properties.setProperty("package", packageName); mavenSession.getUserProperties().putAll(properties); From dfbf81bba73ef281253aee4241c79cbfd3d3545d Mon Sep 17 00:00:00 2001 From: mherman22 Date: Wed, 25 Sep 2024 12:03:51 +0300 Subject: [PATCH 2/3] Add .gitignore file as part of the setup --- archetype-module-content/pom.xml | 1 + .../META-INF/maven/archetype-metadata.xml | 1 + .../resources/archetype-resources/.gitignore | 30 +++++++++++++++++++ .../projects/basic/reference/.gitignore | 30 +++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 archetype-module-content/src/main/resources/archetype-resources/.gitignore create mode 100644 archetype-module-content/src/test/resources/projects/basic/reference/.gitignore diff --git a/archetype-module-content/pom.xml b/archetype-module-content/pom.xml index 9151b542..3779cf2d 100644 --- a/archetype-module-content/pom.xml +++ b/archetype-module-content/pom.xml @@ -30,6 +30,7 @@ true true + false diff --git a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml index 9933cdf3..5fbdefc1 100644 --- a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -31,6 +31,7 @@ assembly.xml + .gitignore content.properties pom.xml README.md diff --git a/archetype-module-content/src/main/resources/archetype-resources/.gitignore b/archetype-module-content/src/main/resources/archetype-resources/.gitignore new file mode 100644 index 00000000..5d0d02ad --- /dev/null +++ b/archetype-module-content/src/main/resources/archetype-resources/.gitignore @@ -0,0 +1,30 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +.idea/ +*.iws +*.iml +*.ipr + +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +.vscode/ + +.DS_Store diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/.gitignore b/archetype-module-content/src/test/resources/projects/basic/reference/.gitignore new file mode 100644 index 00000000..5d0d02ad --- /dev/null +++ b/archetype-module-content/src/test/resources/projects/basic/reference/.gitignore @@ -0,0 +1,30 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +.idea/ +*.iws +*.iml +*.ipr + +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +.vscode/ + +.DS_Store From 0fe80e826964914c1a4f80d9a457ecc48b6a19e7 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Wed, 25 Sep 2024 15:55:47 +0300 Subject: [PATCH 3/3] response to reviews --- .../openmrs/maven/plugins/CreateProject.java | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) 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 e60cf636..2d66ad3c 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 @@ -263,25 +263,11 @@ private void createModule() throws MojoExecutionException { .promptForValueIfMissingWithDefault(DESCRIPTION_PROMPT_TMPL, moduleDescription, "", "no description"); if (TYPE_CONTENT_PACKAGE.equals(type)) { + groupId = "org.openmrs.content"; wizard.showMessage(CONTENT_MAVEN_INFO); - groupId = wizard.promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.content"); - while (!groupId.matches("[a-z][a-z0-9.]*")) { - wizard.showError("The specified groupId " + groupId - + " is not valid. It must start from a letter and can contain only alphanumerics and dots."); - groupId = null; - groupId = wizard - .promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.content"); - } } else { - wizard.showMessage(MAVEN_INFO); - groupId = wizard.promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); - while (!groupId.matches("[a-z][a-z0-9.]*")) { - wizard.showError("The specified groupId " + groupId - + " is not valid. It must start from a letter and can contain only alphanumerics and dots."); - groupId = null; - groupId = wizard - .promptForValueIfMissingWithDefault(GROUP_ID_PROMPT_TMPL, groupId, "groupId", "org.openmrs.module"); - } + groupId = "org.openmrs.module"; + wizard.showMessage(CONTENT_MAVEN_INFO); } artifactId = moduleId; @@ -306,7 +292,7 @@ private void createModule() throws MojoExecutionException { } archetypeVersion = getSdkVersion(); - packageName = TYPE_CONTENT_PACKAGE.equals(type) ? "org.openmrs.content." + artifactId : "org.openmrs.module." + artifactId; + packageName = groupId + "." + artifactId; Properties properties = new Properties(); properties.setProperty("artifactId", artifactId);