-
Notifications
You must be signed in to change notification settings - Fork 84
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-3433: SDK Command: Add dependencies to distro.properties #283
Conversation
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.
Thanks @wikumChamith! Just a few things to adjust... Not sure how to handle the two PRs introducing similar functionality issue...
} | ||
} | ||
|
||
if(StringUtils.isBlank(type)) { |
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.
Shouldn't we also prompt for this in the case that the type
doesn't match one of the known types?
properties = distroHelper.resolveDistroPropertiesForStringSpecifier(distro, versionsHelper).getProperties(); | ||
} | ||
|
||
switch (type) { |
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.
switch (type) { | |
switch (type.toUpperCase()) { |
version = wizard.promptForMissingValueWithOptions("Enter the module version", null, null, versions, | ||
"Please specify the SPA version", null); | ||
} | ||
properties.setProperty("spa.frontendModules.@openmrs/" + moduleName, version); |
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.
The @openmrs/
part is a part of the module name (and we need to allow for implementations that can't publish to our NPM org)
properties.setProperty("spa.frontendModules.@openmrs/" + moduleName, version); | |
properties.setProperty("spa.frontendModules." + moduleName, version); |
* Type of the dependency to add | ||
*/ | ||
@Parameter(property = "type") | ||
private String type; |
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.
It would be good to document the acceptable values here so user's don't have to guess.
maven-plugin/src/main/java/org/openmrs/maven/plugins/AddDependency.java
Outdated
Show resolved
Hide resolved
sdk-commons/pom.xml
Outdated
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.10.1</version> | ||
<scope>compile</scope> | ||
</dependency> |
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 we just use Jackson (already a dependency)?
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class NPMHelper { |
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.
We've got this coming in as well. Which is, I think, a little more correct (i.e., it can support alternative registries, support for registries requiring authentication, etc.)
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.
@ibacher should I wait for it to get merged?
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.
Yes, I think so.
4cd9ace
to
2adacd5
Compare
Parallel to |
f0f827e
to
da3ef7f
Compare
@ibacher I updated the PR. |
@wikumChamith Would you be able to fix the conflict please? I've also merged the other NPM version helper, so maybe we can switch to using that? |
da3ef7f
to
ef44708
Compare
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.
Thanks @wikumChamith. Basically looks good. A couple of nits.
private final String SPA_OPTION = "SPA"; | ||
private final String OWA_OPTION = "OWA"; | ||
private final String WAR_OPTION = "WAR"; | ||
private final String CUSTOM_OPTION = "Custom"; |
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.
What's the idea here?
|
||
|
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.
Could we remove the unnecessary blank lines?
|
||
private final String DEPENDENCY_TYPE_PROMPT = "Enter the type of dependency you need to add"; | ||
|
||
private final String OMOD_OPTION = "OMOD"; |
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.
Better for these to be declared static
|
||
private static JsonNode getPackageMetadata(String versionRange, String packageName) throws IOException, InterruptedException { | ||
if (packageName == null || packageName.isEmpty()) { | ||
|
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.
Do we need this line?
ef44708
to
796980f
Compare
@ibacher I updated the PR. |
|
||
Process process = processBuilder.start(); | ||
|
||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
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.
Wrap this in a try-with-resources so the reader always gets closed.
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
try(BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { |
Also, instead of using the BufferedReader
to read by line, please use the code from getPackageMetadata()
; it's a little more efficient than a line reader for a case like this where we don't care about line-by-line format.
c6f0fca
to
aa24d7e
Compare
aa24d7e
to
afe5764
Compare
Description of what I changed
This adds a plugin that allows users to manipulate a distro.properties file by adding dependencies. This supports adding OMOD, SPA, OWA, and WAR dependencies.
Issue I worked on
see https://openmrs.atlassian.net/browse/O3-3433
Checklist: I completed these to help reviewers :)
My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
I ran
mvn clean install
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute the above command
All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master