1
1
package org .openmrs .maven .plugins ;
2
2
3
+ import java .util .ArrayDeque ;
4
+
3
5
import org .apache .commons .lang .StringUtils ;
4
6
import org .apache .maven .artifact .factory .ArtifactFactory ;
5
7
import org .apache .maven .artifact .metadata .ArtifactMetadataSource ;
12
14
import org .apache .maven .plugins .annotations .Parameter ;
13
15
import org .apache .maven .project .MavenProject ;
14
16
import org .apache .maven .settings .Settings ;
17
+ import org .openmrs .maven .plugins .git .DefaultGitHelper ;
18
+ import org .openmrs .maven .plugins .git .GitHelper ;
15
19
import org .openmrs .maven .plugins .model .Server ;
20
+ import org .openmrs .maven .plugins .utility .ContentHelper ;
16
21
import org .openmrs .maven .plugins .utility .DefaultJira ;
17
22
import org .openmrs .maven .plugins .utility .DistroHelper ;
18
- import org .openmrs .maven .plugins .git .DefaultGitHelper ;
19
- import org .openmrs .maven .plugins .git .GitHelper ;
20
23
import org .openmrs .maven .plugins .utility .DockerHelper ;
21
24
import org .openmrs .maven .plugins .utility .Jira ;
22
25
import org .openmrs .maven .plugins .utility .ModuleInstaller ;
27
30
import org .openmrs .maven .plugins .utility .VersionsHelper ;
28
31
import org .openmrs .maven .plugins .utility .Wizard ;
29
32
30
- import java .util .ArrayDeque ;
31
-
32
33
/**
33
34
* Base class for all OpenMRS SDK Maven Mojos
34
35
*/
35
36
public abstract class AbstractTask extends AbstractMojo {
36
-
37
+
37
38
/**
38
39
* The project currently being build
39
40
*/
40
41
@ Parameter (defaultValue = "${project}" , readonly = true )
41
42
MavenProject mavenProject ;
42
-
43
+
43
44
/**
44
45
* The current Maven session.
45
46
*/
46
47
@ Parameter (defaultValue = "${session}" , readonly = true , required = true )
47
48
MavenSession mavenSession ;
48
-
49
+
49
50
/**
50
51
* The Maven Settings
51
52
*/
52
53
@ Parameter (defaultValue = "${settings}" , readonly = true )
53
54
Settings settings ;
54
-
55
+
55
56
/**
56
57
* test mode, if true disables interactive mode and uses batchAnswers, even if there is none
57
58
*/
58
59
@ Parameter (defaultValue = "false" , property = "testMode" )
59
60
boolean testMode ;
60
-
61
+
61
62
/**
62
63
* path to openmrs directory
63
64
*/
64
65
@ Parameter (property = "openMRSPath" )
65
66
String openMRSPath ;
66
-
67
+
67
68
/***
68
69
* answers to use if not running in interactive mode
69
70
*/
70
71
@ Parameter (property = "batchAnswers" )
71
72
ArrayDeque <String > batchAnswers ;
72
-
73
+
73
74
/**
74
75
* stats
75
76
*/
76
77
@ Parameter (defaultValue = "false" , property = "stats" )
77
78
boolean stats ;
78
-
79
- /**
80
- * The artifact metadata source to use.
81
- */
82
- @ Component
83
- ArtifactMetadataSource artifactMetadataSource ;
84
-
85
- @ Component
86
- ArtifactFactory artifactFactory ;
87
-
88
- /**
89
- * The Maven BuildPluginManager component.
90
- */
91
- @ Component
92
- BuildPluginManager pluginManager ;
93
-
94
- @ Component
95
- Wizard wizard ;
96
-
79
+
80
+ /**
81
+ * The artifact metadata source to use.
82
+ */
83
+ @ Component
84
+ ArtifactMetadataSource artifactMetadataSource ;
85
+
86
+ @ Component
87
+ ArtifactFactory artifactFactory ;
88
+
89
+ /**
90
+ * The Maven BuildPluginManager component.
91
+ */
92
+ @ Component
93
+ BuildPluginManager pluginManager ;
94
+
95
+ @ Component
96
+ Wizard wizard ;
97
+
97
98
/**
98
99
* wizard for resolving artifact available versions
99
100
*/
100
101
VersionsHelper versionsHelper ;
101
-
102
+
102
103
/**
103
104
* handles installing modules on server
104
105
*/
105
106
ModuleInstaller moduleInstaller ;
106
-
107
+
107
108
/**
108
109
* handles distro-properties
109
110
*/
110
111
DistroHelper distroHelper ;
111
-
112
+
112
113
/**
113
114
* handles OWAs
114
115
*/
115
116
OwaHelper owaHelper ;
116
-
117
+
118
+ /**
119
+ * handles Contents
120
+ */
121
+ ContentHelper contentHelper ;
122
+
117
123
/**
118
124
* installs SPAs
119
125
*/
120
126
SpaInstaller spaInstaller ;
121
-
127
+
122
128
/**
123
129
* handles github and provides basic git utilities
124
130
*/
125
131
GitHelper gitHelper ;
126
-
132
+
127
133
/**
128
134
* handles jira
129
135
*/
130
136
Jira jira ;
131
-
137
+
132
138
/**
133
139
* handles docker
134
140
*/
135
141
DockerHelper dockerHelper ;
136
-
142
+
137
143
public AbstractTask () {
138
144
}
139
-
145
+
140
146
public AbstractTask (AbstractTask other ) {
141
147
this .mavenProject = other .mavenProject ;
142
148
this .mavenSession = other .mavenSession ;
@@ -148,6 +154,7 @@ public AbstractTask(AbstractTask other) {
148
154
this .versionsHelper = other .versionsHelper ;
149
155
this .distroHelper = other .distroHelper ;
150
156
this .owaHelper = other .owaHelper ;
157
+ this .contentHelper = other .contentHelper ;
151
158
this .spaInstaller = other .spaInstaller ;
152
159
this .gitHelper = other .gitHelper ;
153
160
this .dockerHelper = other .dockerHelper ;
@@ -158,7 +165,7 @@ public AbstractTask(AbstractTask other) {
158
165
this .stats = other .stats ;
159
166
initTask ();
160
167
}
161
-
168
+
162
169
public void initTask () {
163
170
if (jira == null ) {
164
171
jira = new DefaultJira ();
@@ -178,6 +185,9 @@ public void initTask() {
178
185
if (owaHelper == null ) {
179
186
owaHelper = new OwaHelper (mavenSession , mavenProject , pluginManager , wizard );
180
187
}
188
+ if (contentHelper == null ) {
189
+ contentHelper = new ContentHelper (mavenSession , mavenProject , pluginManager );
190
+ }
181
191
if (spaInstaller == null ) {
182
192
spaInstaller = new SpaInstaller (distroHelper , new NodeHelper (mavenProject , mavenSession , pluginManager ));
183
193
}
@@ -187,19 +197,19 @@ public void initTask() {
187
197
if (StringUtils .isNotBlank (openMRSPath )) {
188
198
Server .setServersPath (openMRSPath );
189
199
}
190
-
200
+
191
201
if ((batchAnswers != null && !batchAnswers .isEmpty ()) || testMode ) {
192
202
wizard .setAnswers (batchAnswers );
193
203
wizard .setInteractiveMode (false );
194
204
}
195
205
}
196
-
206
+
197
207
@ Override
198
208
public void execute () throws MojoExecutionException , MojoFailureException {
199
209
initTask ();
200
210
new StatsManager (wizard , mavenSession , stats ).incrementGoalStats ();
201
211
executeTask ();
202
212
}
203
-
204
- abstract public void executeTask () throws MojoExecutionException , MojoFailureException ;
213
+
214
+ abstract public void executeTask () throws MojoExecutionException , MojoFailureException ;
205
215
}
0 commit comments