-
Notifications
You must be signed in to change notification settings - Fork 85
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: Add fix for content package archetype #294
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
archetype-module-content/src/main/resources/archetype-resources/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
archetype-module-content/src/test/resources/projects/basic/archetype.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
30 changes: 30 additions & 0 deletions
30
archetype-module-content/src/test/resources/projects/basic/reference/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we refactor this into a function call or using the above: packageName = groupId + "." + artifactId That said, we shouldn't need to prompt for a package for a content package since it shouldn't have code. |
||
|
||
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); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be simplified?