1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.t7mp;
17
18 import java.io.File;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.maven.artifact.factory.ArtifactFactory;
26 import org.apache.maven.artifact.repository.ArtifactRepository;
27 import org.apache.maven.artifact.resolver.ArtifactCollector;
28 import org.apache.maven.artifact.resolver.ArtifactResolver;
29 import org.apache.maven.plugin.AbstractMojo;
30 import org.apache.maven.project.MavenProject;
31 import org.codehaus.plexus.archiver.manager.ArchiverManager;
32
33 import com.googlecode.t7mp.scanner.ScannerConfiguration;
34
35
36
37
38
39
40 public abstract class AbstractT7BaseMojo extends AbstractMojo {
41
42 public static final String T7_BOOTSTRAP_CONTEXT_ID = "com.googlecode.t7mp.Bootstrap";
43
44 public static final int DEFAULT_TOMCAT_HTTP_PORT = 8080;
45
46 public static final int DEFAULT_TOMCAT_SHUTDOWN_PORT = 8005;
47
48 public static final String DEFAULT_TOMCAT_VERSION = "7.0.29";
49
50 public static final String CONTEXT_PATH_ROOT = "ROOT";
51
52
53
54
55
56
57
58 protected MavenProject mavenProject;
59
60
61
62
63
64
65 protected ArtifactFactory factory;
66
67
68
69
70
71
72 protected ArtifactResolver resolver;
73
74
75
76
77
78
79
80
81 protected ArtifactCollector artifactCollector;
82
83
84
85
86
87
88
89
90 protected ArtifactRepository local;
91
92
93
94
95
96
97
98
99 protected java.util.List<ArtifactRepository> remoteRepos;
100
101
102
103
104
105
106 protected ArchiverManager archiverManager;
107
108
109
110
111
112
113
114 protected boolean tomcatSetAwait = true;
115
116
117
118
119
120
121
122 protected boolean lookInside = false;
123
124
125
126
127
128
129 protected boolean resolverUpdateSnapshotsAllways = false;
130
131
132
133
134
135 protected String tomcatVersion = DEFAULT_TOMCAT_VERSION;
136
137
138
139
140
141 protected int tomcatHttpPort = DEFAULT_TOMCAT_HTTP_PORT;
142
143
144
145
146
147 protected int tomcatShutdownPort = DEFAULT_TOMCAT_SHUTDOWN_PORT;
148
149
150
151
152
153 protected String tomcatShutdownCommand = "SHUTDOWN";
154
155
156
157
158
159
160 protected String tomcatShutdownHost = "localhost";
161
162
163
164
165
166
167 protected String tomcatHostName = "localhost";
168
169
170
171
172
173
174
175 protected File catalinaBase;
176
177
178
179
180
181
182
183 protected File tomcatConfigDirectory;
184
185
186
187
188
189 protected File overwriteWebXML;
190
191
192
193
194
195
196
197 protected File webappOutputDirectory;
198
199
200
201
202
203
204
205 protected String contextPath;
206
207
208
209
210
211 protected String buildFinalName;
212
213
214
215
216
217 protected File webappSourceDirectory;
218
219
220
221
222
223
224 protected String packaging = "war";
225
226
227
228
229
230 protected boolean scanClasses = false;
231
232
233
234
235
236 protected boolean addGithubRepository = false;
237
238
239
240
241
242 protected File webappClassDirectory;
243
244
245
246
247
248 protected File contextFile = null;
249
250
251
252
253
254 protected ArrayList<WebappArtifact> webapps = new ArrayList<WebappArtifact>();
255
256
257
258
259
260 protected Map<String, String> systemProperties = new HashMap<String, String>();
261
262
263
264
265
266 protected ArrayList<JarArtifact> libs = new ArrayList<JarArtifact>();
267
268
269
270
271
272 protected ArrayList<ScannerConfiguration> scanners = new ArrayList<ScannerConfiguration>();
273
274
275
276
277
278 protected boolean suspendConsoleOutput = false;
279
280
281
282
283 protected ConfigurationArtifact configArtifact = null;
284
285
286
287
288
289
290 protected int instanceCount = 1;
291
292 public boolean isWebProject() {
293 return this.packaging.equals("war");
294 }
295
296 public boolean isTomcatSetAwait() {
297 return tomcatSetAwait;
298 }
299
300 public void setTomcatSetAwait(boolean setAwait) {
301 this.tomcatSetAwait = setAwait;
302 }
303
304 public boolean isLookInside() {
305 return lookInside;
306 }
307
308 public void setLookInside(boolean lookInside) {
309 this.lookInside = lookInside;
310 }
311
312 public boolean isScanClasses() {
313 return scanClasses;
314 }
315
316 public void setScanClasses(boolean scanClasses) {
317 this.scanClasses = scanClasses;
318 }
319
320 public boolean isAddGithubRepository() {
321 return addGithubRepository;
322 }
323
324 public void setAddGithubRepository(boolean addGithubRepository) {
325 this.addGithubRepository = addGithubRepository;
326 }
327
328 public String getTomcatVersion() {
329 return tomcatVersion;
330 }
331
332 public void setTomcatVersion(String tomcatVersion) {
333 this.tomcatVersion = tomcatVersion;
334 }
335
336 public int getTomcatHttpPort() {
337 return tomcatHttpPort;
338 }
339
340 public void setTomcatHttpPort(int tomcatHttpPort) {
341 this.tomcatHttpPort = tomcatHttpPort;
342 }
343
344 public int getTomcatShutdownPort() {
345 return tomcatShutdownPort;
346 }
347
348 public void setTomcatShutdownPort(int tomcatShutdownPort) {
349 this.tomcatShutdownPort = tomcatShutdownPort;
350 }
351
352 public String getTomcatShutdownCommand() {
353 return tomcatShutdownCommand;
354 }
355
356 public void setTomcatShutdownCommand(String tomcatShutdownCommand) {
357 this.tomcatShutdownCommand = tomcatShutdownCommand;
358 }
359
360 public String getTomcatShutdownHost() {
361 return tomcatShutdownHost;
362 }
363
364 public void setTomcatShutdownHost(String tomcatShutdownHost) {
365 this.tomcatShutdownHost = tomcatShutdownHost;
366 }
367
368 public String getTomcatHostName() {
369 return tomcatHostName;
370 }
371
372 public void setTomcatHostName(String tomcatHostName) {
373 this.tomcatHostName = tomcatHostName;
374 }
375
376 public File getUserConfigDir() {
377 return tomcatConfigDirectory;
378 }
379
380 public void setUserConfigDir(File userConfigDir) {
381 this.tomcatConfigDirectory = userConfigDir;
382 }
383
384 public File getWebappOutputDirectory() {
385 return webappOutputDirectory;
386 }
387
388 public void setWebappOutputDirectory(File webappOutputDirectory) {
389 this.webappOutputDirectory = webappOutputDirectory;
390 }
391
392 public String getContextPath() {
393 if (StringUtils.isEmpty(contextPath) || "/".equals(contextPath)) {
394 return CONTEXT_PATH_ROOT;
395 }
396 if (contextPath.startsWith("/")) {
397 return contextPath.substring(1);
398 }
399 return contextPath;
400 }
401
402 public void setContextPath(String contextPath) {
403 this.contextPath = contextPath;
404 }
405
406 public File getOverwriteWebXML() {
407 return overwriteWebXML;
408 }
409
410 public void setOverwriteWebXML(File overwriteWebXML) {
411 this.overwriteWebXML = overwriteWebXML;
412 }
413
414 public File getContextFile() {
415 return contextFile;
416 }
417
418 public void setContextFile(File contextFile) {
419 this.contextFile = contextFile;
420 }
421
422 public File getCatalinaBase() {
423 return catalinaBase;
424 }
425
426 public void setCatalinaBase(File catalinaBase) {
427 this.catalinaBase = catalinaBase;
428 }
429
430 public ArrayList<ScannerConfiguration> getScanners() {
431 return scanners;
432 }
433
434 public String getBuildFinalName() {
435 return buildFinalName;
436 }
437
438 public void setBuildFinalName(String buildFinalName) {
439 this.buildFinalName = buildFinalName;
440 }
441
442 public String getPackaging() {
443 return packaging;
444 }
445
446 public void setPackaging(String packaging) {
447 this.packaging = packaging;
448 }
449
450 public List<JarArtifact> getLibs() {
451 return libs;
452 }
453
454 public void setLibs(ArrayList<JarArtifact> libs) {
455 this.libs = libs;
456 }
457
458 public File getTomcatConfigDirectory() {
459 return tomcatConfigDirectory;
460 }
461
462 public void setTomcatConfigDirectory(File tomcatConfigDirectory) {
463 this.tomcatConfigDirectory = tomcatConfigDirectory;
464 }
465
466 public File getWebappSourceDirectory() {
467 return webappSourceDirectory;
468 }
469
470 public void setWebappSourceDirectory(File webappSourceDirectory) {
471 this.webappSourceDirectory = webappSourceDirectory;
472 }
473
474 public File getWebappClassDirectory() {
475 return webappClassDirectory;
476 }
477
478 public void setWebappClassDirectory(File webappClassDirectory) {
479 this.webappClassDirectory = webappClassDirectory;
480 }
481
482 public List<WebappArtifact> getWebapps() {
483 return webapps;
484 }
485
486 public void setWebapps(ArrayList<WebappArtifact> webapps) {
487 this.webapps = webapps;
488 }
489
490 public Map<String, String> getSystemProperties() {
491 return systemProperties;
492 }
493
494 public void setSystemProperties(Map<String, String> systemProperties) {
495 this.systemProperties = systemProperties;
496 }
497
498 public ArtifactFactory getFactory() {
499 return factory;
500 }
501
502 public void setFactory(ArtifactFactory factory) {
503 this.factory = factory;
504 }
505
506 public ArtifactResolver getResolver() {
507 return resolver;
508 }
509
510 public void setResolver(ArtifactResolver resolver) {
511 this.resolver = resolver;
512 }
513
514 public ArtifactCollector getArtifactCollector() {
515 return artifactCollector;
516 }
517
518 public void setArtifactCollector(ArtifactCollector artifactCollector) {
519 this.artifactCollector = artifactCollector;
520 }
521
522 public ArtifactRepository getLocal() {
523 return local;
524 }
525
526 public void setLocal(ArtifactRepository local) {
527 this.local = local;
528 }
529
530 public java.util.List<ArtifactRepository> getRemoteRepos() {
531 return remoteRepos;
532 }
533
534 public void setRemoteRepos(java.util.List<ArtifactRepository> remoteRepos) {
535 this.remoteRepos = remoteRepos;
536 }
537
538 public ArchiverManager getArchiverManager() {
539 return archiverManager;
540 }
541
542 public void setArchiverManager(ArchiverManager archiverManager) {
543 this.archiverManager = archiverManager;
544 }
545
546 public boolean isResolverUpdateSnapshotsAllways() {
547 return resolverUpdateSnapshotsAllways;
548 }
549
550 public void setResolverUpdateSnapshotsAllways(boolean resolverUpdateSnapshotsAllways) {
551 this.resolverUpdateSnapshotsAllways = resolverUpdateSnapshotsAllways;
552 }
553
554 public void setScanners(ArrayList<ScannerConfiguration> scanners) {
555 this.scanners = scanners;
556 }
557
558 public MavenProject getMavenProject() {
559 return mavenProject;
560 }
561
562 public void setMavenProject(MavenProject mavenProject) {
563 this.mavenProject = mavenProject;
564 }
565
566 public boolean isSuspendConsoleOutput() {
567 return suspendConsoleOutput;
568 }
569
570 public void setSuspendConsoleOutput(boolean suspendConsoleOutput) {
571 this.suspendConsoleOutput = suspendConsoleOutput;
572 }
573
574 public ConfigurationArtifact getConfigArtifact() {
575 return configArtifact;
576 }
577
578 public void setConfigArtifact(ConfigurationArtifact configurationArtifact) {
579 this.configArtifact = configurationArtifact;
580 }
581
582 public int getInstanceCount() {
583 return instanceCount;
584 }
585
586 public void setInstanceCount(int instanceCount) {
587 this.instanceCount = instanceCount;
588 }
589
590 }