Skip to content

Commit

Permalink
Pull and extract the content package set in distro.prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravilla committed Aug 26, 2024
1 parent 58f4b90 commit 384e7b3
Show file tree
Hide file tree
Showing 8 changed files with 1,277 additions and 1,055 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openmrs.maven.plugins;

import java.util.ArrayDeque;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
Expand All @@ -12,11 +14,12 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.openmrs.maven.plugins.git.DefaultGitHelper;
import org.openmrs.maven.plugins.git.GitHelper;
import org.openmrs.maven.plugins.model.Server;
import org.openmrs.maven.plugins.utility.ContentHelper;
import org.openmrs.maven.plugins.utility.DefaultJira;
import org.openmrs.maven.plugins.utility.DistroHelper;
import org.openmrs.maven.plugins.git.DefaultGitHelper;
import org.openmrs.maven.plugins.git.GitHelper;
import org.openmrs.maven.plugins.utility.DockerHelper;
import org.openmrs.maven.plugins.utility.Jira;
import org.openmrs.maven.plugins.utility.ModuleInstaller;
Expand All @@ -27,116 +30,119 @@
import org.openmrs.maven.plugins.utility.VersionsHelper;
import org.openmrs.maven.plugins.utility.Wizard;

import java.util.ArrayDeque;

/**
* Base class for all OpenMRS SDK Maven Mojos
*/
public abstract class AbstractTask extends AbstractMojo {

/**
* The project currently being build
*/
@Parameter(defaultValue = "${project}", readonly = true)
MavenProject mavenProject;

/**
* The current Maven session.
*/
@Parameter(defaultValue = "${session}", readonly = true, required = true)
MavenSession mavenSession;

/**
* The Maven Settings
*/
@Parameter(defaultValue = "${settings}", readonly = true)
Settings settings;

/**
* test mode, if true disables interactive mode and uses batchAnswers, even if there is none
*/
@Parameter(defaultValue = "false", property = "testMode")
boolean testMode;

/**
* path to openmrs directory
*/
@Parameter(property = "openMRSPath")
String openMRSPath;

/***
* answers to use if not running in interactive mode
*/
@Parameter(property = "batchAnswers")
ArrayDeque<String> batchAnswers;

/**
* stats
*/
@Parameter(defaultValue = "false", property = "stats")
boolean stats;

/**
* The artifact metadata source to use.
*/
@Component
ArtifactMetadataSource artifactMetadataSource;

@Component
ArtifactFactory artifactFactory;

/**
* The Maven BuildPluginManager component.
*/
@Component
BuildPluginManager pluginManager;

@Component
Wizard wizard;

/**
* The artifact metadata source to use.
*/
@Component
ArtifactMetadataSource artifactMetadataSource;
@Component
ArtifactFactory artifactFactory;
/**
* The Maven BuildPluginManager component.
*/
@Component
BuildPluginManager pluginManager;
@Component
Wizard wizard;
/**
* wizard for resolving artifact available versions
*/
VersionsHelper versionsHelper;

/**
* handles installing modules on server
*/
ModuleInstaller moduleInstaller;

/**
* handles distro-properties
*/
DistroHelper distroHelper;

/**
* handles OWAs
*/
OwaHelper owaHelper;


/**
* handles Contents
*/
ContentHelper contentHelper;

/**
* installs SPAs
*/
SpaInstaller spaInstaller;

/**
* handles github and provides basic git utilities
*/
GitHelper gitHelper;

/**
* handles jira
*/
Jira jira;

/**
* handles docker
*/
DockerHelper dockerHelper;

public AbstractTask() {
}

public AbstractTask(AbstractTask other) {
this.mavenProject = other.mavenProject;
this.mavenSession = other.mavenSession;
Expand All @@ -148,6 +154,7 @@ public AbstractTask(AbstractTask other) {
this.versionsHelper = other.versionsHelper;
this.distroHelper = other.distroHelper;
this.owaHelper = other.owaHelper;
this.contentHelper = other.contentHelper;
this.spaInstaller = other.spaInstaller;
this.gitHelper = other.gitHelper;
this.dockerHelper = other.dockerHelper;
Expand All @@ -158,7 +165,7 @@ public AbstractTask(AbstractTask other) {
this.stats = other.stats;
initTask();
}

public void initTask() {
if (jira == null) {
jira = new DefaultJira();
Expand All @@ -178,6 +185,9 @@ public void initTask() {
if (owaHelper == null) {
owaHelper = new OwaHelper(mavenSession, mavenProject, pluginManager, wizard);
}
if (contentHelper == null) {
contentHelper = new ContentHelper(mavenSession, mavenProject, pluginManager);
}
if (spaInstaller == null) {
spaInstaller = new SpaInstaller(distroHelper, new NodeHelper(mavenProject, mavenSession, pluginManager));
}
Expand All @@ -187,19 +197,19 @@ public void initTask() {
if (StringUtils.isNotBlank(openMRSPath)) {
Server.setServersPath(openMRSPath);
}

if ((batchAnswers != null && !batchAnswers.isEmpty()) || testMode) {
wizard.setAnswers(batchAnswers);
wizard.setInteractiveMode(false);
}
}

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
initTask();
new StatsManager(wizard, mavenSession, stats).incrementGoalStats();
executeTask();
}

abstract public void executeTask() throws MojoExecutionException, MojoFailureException;
abstract public void executeTask() throws MojoExecutionException, MojoFailureException;
}
Loading

0 comments on commit 384e7b3

Please sign in to comment.