Skip to content

Commit

Permalink
O3-3776: Add fix for content package archetype
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 committed Sep 25, 2024
1 parent b09b2ca commit c240152
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
</requiredProperty>
<requiredProperty key="moduleName" />
<requiredProperty key="moduleDescription"/>
<requiredProperty key="openmrsContentPackageVersion"/>
</requiredProperties>

<fileSets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<name>{moduleName}</name>
<packaging>pom</packaging>
<name>${moduleName}</name>
<description>${moduleDescription}</description>
<developers>
<developer>
<name>OpenMRS</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<groupId>org.openmrs.content</groupId>
<artifactId>content-package</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>{moduleName}</name>
<packaging>pom</packaging>
<name>content package</name>
<description>Basic Content Package Module. Useful for creating other Content Packages i.e hiv,...</description>
<developers>
<developer>
<name>OpenMRS</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c240152

Please sign in to comment.