diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/AddFeature.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/AddFeature.java index c3a22c49..f352ea13 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/AddFeature.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/AddFeature.java @@ -23,6 +23,9 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin; import static org.twdata.maven.mojoexecutor.MojoExecutor.version; +/** + * Enhance an existing module by adding a feature + */ @Mojo(name = "add-feature", requiresProject = false) public class AddFeature extends AbstractTask { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Build.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Build.java index b7e24875..050e7716 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Build.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Build.java @@ -21,15 +21,27 @@ import java.util.Properties; import java.util.Set; +/** + * Build server's watched projects, OWA projects or node projects. + */ @Mojo(name = "build", requiresProject = false) public class Build extends AbstractServerTask { + /** + * Flag to indicate whether to build OWA projects. + */ @Parameter(property = "buildOwa", defaultValue = "true") private boolean buildOwa; + /** + * Version of npm to use for building node projects. + */ @Parameter(property = "npmVersion") protected String npmVersion; + /** + * Version of Node.js to use for building node projects. + */ @Parameter(property = "nodeVersion") protected String nodeVersion; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java index e84f6924..9f88e790 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java @@ -35,6 +35,9 @@ import java.util.ArrayList; import java.util.List; +/** + * Create docker configuration for distributions. + */ @Mojo(name = "build-distro", requiresProject = false) public class BuildDistro extends AbstractTask { @@ -74,18 +77,33 @@ public class BuildDistro extends AbstractTask { private static final Logger log = LoggerFactory.getLogger(BuildDistro.class); + /** + * Path to the openmrs-distro.properties file. + */ @Parameter(property = "distro") private String distro; + /** + * Directory for generated files. (default to 'docker') + */ @Parameter(property = "dir") private String dir; + /** + * SQL script for database configuration. + */ @Parameter(property = "dbSql") private String dbSql; + /** + * Causes npm to completely ignore peerDependencies + */ @Parameter(property = "ignorePeerDependencies", defaultValue = "true") private boolean ignorePeerDependencies; + /** + * Override the reuseNodeCache property that controls whether the SDK reuse the NPM cache after the setup + */ @Parameter(property = "reuseNodeCache") public Boolean overrideReuseNodeCache; @@ -96,6 +114,9 @@ public class BuildDistro extends AbstractTask { @Parameter(defaultValue = "false", property = "bundled") private boolean bundled; + /** + * Flag to indicate whether to delete the target directory or not. + */ @Parameter(defaultValue = "false", property = "reset") private boolean reset; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Clone.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Clone.java index 21d118f9..6f504d8d 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Clone.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Clone.java @@ -21,6 +21,9 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.*; +/** + * Clone any OpenMRS module repository + */ @Mojo(name = "clone", requiresProject = false) public class Clone extends AbstractTask { @@ -28,15 +31,27 @@ public class Clone extends AbstractTask { public static final String GITHUB_BASE_URL = "https://github.com/"; + /** + * groupId of the module you want to clone. + */ @Parameter(property = "groupId") private String groupId; + /** + * artifactId of module You want to clone. + */ @Parameter(property = "artifactId") private String artifactId; + /** + * Github username + */ @Parameter(property = "githubUsername") private String username; + /** + * GitHub password or personal access token. + */ @Parameter(property = "githubPassword", alias = "personalAccessToken") private String personalAccessToken; 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 3913e061..25f3f10a 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 @@ -101,6 +101,9 @@ public class CreateProject extends AbstractTask { @Parameter(defaultValue = "org.openmrs.maven.archetypes:", property = "filter") private String filter; + /** + * The output directory. + */ @Parameter(defaultValue = "${project.basedir}", property = "outputDirectory") private File outputDirectory; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Deploy.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Deploy.java index f9544f8f..5d7b0a26 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Deploy.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Deploy.java @@ -48,21 +48,40 @@ public class Deploy extends AbstractServerTask { private static final String DEPLOY_PLATFORM_OPTION = "Platform"; + /** + * Artifact id of an artifact, which you want to deploy. + */ @Parameter(property = "artifactId") private String artifactId; + /** + * Group id of an artifact, which you want to deploy + */ @Parameter(property = "groupId") private String groupId; + /** + * Version of an artifact, which you want to deploy. + */ @Parameter(property = "version") private String version; + /** + * OpenMRS Distribution to set up in the format 'groupId:artifactId:version'. + * You can skip groupId, if it is 'org.openmrs.distro'. You can also give Path to distro.properties file + */ @Parameter(property = "distro") private String distro; + /** + * OpenMRS platform version. + */ @Parameter(property = "platform") private String platform; + /** + * Owa property in the format 'owa-name:version' + */ @Parameter(property = "owa") private String owa; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Fetch.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Fetch.java index 54b8ff8b..1a7e53f9 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Fetch.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Fetch.java @@ -24,6 +24,9 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin; import static org.twdata.maven.mojoexecutor.MojoExecutor.version; +/** + * Fetch any OpenMRS module or OWA. + */ @Mojo(name = "fetch", requiresProject = false) public class Fetch extends AbstractTask { @@ -35,18 +38,33 @@ public class Fetch extends AbstractTask { private static final String DEFAULT_GROUP_ID = "org.openmrs.module"; + /** + * artifactId of the module you want to fetch. + */ @Parameter(property = "artifactId") private String artifactId; + /** + * groupId of the module you want to fetch. + */ @Parameter(property = "groupId") private String groupId; + /** + * version of the module you want to fetch. + */ @Parameter(property = "version") private String version; + /** + * OWA you want to fetch. + */ @Parameter(property = "owa") private String owa; + /** + * The Directory the file should be fetched into. (Default to the current directory)" + */ @Parameter(property = "dir") private String dir; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/GenerateDistro.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/GenerateDistro.java index e9aab78c..61703889 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/GenerateDistro.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/GenerateDistro.java @@ -20,6 +20,9 @@ import java.util.List; import java.util.Properties; +/** + * Generates an openmrs-distro.properties file for a specific version of OpenMRS Distro + */ @Mojo(name = "generate-distro", requiresProject = false) public class GenerateDistro extends AbstractTask { @@ -33,6 +36,9 @@ public class GenerateDistro extends AbstractTask { private static final Logger logger = LoggerFactory.getLogger(GenerateDistro.class); + /** + * Specify the location where the file should be saved. (Default to current location) + */ @Parameter(property = "output") private String outputLocation; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Help.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Help.java index d16123af..81447480 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Help.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Help.java @@ -1,74 +1,32 @@ package org.openmrs.maven.plugins; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; -import org.ho.yaml.YamlDecoder; +import org.openmrs.maven.plugins.utility.SDKConstants; +import org.twdata.maven.mojoexecutor.MojoExecutor; -import java.io.EOFException; -import java.io.InputStream; -import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; -import java.util.Map; + +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.plugin; +import static org.twdata.maven.mojoexecutor.MojoExecutor.version; @Mojo(name = "help", requiresProject = false) public class Help extends AbstractTask { - private static final String HELP_FILE = "help.yaml"; - private static final String DESC_MESSAGE = "Description: "; - private static final String INFO = "OpenMRS SDK %s"; - private static final String WIKI = "https://wiki.openmrs.org/display/docs/OpenMRS+SDK"; - public void executeTask() throws MojoExecutionException { - InputStream stream = getClass().getClassLoader().getResourceAsStream(HELP_FILE); - YamlDecoder dec = new YamlDecoder(stream); - HelpFormatter formatter = new HelpFormatter(); - formatter.setLeftPadding(4); - formatter.setDescPadding(8); - try { - @SuppressWarnings("unchecked") - Map keys = (Map) dec.readObject(); - @SuppressWarnings("unchecked") - List> l = (List>) keys.get("help"); - String printVersion = String.format(INFO, keys.get("version")); - String printWikiLink = "For more info, see SDK documentation: " + WIKI; - PrintWriter writer = new PrintWriter(System.out); - writer.println(); - writer.println(); - writer.println(printVersion); - writer.println(); - writer.println(printWikiLink); - writer.println(); - writer.println(); - writer.flush(); - if (l == null) { - throw new MojoExecutionException("Error during reading help data"); - } - for (Map o: l) { - Options options = new Options(); - @SuppressWarnings("unchecked") - List> params = (List>) o.get("options"); - String header = (o.get("desc") != null) ? o.get("desc").toString() : "None"; - header = DESC_MESSAGE.concat(header); - if (params != null) { - for (Map x: params) { - String name = x.get("name").toString(); - String desc = x.get("desc").toString(); - if ((name == null) || (desc == null)) throw new MojoExecutionException("Error in help file structure"); - options.addOption(new Option(name, desc)); - } - } - formatter.printHelp(o.get("name").toString(), header, options, ""); - writer.println(); - writer.flush(); - } - writer.flush(); - } catch (EOFException e) { - throw new MojoExecutionException(e.getMessage()); - } finally { - dec.close(); - } + List configuration = new ArrayList<>(3); + configuration.add(element("groupId", "org.openmrs.maven.plugins")); + configuration.add(element("artifactId", "openmrs-sdk-maven-plugin")); + configuration.add(element("version", mavenProject.getVersion())); + configuration.add(element("detail", "true")); + executeMojo(plugin(groupId(SDKConstants.HELP_PLUGIN_GROUP_ID), artifactId(SDKConstants.HELP_PLUGIN_ARTIFACT_ID), version(SDKConstants.HELP_PLUGIN_VERSION)), goal("describe"), configuration(configuration.toArray(new MojoExecutor.Element[0])), executionEnvironment(mavenProject, mavenSession, pluginManager)); } } diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Info.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Info.java index 435e39fe..a830f247 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Info.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Info.java @@ -7,6 +7,9 @@ import java.util.Set; +/** + * Display server details including the list of watched modules. + */ @Mojo(name = "info", requiresProject = false) public class Info extends AbstractServerTask { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Pull.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Pull.java index 476a9d3e..046fc0f0 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Pull.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Pull.java @@ -26,6 +26,9 @@ import java.util.List; import java.util.Set; +/** + * Pull changes from upstream for all watched projects or for any project if executed in its directory. + */ @Mojo(name = "pull", requiresProject = false) public class Pull extends AbstractServerTask { @@ -64,6 +67,9 @@ public class Pull extends AbstractServerTask { private static final String TEMP_BRANCH = "tempBranch"; + /** + * Branch that is needed be pulled. (Default to 'master') + */ @Parameter(property = "branch") private String branch; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/PullRequest.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/PullRequest.java index 45f902dd..eb292bcd 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/PullRequest.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/PullRequest.java @@ -16,12 +16,14 @@ import java.util.ArrayList; import java.util.List; +/** + * Create or update pull request to any OpenMRS repository. + */ @Mojo(name = "pr", requiresProject = false) public class PullRequest extends AbstractTask { - /** - * Interactive mode flag, set for 'false' allows automatic testing in batch mode, - * as it makes all 'yes/no' prompts return 'yes' + /** + * The branch to create the pull request. */ @Parameter(defaultValue = "master", property = "branch") String branch; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Reset.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Reset.java index 5753f487..afe761f1 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Reset.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Reset.java @@ -15,6 +15,9 @@ import java.io.IOException; import java.sql.SQLException; +/** + * Reset the server and its database to the initial state. + */ @Mojo(name = "reset", requiresProject = false) public class Reset extends AbstractServerTask { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Run.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Run.java index 712ddc68..41f88493 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Run.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Run.java @@ -36,6 +36,9 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin; import static org.twdata.maven.mojoexecutor.MojoExecutor.version; +/** + * Start a server. If it is run from a module/distro/platform project, the project will be redeployed before launching. + */ @Mojo(name = "run", requiresProject = false) public class Run extends AbstractServerTask { @@ -53,18 +56,34 @@ public Run(AbstractTask other, String serverId) { this.serverId = serverId; } + /** + * Port to use for running the server (defaults to '8080') + */ @Parameter(property = "port") private Integer port; + /** + * Enable remote debugging on the given port (defaults to '1044' if empty) + */ @Parameter(property = "debug") private String debug; + /** + * Flag to indicate whether to redeploy API classes + */ @Parameter(property = "watchApi") private Boolean watchApi; + /** + * Flag to indicate whether to build server's watched projects, OWA projects, or node projects. + */ @Parameter(defaultValue = "false", property = "skipBuild") private boolean skipBuild; - + + /** + * Goal to execute when running the server."Goal to execute when running the server + * (Defaults to 'org.openmrs.maven.plugins:openmrs-sdk-tomcat9-maven-plugin:{$version}') + */ @Parameter(property = "runGoal") private String runGoal; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java index 2ef204fd..95dda3e6 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java @@ -41,6 +41,9 @@ import org.openmrs.maven.plugins.utility.SDKConstants; import org.openmrs.maven.plugins.utility.ServerHelper; +/** + * Set up a new instance of OpenMRS server. It can be used for setting up a platform or a distribution. It prompts for any missing, but required parameters. + */ @Mojo(name = "setup", requiresProject = false) public class Setup extends AbstractServerTask { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/SetupSDK.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/SetupSDK.java index 77f9d1ea..c2ad17eb 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/SetupSDK.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/SetupSDK.java @@ -19,6 +19,9 @@ import static org.openmrs.maven.plugins.utility.PropertiesUtils.getSdkProperties; import static org.openmrs.maven.plugins.utility.PropertiesUtils.savePropertiesChangesToFile; +/** + * Setup the OpenMRS SDK + */ @Mojo(name = "setup-sdk", requiresProject = false) public class SetupSDK extends AbstractTask { diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Undeploy.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Undeploy.java index 2aaab22b..15a43d43 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Undeploy.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Undeploy.java @@ -10,12 +10,21 @@ import java.io.File; +/** + * Undeploy a module from a server. + */ @Mojo(name = "undeploy", requiresProject = false) public class Undeploy extends AbstractServerTask { + /** + * Artifact id of a module, which you want to undeploy. + */ @Parameter(property = "artifactId") private String artifactId; + /** + * Group id of a module, which you want to undeploy + */ @Parameter(defaultValue = "org.openmrs.module", property = "groupId") private String groupId; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Unwatch.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Unwatch.java index f84d7bf8..af6e096e 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Unwatch.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Unwatch.java @@ -9,12 +9,21 @@ import java.io.File; +/** + * Remove a module from the list of watched projects. It disabled the live-reloading feature for a module. + */ @Mojo(name = "unwatch", requiresProject = false) public class Unwatch extends AbstractServerTask { - @Parameter(property = "artifactId") + /** + * Artifact id of a module to unwatch. + */ + @Parameter(property = "artifactId") private String artifactId; + /** + * Group id of a module to unwatch. It is optional if artifact id is unambiguous. + */ @Parameter(property = "groupId") private String groupId; diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Watch.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Watch.java index f5888967..1ffde72a 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Watch.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Watch.java @@ -9,10 +9,17 @@ import java.io.File; +/** + * Add a module from the current directory to the list of watched projects. + * It enables the live-reloading feature for a module. + */ @Mojo(name = "watch", requiresProject = false) public class Watch extends AbstractServerTask { - @Parameter(property = "serverId") + /** + * Unique id of a server. + */ + @Parameter(property = "serverId") private String serverId; @Override diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/WatchOwa.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/WatchOwa.java index 5caaa90c..90905ffa 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/WatchOwa.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/WatchOwa.java @@ -9,6 +9,9 @@ import java.util.List; import java.util.Map; +/** + * Watch OWA + */ @Mojo(name = "watch-owa", requiresProject = false) public class WatchOwa extends AbstractServerTask { diff --git a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java index c5cfedf6..f7d7cbdb 100644 --- a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java +++ b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/SDKConstants.java @@ -23,6 +23,10 @@ public class SDKConstants { public static final String ARCHETYPE_PLUGIN_GROUP_ID = "org.apache.maven.plugins"; public static final String ARCHETYPE_PLUGIN_ARTIFACT_ID = "maven-archetype-plugin"; public static final String ARCHETYPE_PLUGIN_VERSION = "3.2.0"; + //help plugin + public static final String HELP_PLUGIN_GROUP_ID = "org.apache.maven.plugins"; + public static final String HELP_PLUGIN_ARTIFACT_ID = "maven-help-plugin"; + public static final String HELP_PLUGIN_VERSION = "3.2.0"; //docker plugin public static final String PLUGIN_DOCKER_ARTIFACT_ID = "openmrs-sdk-docker-maven-plugin"; // frontend plugin