1 | |
package org.apache.maven.plugin.surefire; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.File; |
23 | |
import java.io.IOException; |
24 | |
import java.lang.reflect.Method; |
25 | |
import java.util.ArrayList; |
26 | |
import java.util.Arrays; |
27 | |
import java.util.Collections; |
28 | |
import java.util.HashMap; |
29 | |
import java.util.LinkedHashSet; |
30 | |
import java.util.List; |
31 | |
import java.util.Map; |
32 | |
import java.util.Map.Entry; |
33 | |
import java.util.Properties; |
34 | |
import java.util.Set; |
35 | |
|
36 | |
import org.apache.maven.artifact.Artifact; |
37 | |
import org.apache.maven.artifact.factory.ArtifactFactory; |
38 | |
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; |
39 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
40 | |
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; |
41 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionException; |
42 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; |
43 | |
import org.apache.maven.artifact.resolver.ArtifactResolver; |
44 | |
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; |
45 | |
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; |
46 | |
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; |
47 | |
import org.apache.maven.artifact.versioning.ArtifactVersion; |
48 | |
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; |
49 | |
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; |
50 | |
import org.apache.maven.artifact.versioning.VersionRange; |
51 | |
import org.apache.maven.execution.MavenSession; |
52 | |
import org.apache.maven.model.Plugin; |
53 | |
import org.apache.maven.plugin.AbstractMojo; |
54 | |
import org.apache.maven.plugin.MojoExecutionException; |
55 | |
import org.apache.maven.plugin.MojoFailureException; |
56 | |
import org.apache.maven.plugin.descriptor.PluginDescriptor; |
57 | |
import org.apache.maven.plugin.logging.Log; |
58 | |
import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator; |
59 | |
import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration; |
60 | |
import org.apache.maven.plugin.surefire.booterclient.ForkStarter; |
61 | |
import org.apache.maven.plugin.surefire.util.DependencyScanner; |
62 | |
import org.apache.maven.plugin.surefire.util.DirectoryScanner; |
63 | |
import org.apache.maven.plugins.annotations.Component; |
64 | |
import org.apache.maven.plugins.annotations.Parameter; |
65 | |
import org.apache.maven.project.MavenProject; |
66 | |
import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; |
67 | |
import org.apache.maven.shared.utils.StringUtils; |
68 | |
import org.apache.maven.shared.utils.io.FileUtils; |
69 | |
import org.apache.maven.surefire.booter.ClassLoaderConfiguration; |
70 | |
import org.apache.maven.surefire.booter.Classpath; |
71 | |
import org.apache.maven.surefire.booter.ClasspathConfiguration; |
72 | |
import org.apache.maven.surefire.booter.KeyValueSource; |
73 | |
import org.apache.maven.surefire.booter.ProviderConfiguration; |
74 | |
import org.apache.maven.surefire.booter.ProviderParameterNames; |
75 | |
import org.apache.maven.surefire.booter.StartupConfiguration; |
76 | |
import org.apache.maven.surefire.booter.SurefireBooterForkException; |
77 | |
import org.apache.maven.surefire.booter.SurefireExecutionException; |
78 | |
import org.apache.maven.surefire.report.ReporterConfiguration; |
79 | |
import org.apache.maven.surefire.suite.RunResult; |
80 | |
import org.apache.maven.surefire.testset.DirectoryScannerParameters; |
81 | |
import org.apache.maven.surefire.testset.RunOrderParameters; |
82 | |
import org.apache.maven.surefire.testset.TestArtifactInfo; |
83 | |
import org.apache.maven.surefire.testset.TestRequest; |
84 | |
import org.apache.maven.surefire.testset.TestSetFailedException; |
85 | |
import org.apache.maven.surefire.util.DefaultScanResult; |
86 | |
import org.apache.maven.surefire.util.NestedCheckedException; |
87 | |
import org.apache.maven.surefire.util.NestedRuntimeException; |
88 | |
import org.apache.maven.surefire.util.RunOrder; |
89 | |
import org.apache.maven.toolchain.Toolchain; |
90 | |
import org.apache.maven.toolchain.ToolchainManager; |
91 | |
|
92 | |
import javax.annotation.Nonnull; |
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | 0 | public abstract class AbstractSurefireMojo |
101 | |
extends AbstractMojo |
102 | |
implements SurefireExecutionParameters |
103 | |
{ |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
@Parameter( defaultValue = "${plugin}", readonly = true ) |
114 | |
protected PluginDescriptor pluginDescriptor; |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
@Parameter( property = "skipTests", defaultValue = "false" ) |
123 | |
protected boolean skipTests; |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
@Parameter( property = "maven.test.skip.exec" ) |
132 | |
protected boolean skipExec; |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
@Parameter( property = "maven.test.skip", defaultValue = "false" ) |
140 | |
protected boolean skip; |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
@Component |
146 | |
protected MavenProject project; |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
@Parameter( defaultValue = "${basedir}" ) |
153 | |
protected File basedir; |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
@Parameter( defaultValue = "${project.build.testOutputDirectory}" ) |
160 | |
protected File testClassesDirectory; |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
@Parameter( defaultValue = "${project.build.outputDirectory}" ) |
167 | |
protected File classesDirectory; |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
@Parameter( property = "maven.test.dependency.excludes" ) |
176 | |
private String[] classpathDependencyExcludes; |
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
@Parameter( defaultValue = "" ) |
193 | |
private String classpathDependencyScopeExclude; |
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
@Parameter( property = "maven.test.additionalClasspath" ) |
201 | |
private String[] additionalClasspathElements; |
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
@Parameter( defaultValue = "${project.build.testSourceDirectory}", required = true ) |
209 | |
protected File testSourceDirectory; |
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
@Parameter |
216 | |
protected File includesFile; |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
@Parameter |
231 | |
protected List<String> excludes; |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
@Parameter |
238 | |
protected File excludesFile; |
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
@Parameter( defaultValue = "${localRepository}", required = true, readonly = true ) |
245 | |
protected ArtifactRepository localRepository; |
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
@Parameter |
253 | |
protected Properties systemProperties; |
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
@Parameter |
261 | |
protected Map<String, String> systemPropertyVariables; |
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
@Parameter |
269 | |
protected File systemPropertiesFile; |
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
@Parameter |
278 | |
protected Properties properties; |
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
@Parameter( property = "plugin.artifactMap", required = true, readonly = true ) |
285 | |
protected Map<String, Artifact> pluginArtifactMap; |
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
@Parameter( property = "project.artifactMap", readonly = true, required = true ) |
292 | |
protected Map<String, Artifact> projectArtifactMap; |
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
@Parameter( property = "surefire.reportNameSuffix", defaultValue = "" ) |
301 | |
protected String reportNameSuffix; |
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
@Parameter( property = "maven.test.redirectTestOutputToFile", defaultValue = "false" ) |
310 | |
protected boolean redirectTestOutputToFile; |
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
@Parameter( property = "failIfNoTests" ) |
318 | |
protected Boolean failIfNoTests; |
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
@Parameter( property = "forkMode", defaultValue = "once" ) |
330 | |
protected String forkMode; |
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
@Parameter( property = "jvm" ) |
340 | |
protected String jvm; |
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
@Parameter( property = "argLine" ) |
348 | |
protected String argLine; |
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | 0 | @Parameter |
356 | |
protected Map<String, String> environmentVariables = new HashMap<String, String>(); |
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
@Parameter( property = "basedir" ) |
364 | |
protected File workingDirectory; |
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
@Parameter( property = "childDelegation", defaultValue = "false" ) |
375 | |
protected boolean childDelegation; |
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
@Parameter( property = "groups" ) |
385 | |
protected String groups; |
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
@Parameter( property = "excludedGroups" ) |
395 | |
protected String excludedGroups; |
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
@Parameter |
407 | |
protected File[] suiteXmlFiles; |
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
@Parameter( property = "junitArtifactName", defaultValue = "junit:junit" ) |
415 | |
protected String junitArtifactName; |
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
@Parameter( property = "testNGArtifactName", defaultValue = "org.testng:testng" ) |
423 | |
protected String testNGArtifactName; |
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
@Parameter( property = "threadCount" ) |
432 | |
protected int threadCount; |
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
@Parameter( property = "forkCount", defaultValue = "1" ) |
450 | |
private String forkCount; |
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
|
458 | |
|
459 | |
@Parameter( property = "reuseForks", defaultValue = "true" ) |
460 | |
private boolean reuseForks; |
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
@Parameter( property = "perCoreThreadCount", defaultValue = "true" ) |
468 | |
protected boolean perCoreThreadCount; |
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
@Parameter( property = "useUnlimitedThreads", defaultValue = "false" ) |
478 | |
protected boolean useUnlimitedThreads; |
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
@Parameter( property = "parallel" ) |
497 | |
protected String parallel; |
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
|
522 | |
@Parameter( property = "threadCountSuites", defaultValue = "0" ) |
523 | |
protected int threadCountSuites; |
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
|
548 | |
@Parameter( property = "threadCountClasses", defaultValue = "0" ) |
549 | |
protected int threadCountClasses; |
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
|
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
@Parameter( property = "threadCountMethods", defaultValue = "0" ) |
566 | |
protected int threadCountMethods; |
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
@Parameter( property = "trimStackTrace", defaultValue = "true" ) |
574 | |
protected boolean trimStackTrace; |
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
@Component |
580 | |
protected ArtifactResolver artifactResolver; |
581 | |
|
582 | |
|
583 | |
|
584 | |
|
585 | |
@Component |
586 | |
protected ArtifactFactory artifactFactory; |
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | |
@Parameter( defaultValue = "${project.pluginArtifactRepositories}" ) |
594 | |
protected List<ArtifactRepository> remoteRepositories; |
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
@Component |
600 | |
protected ArtifactMetadataSource metadataSource; |
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
@Parameter( property = "disableXmlReport", defaultValue = "false" ) |
608 | |
protected boolean disableXmlReport; |
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
@Parameter( property = "enableAssertions", defaultValue = "true" ) |
617 | |
protected boolean enableAssertions; |
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
@Component |
623 | |
protected MavenSession session; |
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
@Parameter( property = "objectFactory" ) |
631 | |
protected String objectFactory; |
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
@Parameter( defaultValue = "${session.parallel}", readonly = true ) |
637 | |
protected Boolean parallelMavenExecution; |
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
|
646 | |
|
647 | |
|
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
|
656 | |
|
657 | |
|
658 | |
|
659 | |
@Parameter( defaultValue = "filesystem" ) |
660 | |
protected String runOrder; |
661 | |
|
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
@Parameter( property = "dependenciesToScan" ) |
669 | |
private String[] dependenciesToScan; |
670 | |
|
671 | |
|
672 | |
|
673 | |
|
674 | |
@Component |
675 | |
protected ToolchainManager toolchainManager; |
676 | |
|
677 | |
private Artifact surefireBooterArtifact; |
678 | |
|
679 | |
private Toolchain toolchain; |
680 | |
|
681 | 0 | private int effectiveForkCount = -1; |
682 | |
|
683 | |
|
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
public static final String THREAD_NUMBER_PLACEHOLDER = "${surefire.threadNumber}"; |
689 | |
|
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
public static final String FORK_NUMBER_PLACEHOLDER = "${surefire.forkNumber}"; |
695 | |
|
696 | |
protected abstract String getPluginName(); |
697 | |
|
698 | |
private SurefireDependencyResolver dependencyResolver; |
699 | |
|
700 | |
public void execute() |
701 | |
throws MojoExecutionException, MojoFailureException |
702 | |
{ |
703 | |
|
704 | 0 | setupStuff(); |
705 | |
|
706 | 0 | if ( verifyParameters() && !hasExecutedBefore() ) |
707 | |
{ |
708 | 0 | DefaultScanResult scan = scanForTestClasses(); |
709 | 0 | if ( !isValidSuiteXmlFileConfig() && scan.isEmpty() ) |
710 | |
{ |
711 | 0 | if ( getEffectiveFailIfNoTests() ) |
712 | |
{ |
713 | 0 | throw new MojoFailureException( |
714 | |
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); |
715 | |
} |
716 | 0 | handleSummary( RunResult.noTestsRun(), null ); |
717 | 0 | return; |
718 | |
} |
719 | 0 | logReportsDirectory(); |
720 | 0 | executeAfterPreconditionsChecked( scan ); |
721 | |
} |
722 | 0 | } |
723 | |
|
724 | |
private void setupStuff() |
725 | |
{ |
726 | 0 | createDependencyResolver(); |
727 | 0 | surefireBooterArtifact = getSurefireBooterArtifact(); |
728 | 0 | toolchain = getToolchain(); |
729 | 0 | } |
730 | |
|
731 | |
private DefaultScanResult scanForTestClasses() |
732 | |
{ |
733 | 0 | DefaultScanResult scan = scanDirectories(); |
734 | 0 | DefaultScanResult scanDeps = scanDependencies(); |
735 | 0 | return scan.append( scanDeps ); |
736 | |
} |
737 | |
|
738 | |
private DefaultScanResult scanDirectories() |
739 | |
{ |
740 | 0 | return new DirectoryScanner( getTestClassesDirectory(), getIncludeList(), getExcludeList(), |
741 | |
getSpecificTests() ).scan(); |
742 | |
} |
743 | |
|
744 | |
private DefaultScanResult scanDependencies() |
745 | |
{ |
746 | 0 | if ( getDependenciesToScan() == null ) |
747 | |
{ |
748 | 0 | return null; |
749 | |
} |
750 | |
else |
751 | |
{ |
752 | |
try |
753 | |
{ |
754 | |
|
755 | 0 | return new DependencyScanner( DependencyScanner.filter( project.getTestArtifacts(), |
756 | |
Arrays.asList( getDependenciesToScan() ) ), |
757 | |
getIncludeList(), getExcludeList(), getSpecificTests() ).scan(); |
758 | |
} |
759 | 0 | catch ( Exception e ) |
760 | |
{ |
761 | 0 | throw new RuntimeException( e ); |
762 | |
} |
763 | |
} |
764 | |
} |
765 | |
|
766 | |
boolean verifyParameters() |
767 | |
throws MojoFailureException, MojoExecutionException |
768 | |
{ |
769 | 0 | setProperties( new SurefireProperties( getProperties() ) ); |
770 | 0 | if ( isSkipExecution() ) |
771 | |
{ |
772 | 0 | getLog().info( "Tests are skipped." ); |
773 | 0 | return false; |
774 | |
} |
775 | |
|
776 | 0 | String jvmToUse = getJvm(); |
777 | 0 | if ( toolchain != null ) |
778 | |
{ |
779 | 0 | getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + toolchain ); |
780 | 0 | if ( jvmToUse != null ) |
781 | |
{ |
782 | 0 | getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse ); |
783 | |
} |
784 | |
} |
785 | |
|
786 | 0 | if ( !getTestClassesDirectory().exists() |
787 | |
&& ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) ) |
788 | |
{ |
789 | 0 | if ( Boolean.TRUE.equals( getFailIfNoTests() ) ) |
790 | |
{ |
791 | 0 | throw new MojoFailureException( "No tests to run!" ); |
792 | |
} |
793 | 0 | getLog().info( "No tests to run." ); |
794 | |
} |
795 | |
else |
796 | |
{ |
797 | 0 | convertDeprecatedForkMode(); |
798 | 0 | ensureWorkingDirectoryExists(); |
799 | 0 | ensureParallelRunningCompatibility(); |
800 | 0 | ensureThreadCountWithPerThread(); |
801 | 0 | warnIfUselessUseSystemClassLoaderParameter(); |
802 | 0 | warnIfDefunctGroupsCombinations(); |
803 | |
} |
804 | 0 | return true; |
805 | |
} |
806 | |
|
807 | |
protected abstract boolean isSkipExecution(); |
808 | |
|
809 | |
protected void executeAfterPreconditionsChecked( DefaultScanResult scanResult ) |
810 | |
throws MojoExecutionException, MojoFailureException |
811 | |
{ |
812 | |
|
813 | 0 | List<ProviderInfo> providers = createProviders(); |
814 | |
|
815 | 0 | RunResult current = RunResult.noTestsRun(); |
816 | |
|
817 | 0 | NestedCheckedException firstForkException = null; |
818 | 0 | for ( ProviderInfo provider : providers ) |
819 | |
{ |
820 | |
try |
821 | |
{ |
822 | 0 | current = current.aggregate( executeProvider( provider, scanResult ) ); |
823 | |
} |
824 | 0 | catch ( SurefireBooterForkException e ) |
825 | |
{ |
826 | 0 | if ( firstForkException == null ) |
827 | |
{ |
828 | 0 | firstForkException = e; |
829 | |
} |
830 | |
} |
831 | 0 | catch ( SurefireExecutionException e ) |
832 | |
{ |
833 | 0 | if ( firstForkException == null ) |
834 | |
{ |
835 | 0 | firstForkException = e; |
836 | |
} |
837 | |
} |
838 | 0 | catch ( TestSetFailedException e ) |
839 | |
{ |
840 | 0 | if ( firstForkException == null ) |
841 | |
{ |
842 | 0 | firstForkException = e; |
843 | |
} |
844 | 0 | } |
845 | 0 | } |
846 | |
|
847 | 0 | if ( firstForkException != null ) |
848 | |
{ |
849 | 0 | current = RunResult.failure( current, firstForkException ); |
850 | |
} |
851 | |
|
852 | 0 | handleSummary( current, firstForkException ); |
853 | 0 | } |
854 | |
|
855 | |
|
856 | |
private void createDependencyResolver() |
857 | |
{ |
858 | 0 | dependencyResolver = |
859 | |
new SurefireDependencyResolver( getArtifactResolver(), getArtifactFactory(), getLog(), getLocalRepository(), |
860 | |
getRemoteRepositories(), getMetadataSource(), getPluginName() ); |
861 | 0 | } |
862 | |
|
863 | |
protected List<ProviderInfo> createProviders() |
864 | |
throws MojoFailureException, MojoExecutionException |
865 | |
{ |
866 | 0 | final Artifact junitDepArtifact = getJunitDepArtifact(); |
867 | 0 | ProviderList wellKnownProviders = |
868 | |
new ProviderList( new DynamicProviderInfo( null ), new TestNgProviderInfo( getTestNgArtifact() ), |
869 | |
new JUnitCoreProviderInfo( getJunitArtifact(), junitDepArtifact ), |
870 | |
new JUnit4ProviderInfo( getJunitArtifact(), junitDepArtifact ), |
871 | |
new JUnit3ProviderInfo() ); |
872 | |
|
873 | 0 | return wellKnownProviders.resolve( getLog() ); |
874 | |
} |
875 | |
|
876 | |
private SurefireProperties setupProperties() |
877 | |
{ |
878 | 0 | SurefireProperties sysProps = null; |
879 | |
try { |
880 | 0 | sysProps = SurefireProperties.loadProperties( systemPropertiesFile ); |
881 | |
} |
882 | 0 | catch ( IOException e ) |
883 | |
{ |
884 | 0 | String msg = "The system property file '" + systemPropertiesFile.getAbsolutePath() + "' can't be read."; |
885 | 0 | if ( getLog().isDebugEnabled() ) |
886 | |
{ |
887 | 0 | getLog().warn( msg, e ); |
888 | |
} |
889 | |
else |
890 | |
{ |
891 | 0 | getLog().warn( msg ); |
892 | |
} |
893 | 0 | } |
894 | |
|
895 | 0 | SurefireProperties result = |
896 | |
SurefireProperties.calculateEffectiveProperties( getSystemProperties(), getSystemPropertyVariables(), |
897 | |
getUserProperties(), sysProps ); |
898 | |
|
899 | 0 | result.setProperty( "basedir", getBasedir().getAbsolutePath() ); |
900 | 0 | result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() ); |
901 | 0 | result.setProperty( "localRepository", getLocalRepository().getBasedir() ); |
902 | |
|
903 | 0 | for ( Object o : result.propertiesThatCannotBeSetASystemProperties() ) |
904 | |
{ |
905 | 0 | getLog().warn( o + " cannot be set as system property, use <argLine>-D" + o + "=...<argLine> instead" ); |
906 | |
|
907 | 0 | } |
908 | 0 | if ( getLog().isDebugEnabled() ) |
909 | |
{ |
910 | 0 | showToLog( result, getLog(), "system property" ); |
911 | |
} |
912 | 0 | return result; |
913 | |
} |
914 | |
|
915 | |
public void showToLog( SurefireProperties props, org.apache.maven.plugin.logging.Log log, String setting ) |
916 | |
{ |
917 | 0 | for ( Object key : props.getStringKeySet() ) |
918 | |
{ |
919 | 0 | String value = props.getProperty( (String) key ); |
920 | 0 | log.debug( "Setting " + setting + " [" + key + "]=[" + value + "]" ); |
921 | 0 | } |
922 | 0 | } |
923 | |
|
924 | |
|
925 | |
private RunResult executeProvider( ProviderInfo provider, DefaultScanResult scanResult ) |
926 | |
throws MojoExecutionException, MojoFailureException, SurefireExecutionException, SurefireBooterForkException, |
927 | |
TestSetFailedException |
928 | |
{ |
929 | 0 | SurefireProperties effectiveProperties = setupProperties(); |
930 | 0 | ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration( isForking() ); |
931 | |
|
932 | 0 | RunOrderParameters runOrderParameters = |
933 | |
new RunOrderParameters( getRunOrder(), getStatisticsFileName( getConfigChecksum() ) ); |
934 | |
|
935 | |
final RunResult result; |
936 | 0 | if ( isNotForking() ) |
937 | |
{ |
938 | 0 | createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties(); |
939 | |
|
940 | 0 | InPluginVMSurefireStarter surefireStarter = |
941 | |
createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters ); |
942 | 0 | result = surefireStarter.runSuitesInProcess( scanResult ); |
943 | 0 | } |
944 | |
else |
945 | |
{ |
946 | 0 | ForkConfiguration forkConfiguration = getForkConfiguration(); |
947 | 0 | if ( getLog().isDebugEnabled() ) |
948 | |
{ |
949 | 0 | showMap( getEnvironmentVariables(), "environment variable" ); |
950 | |
} |
951 | |
|
952 | 0 | Properties originalSystemProperties = (Properties) System.getProperties().clone(); |
953 | |
try |
954 | |
{ |
955 | 0 | ForkStarter forkStarter = |
956 | |
createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters, |
957 | |
getLog() ); |
958 | 0 | result = forkStarter.run( effectiveProperties, scanResult ); |
959 | |
} |
960 | |
finally |
961 | |
{ |
962 | 0 | System.setProperties( originalSystemProperties ); |
963 | 0 | cleanupForkConfiguration( forkConfiguration ); |
964 | 0 | } |
965 | |
} |
966 | 0 | return result; |
967 | |
} |
968 | |
|
969 | |
|
970 | |
public static SurefireProperties createCopyAndReplaceForkNumPlaceholder( |
971 | |
SurefireProperties effectiveSystemProperties, int threadNumber ) |
972 | |
{ |
973 | 0 | SurefireProperties filteredProperties = new SurefireProperties( ( KeyValueSource) effectiveSystemProperties ); |
974 | 0 | String threadNumberString = String.valueOf( threadNumber ); |
975 | 0 | for ( Entry<Object, Object> entry : effectiveSystemProperties.entrySet() ) |
976 | |
{ |
977 | 0 | if ( entry.getValue() instanceof String ) |
978 | |
{ |
979 | 0 | String value = (String) entry.getValue(); |
980 | 0 | value = value.replace( THREAD_NUMBER_PLACEHOLDER, threadNumberString ); |
981 | 0 | value = value.replace( FORK_NUMBER_PLACEHOLDER, threadNumberString ); |
982 | |
|
983 | 0 | filteredProperties.put( entry.getKey(), value ); |
984 | |
} |
985 | 0 | } |
986 | 0 | return filteredProperties; |
987 | |
} |
988 | |
|
989 | |
protected void cleanupForkConfiguration( ForkConfiguration forkConfiguration ) |
990 | |
{ |
991 | 0 | if ( !getLog().isDebugEnabled() && forkConfiguration != null ) |
992 | |
{ |
993 | 0 | File tempDirectory = forkConfiguration.getTempDirectory(); |
994 | |
try |
995 | |
{ |
996 | 0 | FileUtils.deleteDirectory( tempDirectory ); |
997 | |
} |
998 | 0 | catch ( IOException ioe ) |
999 | |
{ |
1000 | 0 | getLog().warn( "Could not delete temp direcotry " + tempDirectory + " because " + ioe.getMessage() ); |
1001 | 0 | } |
1002 | |
} |
1003 | 0 | } |
1004 | |
|
1005 | |
protected abstract void handleSummary( RunResult summary, NestedCheckedException firstForkException ) |
1006 | |
throws MojoExecutionException, MojoFailureException; |
1007 | |
|
1008 | |
protected void logReportsDirectory() |
1009 | |
{ |
1010 | 0 | getLog().info( |
1011 | |
StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() ); |
1012 | 0 | } |
1013 | |
|
1014 | |
|
1015 | |
final Toolchain getToolchain() |
1016 | |
{ |
1017 | 0 | Toolchain tc = null; |
1018 | |
|
1019 | 0 | if ( getToolchainManager() != null ) |
1020 | |
{ |
1021 | 0 | tc = getToolchainManager().getToolchainFromBuildContext( "jdk", getSession() ); |
1022 | |
} |
1023 | |
|
1024 | 0 | return tc; |
1025 | |
} |
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
|
1030 | |
|
1031 | |
private void convertTestNGParameters() throws MojoExecutionException |
1032 | |
{ |
1033 | 0 | if ( this.getParallel() != null ) |
1034 | |
{ |
1035 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_PROP, this.getParallel() ); |
1036 | |
} |
1037 | 0 | convertGroupParameters(); |
1038 | |
|
1039 | 0 | if ( this.getThreadCount() > 0 ) |
1040 | |
{ |
1041 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, |
1042 | |
Integer.toString( this.getThreadCount() ) ); |
1043 | |
} |
1044 | 0 | if ( this.getObjectFactory() != null ) |
1045 | |
{ |
1046 | 0 | getProperties().setProperty( "objectfactory", this.getObjectFactory() ); |
1047 | |
} |
1048 | 0 | if ( this.getTestClassesDirectory() != null ) |
1049 | |
{ |
1050 | 0 | getProperties().setProperty( "testng.test.classpath", getTestClassesDirectory().getAbsolutePath() ); |
1051 | |
} |
1052 | |
|
1053 | 0 | Artifact testNgArtifact = getTestNgArtifact(); |
1054 | 0 | if ( testNgArtifact != null){ |
1055 | |
|
1056 | 0 | DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion( testNgArtifact.getVersion() ); |
1057 | 0 | getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion ) ); |
1058 | |
} |
1059 | |
|
1060 | |
|
1061 | 0 | } |
1062 | |
|
1063 | |
private static String getConfiguratorName( ArtifactVersion version ) |
1064 | |
throws MojoExecutionException |
1065 | |
{ |
1066 | |
try |
1067 | |
{ |
1068 | 0 | VersionRange range = VersionRange.createFromVersionSpec( "[4.7,5.1]" ); |
1069 | 0 | if ( range.containsVersion( version ) ) |
1070 | |
{ |
1071 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG4751Configurator"; |
1072 | |
} |
1073 | 0 | range = VersionRange.createFromVersionSpec( "[5.2]" ); |
1074 | 0 | if ( range.containsVersion( version ) ) |
1075 | |
{ |
1076 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG52Configurator"; |
1077 | |
} |
1078 | 0 | range = VersionRange.createFromVersionSpec( "[5.3,6.4]" ); |
1079 | 0 | if ( range.containsVersion( version ) ) |
1080 | |
{ |
1081 | 0 | return "org.apache.maven.surefire.testng.conf.TestNGMapConfigurator"; |
1082 | |
} |
1083 | 0 | range = VersionRange.createFromVersionSpec( "[6.5,)" ); |
1084 | 0 | if ( range.containsVersion( version ) ) |
1085 | |
{ |
1086 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG652Configurator"; |
1087 | |
} |
1088 | |
|
1089 | 0 | throw new MojoExecutionException( "Unknown TestNG version " + version ); |
1090 | |
} |
1091 | 0 | catch ( InvalidVersionSpecificationException invsex ) |
1092 | |
{ |
1093 | 0 | throw new MojoExecutionException( "Bug in plugin. Please report it with the attached stacktrace", invsex ); |
1094 | |
} |
1095 | |
} |
1096 | |
|
1097 | |
|
1098 | |
private void convertGroupParameters() |
1099 | |
{ |
1100 | 0 | if ( this.getExcludedGroups() != null ) |
1101 | |
{ |
1102 | 0 | getProperties().setProperty( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP, this.getExcludedGroups() ); |
1103 | |
} |
1104 | 0 | if ( this.getGroups() != null ) |
1105 | |
{ |
1106 | 0 | getProperties().setProperty( ProviderParameterNames.TESTNG_GROUPS_PROP, this.getGroups() ); |
1107 | |
} |
1108 | 0 | } |
1109 | |
|
1110 | |
protected boolean isAnyConcurrencySelected() |
1111 | |
{ |
1112 | 0 | return this.getParallel() != null && this.getParallel().trim().length() > 0; |
1113 | |
} |
1114 | |
|
1115 | |
protected boolean isAnyGroupsSelected() |
1116 | |
{ |
1117 | 0 | return this.getGroups() != null || this.getExcludedGroups() != null; |
1118 | |
} |
1119 | |
|
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
private void convertJunitCoreParameters() throws MojoExecutionException |
1125 | |
{ |
1126 | 0 | checkThreadCountEntity( getThreadCountSuites(), "suites" ); |
1127 | 0 | checkThreadCountEntity( getThreadCountClasses(), "classes" ); |
1128 | 0 | checkThreadCountEntity( getThreadCountMethods(), "methods" ); |
1129 | |
|
1130 | 0 | String usedParallel = ( getParallel() != null ) ? getParallel() : "none"; |
1131 | |
|
1132 | 0 | if ( !"none".equals( usedParallel )) |
1133 | |
{ |
1134 | 0 | checkNonForkedThreads( parallel ); |
1135 | |
} |
1136 | |
|
1137 | 0 | String usedThreadCount = Integer.toString( getThreadCount() ); |
1138 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_PROP, usedParallel ); |
1139 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, usedThreadCount ); |
1140 | 0 | getProperties().setProperty( "perCoreThreadCount", Boolean.toString( getPerCoreThreadCount() ) ); |
1141 | 0 | getProperties().setProperty( "useUnlimitedThreads", Boolean.toString( getUseUnlimitedThreads() ) ); |
1142 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNTSUITES_PROP, Integer.toString( getThreadCountSuites() ) ); |
1143 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNTCLASSES_PROP, Integer.toString( getThreadCountClasses() ) ); |
1144 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNTMETHODS_PROP, Integer.toString( getThreadCountMethods() ) ); |
1145 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_TIMEOUT_PROP, |
1146 | |
Integer.toString( getParallelTestsTimeoutInSeconds() ) ); |
1147 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_TIMEOUTFORCED_PROP, |
1148 | |
Integer.toString( getParallelTestsTimeoutForcedInSeconds() ) ); |
1149 | |
|
1150 | 0 | String message = |
1151 | |
"parallel='" + usedParallel + '\'' + ", perCoreThreadCount=" + getPerCoreThreadCount() + ", threadCount=" |
1152 | |
+ usedThreadCount + ", useUnlimitedThreads=" + getUseUnlimitedThreads() + |
1153 | |
", threadCountSuites=" + getThreadCountSuites() + ", threadCountClasses=" + getThreadCountClasses() + |
1154 | |
", threadCountMethods=" + getThreadCountMethods(); |
1155 | |
|
1156 | 0 | getLog().info( message ); |
1157 | 0 | } |
1158 | |
|
1159 | |
private void checkNonForkedThreads( String parallel ) throws MojoExecutionException |
1160 | |
{ |
1161 | 0 | if ( "suites".equals( parallel ) ) |
1162 | |
{ |
1163 | 0 | if ( !( getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountSuites() > 0 ) ) |
1164 | |
{ |
1165 | 0 | throw new MojoExecutionException( "Use threadCount or threadCountSuites > 0 or useUnlimitedThreads=true " + |
1166 | |
"for parallel='suites'" ); |
1167 | |
} |
1168 | 0 | setThreadCountClasses( 0 ); |
1169 | 0 | setThreadCountMethods( 0 ); |
1170 | |
} |
1171 | 0 | else if ( "classes".equals( parallel ) ) |
1172 | |
{ |
1173 | 0 | if ( !( getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountClasses() > 0 ) ) |
1174 | |
{ |
1175 | 0 | throw new MojoExecutionException( "Use threadCount or threadCountClasses > 0 or useUnlimitedThreads=true " + |
1176 | |
"for parallel='classes'" ); |
1177 | |
} |
1178 | 0 | setThreadCountSuites( 0 ); |
1179 | 0 | setThreadCountMethods( 0 ); |
1180 | |
} |
1181 | 0 | else if ( "methods".equals( parallel ) ) |
1182 | |
{ |
1183 | 0 | if ( !( getUseUnlimitedThreads() || getThreadCount() > 0 ^ getThreadCountMethods() > 0 ) ) |
1184 | |
{ |
1185 | 0 | throw new MojoExecutionException( "Use threadCount or threadCountMethods > 0 or useUnlimitedThreads=true " + |
1186 | |
"for parallel='methods'" ); |
1187 | |
} |
1188 | 0 | setThreadCountSuites( 0 ); |
1189 | 0 | setThreadCountClasses( 0 ); |
1190 | |
} |
1191 | 0 | else if ( "suitesAndClasses".equals( parallel ) ) |
1192 | |
{ |
1193 | 0 | if ( !( getUseUnlimitedThreads() |
1194 | |
|| onlyThreadCount() |
1195 | |
|| getThreadCountSuites() > 0 && getThreadCountClasses() > 0 |
1196 | |
&& getThreadCount() == 0 && getThreadCountMethods() == 0 |
1197 | |
|| getThreadCount() > 0 && getThreadCountSuites() > 0 && getThreadCountClasses() > 0 |
1198 | |
&& getThreadCountMethods() == 0 |
1199 | |
|| getThreadCount() > 0 && getThreadCountSuites() > 0 && getThreadCount() > getThreadCountSuites() |
1200 | |
&& getThreadCountClasses() == 0 && getThreadCountMethods() == 0 ) ) |
1201 | |
{ |
1202 | 0 | throw new MojoExecutionException( "Use useUnlimitedThreads=true, " + |
1203 | |
"or only threadCount > 0, " + |
1204 | |
"or (threadCountSuites > 0 and threadCountClasses > 0), " + |
1205 | |
"or (threadCount > 0 and threadCountSuites > 0 and threadCountClasses > 0) " + |
1206 | |
"or (threadCount > 0 and threadCountSuites > 0 and threadCount > threadCountSuites) " + |
1207 | |
"for parallel='suitesAndClasses' or 'both'" ); |
1208 | |
} |
1209 | 0 | setThreadCountMethods( 0 ); |
1210 | |
} |
1211 | 0 | else if ( "suitesAndMethods".equals( parallel ) ) |
1212 | |
{ |
1213 | 0 | if ( !( getUseUnlimitedThreads() |
1214 | |
|| onlyThreadCount() |
1215 | |
|| getThreadCountSuites() > 0 && getThreadCountMethods() > 0 |
1216 | |
&& getThreadCount() == 0 && getThreadCountClasses() == 0 |
1217 | |
|| getThreadCount() > 0 && getThreadCountSuites() > 0 && getThreadCountMethods() > 0 |
1218 | |
&& getThreadCountClasses() == 0 |
1219 | |
|| getThreadCount() > 0 && getThreadCountSuites() > 0 && getThreadCount() > getThreadCountSuites() |
1220 | |
&& getThreadCountClasses() == 0 && getThreadCountMethods() == 0 ) ) |
1221 | |
{ |
1222 | 0 | throw new MojoExecutionException( "Use useUnlimitedThreads=true, " + |
1223 | |
"or only threadCount > 0, " + |
1224 | |
"or (threadCountSuites > 0 and threadCountMethods > 0), " + |
1225 | |
"or (threadCount > 0 and threadCountSuites > 0 and threadCountMethods > 0), " + |
1226 | |
"or (threadCount > 0 and threadCountSuites > 0 and threadCount > threadCountSuites) " + |
1227 | |
"for parallel='suitesAndMethods'" ); |
1228 | |
} |
1229 | 0 | setThreadCountClasses( 0 ); |
1230 | |
} |
1231 | 0 | else if ( "both".equals( parallel ) || "classesAndMethods".equals( parallel ) ) |
1232 | |
{ |
1233 | 0 | if ( !( getUseUnlimitedThreads() |
1234 | |
|| onlyThreadCount() |
1235 | |
|| getThreadCountClasses() > 0 && getThreadCountMethods() > 0 |
1236 | |
&& getThreadCount() == 0 && getThreadCountSuites() == 0 |
1237 | |
|| getThreadCount() > 0 && getThreadCountClasses() > 0 && getThreadCountMethods() > 0 |
1238 | |
&& getThreadCountSuites() == 0 |
1239 | |
|| getThreadCount() > 0 && getThreadCountClasses() > 0 && getThreadCount() > getThreadCountClasses() |
1240 | |
&& getThreadCountSuites() == 0 && getThreadCountMethods() == 0 ) ) |
1241 | |
{ |
1242 | 0 | throw new MojoExecutionException( "Use useUnlimitedThreads=true, " + |
1243 | |
"or only threadCount > 0, " + |
1244 | |
"or (threadCountClasses > 0 and threadCountMethods > 0), " + |
1245 | |
"or (threadCount > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + |
1246 | |
"or (threadCount > 0 and threadCountClasses > 0 and threadCount > threadCountClasses) " + |
1247 | |
"for parallel='both' or parallel='classesAndMethods'" ); |
1248 | |
} |
1249 | 0 | setThreadCountSuites( 0 ); |
1250 | |
} |
1251 | 0 | else if ( "all".equals( parallel ) ) |
1252 | |
{ |
1253 | 0 | if ( !( getUseUnlimitedThreads() |
1254 | |
|| onlyThreadCount() |
1255 | |
|| getThreadCountSuites() > 0 && getThreadCountClasses() > 0 && getThreadCountMethods() > 0 |
1256 | |
|| getThreadCount() > 0 && getThreadCountSuites() > 0 && getThreadCountClasses() > 0 |
1257 | |
&& getThreadCountMethods() == 0 |
1258 | |
&& getThreadCount() > ( getThreadCountSuites() + getThreadCountClasses() ) ) ) |
1259 | |
{ |
1260 | 0 | throw new MojoExecutionException( "Use useUnlimitedThreads=true, " + |
1261 | |
"or only threadCount > 0, " + |
1262 | |
"or (threadCountSuites > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + |
1263 | |
"or every thread-count is specified, " + |
1264 | |
"or (threadCount > 0 and threadCountSuites > 0 and threadCountClasses > 0 " + |
1265 | |
"and threadCount > threadCountSuites + threadCountClasses) " + |
1266 | |
"for parallel='all'" ); |
1267 | |
} |
1268 | |
} |
1269 | |
else |
1270 | |
{ |
1271 | 0 | throw new MojoExecutionException( "Illegal parallel='" + parallel + "'" ); |
1272 | |
} |
1273 | 0 | } |
1274 | |
|
1275 | |
private boolean onlyThreadCount() |
1276 | |
{ |
1277 | 0 | return getThreadCount() > 0 && getThreadCountSuites() == 0 && getThreadCountClasses() == 0 |
1278 | |
&& getThreadCountMethods() == 0; |
1279 | |
} |
1280 | |
|
1281 | |
private static void checkThreadCountEntity(int count, String entity) throws MojoExecutionException |
1282 | |
{ |
1283 | 0 | if ( count < 0 ) |
1284 | |
{ |
1285 | 0 | throw new MojoExecutionException("parallel maven execution does not allow negative thread-count" + entity); |
1286 | |
} |
1287 | 0 | } |
1288 | |
|
1289 | |
private boolean isJunit47Compatible( Artifact artifact ) |
1290 | |
{ |
1291 | 0 | return dependencyResolver.isWithinVersionSpec( artifact, "[4.7,)" ); |
1292 | |
} |
1293 | |
|
1294 | |
private boolean isAnyJunit4( Artifact artifact ) |
1295 | |
{ |
1296 | 0 | return dependencyResolver.isWithinVersionSpec( artifact, "[4.0,)" ); |
1297 | |
} |
1298 | |
|
1299 | |
static boolean isForkModeNever( String forkMode ) |
1300 | |
{ |
1301 | 0 | return ForkConfiguration.FORK_NEVER.equals( forkMode ); |
1302 | |
} |
1303 | |
|
1304 | |
boolean isForking() |
1305 | |
{ |
1306 | 0 | return 0 < getEffectiveForkCount(); |
1307 | |
} |
1308 | |
|
1309 | |
String getEffectiveForkMode() |
1310 | |
{ |
1311 | 0 | String forkMode1 = getForkMode(); |
1312 | |
|
1313 | 0 | if ( toolchain != null && isForkModeNever( forkMode1 ) ) |
1314 | |
{ |
1315 | 0 | return ForkConfiguration.FORK_ONCE; |
1316 | |
} |
1317 | |
|
1318 | 0 | return ForkConfiguration.getEffectiveForkMode( forkMode1 ); |
1319 | |
} |
1320 | |
|
1321 | |
private List<RunOrder> getRunOrders() |
1322 | |
{ |
1323 | 0 | String runOrderString = getRunOrder(); |
1324 | 0 | RunOrder[] runOrder = runOrderString == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrderString ); |
1325 | 0 | return Arrays.asList( runOrder ); |
1326 | |
} |
1327 | |
|
1328 | |
private boolean requiresRunHistory() |
1329 | |
{ |
1330 | 0 | final List<RunOrder> runOrders = getRunOrders(); |
1331 | 0 | return runOrders.contains( RunOrder.BALANCED ) || runOrders.contains( RunOrder.FAILEDFIRST ); |
1332 | |
} |
1333 | |
|
1334 | |
private boolean getEffectiveFailIfNoTests() |
1335 | |
{ |
1336 | 0 | if ( isSpecificTestSpecified() ) |
1337 | |
{ |
1338 | 0 | if ( getFailIfNoSpecifiedTests() != null ) |
1339 | |
{ |
1340 | 0 | return getFailIfNoSpecifiedTests(); |
1341 | |
} |
1342 | 0 | else if ( getFailIfNoTests() != null ) |
1343 | |
{ |
1344 | 0 | return getFailIfNoTests(); |
1345 | |
} |
1346 | |
else |
1347 | |
{ |
1348 | 0 | return true; |
1349 | |
} |
1350 | |
} |
1351 | |
else |
1352 | |
{ |
1353 | 0 | return getFailIfNoTests() != null && getFailIfNoTests(); |
1354 | |
} |
1355 | |
} |
1356 | |
|
1357 | |
private ProviderConfiguration createProviderConfiguration( RunOrderParameters runOrderParameters ) |
1358 | |
throws MojoExecutionException, MojoFailureException |
1359 | |
{ |
1360 | 0 | ReporterConfiguration reporterConfiguration = |
1361 | |
new ReporterConfiguration( getReportsDirectory(), isTrimStackTrace() ); |
1362 | |
|
1363 | |
Artifact testNgArtifact; |
1364 | 0 | testNgArtifact = getTestNgArtifact(); |
1365 | |
|
1366 | 0 | DirectoryScannerParameters directoryScannerParameters = null; |
1367 | 0 | final boolean isTestNg = testNgArtifact != null; |
1368 | 0 | TestArtifactInfo testNg = |
1369 | |
isTestNg ? new TestArtifactInfo( testNgArtifact.getVersion(), testNgArtifact.getClassifier() ) : null; |
1370 | 0 | List<File> testXml = getSuiteXmlFiles() != null ? Arrays.asList( getSuiteXmlFiles() ) : null; |
1371 | 0 | TestRequest testSuiteDefinition = |
1372 | |
new TestRequest( testXml, getTestSourceDirectory(), getTest(), getTestMethod() ); |
1373 | |
final boolean failIfNoTests; |
1374 | |
|
1375 | 0 | if ( isValidSuiteXmlFileConfig() && getTest() == null ) |
1376 | |
{ |
1377 | 0 | failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests(); |
1378 | 0 | if ( !isTestNg ) |
1379 | |
{ |
1380 | 0 | throw new MojoExecutionException( "suiteXmlFiles is configured, but there is no TestNG dependency" ); |
1381 | |
} |
1382 | |
} |
1383 | |
else |
1384 | |
{ |
1385 | 0 | if ( isSpecificTestSpecified() ) |
1386 | |
{ |
1387 | 0 | failIfNoTests = getEffectiveFailIfNoTests(); |
1388 | 0 | setFailIfNoTests( failIfNoTests ); |
1389 | |
} |
1390 | |
else |
1391 | |
{ |
1392 | 0 | failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests(); |
1393 | |
} |
1394 | |
|
1395 | 0 | List<String> includes = getIncludeList(); |
1396 | 0 | List<String> excludes = getExcludeList(); |
1397 | 0 | List<String> specificTests = getSpecificTests(); |
1398 | 0 | directoryScannerParameters = |
1399 | |
new DirectoryScannerParameters( getTestClassesDirectory(), includes, excludes, specificTests, |
1400 | |
failIfNoTests, getRunOrder() ); |
1401 | |
} |
1402 | |
|
1403 | 0 | Properties providerProperties = getProperties(); |
1404 | |
|
1405 | 0 | return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, failIfNoTests, |
1406 | |
reporterConfiguration, testNg, testSuiteDefinition, providerProperties, null, |
1407 | |
false ); |
1408 | |
} |
1409 | |
|
1410 | |
public String getStatisticsFileName( String configurationHash ) |
1411 | |
{ |
1412 | 0 | return getReportsDirectory().getParentFile().getParentFile() + File.separator + ".surefire-" |
1413 | |
+ configurationHash; |
1414 | |
} |
1415 | |
|
1416 | |
|
1417 | |
StartupConfiguration createStartupConfiguration( ProviderInfo provider, |
1418 | |
ClassLoaderConfiguration classLoaderConfiguration ) |
1419 | |
throws MojoExecutionException, MojoFailureException |
1420 | |
{ |
1421 | |
|
1422 | |
try |
1423 | |
{ |
1424 | 0 | provider.addProviderProperties(); |
1425 | |
|
1426 | 0 | String providerName = provider.getProviderName(); |
1427 | 0 | Classpath providerClasspath = ClasspathCache.getCachedClassPath( providerName ); |
1428 | 0 | if ( providerClasspath == null ) |
1429 | |
{ |
1430 | 0 | providerClasspath = provider.getProviderClasspath(); |
1431 | 0 | ClasspathCache.setCachedClasspath( providerName, providerClasspath ); |
1432 | |
|
1433 | |
} |
1434 | 0 | Artifact surefireArtifact = getCommonArtifact(); |
1435 | 0 | Classpath inprocClassPath = providerClasspath.addClassPathElementUrl( surefireArtifact.getFile().getAbsolutePath() ); |
1436 | |
|
1437 | 0 | final Classpath testClasspath = generateTestClasspath(); |
1438 | |
|
1439 | 0 | getLog().debug( testClasspath.getLogMessage( "test" ) ); |
1440 | 0 | getLog().debug( providerClasspath.getLogMessage( "provider" ) ); |
1441 | |
|
1442 | 0 | getLog().debug( testClasspath.getCompactLogMessage( "test(compact)" ) ); |
1443 | 0 | getLog().debug( providerClasspath.getCompactLogMessage( "provider(compact)" ) ); |
1444 | |
|
1445 | 0 | final ClasspathConfiguration classpathConfiguration = |
1446 | |
new ClasspathConfiguration( testClasspath, providerClasspath, inprocClassPath, |
1447 | |
effectiveIsEnableAssertions(), isChildDelegation() ); |
1448 | |
|
1449 | 0 | return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, |
1450 | |
isForking(), false ); |
1451 | |
} |
1452 | 0 | catch ( ArtifactResolutionException e ) |
1453 | |
{ |
1454 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1455 | |
} |
1456 | 0 | catch ( ArtifactNotFoundException e ) |
1457 | |
{ |
1458 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1459 | |
} |
1460 | 0 | catch ( InvalidVersionSpecificationException e ) |
1461 | |
{ |
1462 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1463 | |
} |
1464 | |
|
1465 | |
} |
1466 | |
|
1467 | |
private Artifact getCommonArtifact() |
1468 | |
{ |
1469 | 0 | return getPluginArtifactMap().get( "org.apache.maven.surefire:maven-surefire-common" ); |
1470 | |
} |
1471 | |
|
1472 | |
private StartupReportConfiguration getStartupReportConfiguration( String configChecksum ) |
1473 | |
{ |
1474 | 0 | return new StartupReportConfiguration( isUseFile(), isPrintSummary(), getReportFormat(), |
1475 | |
isRedirectTestOutputToFile(), isDisableXmlReport(), |
1476 | |
getReportsDirectory(), isTrimStackTrace(), getReportNameSuffix(), |
1477 | |
configChecksum, requiresRunHistory() ); |
1478 | |
} |
1479 | |
|
1480 | |
private boolean isSpecificTestSpecified() |
1481 | |
{ |
1482 | 0 | return getTest() != null; |
1483 | |
} |
1484 | |
|
1485 | |
private boolean isValidSuiteXmlFileConfig() |
1486 | |
{ |
1487 | 0 | return getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0; |
1488 | |
} |
1489 | |
|
1490 | |
@Nonnull private List<String> readListFromFile( @Nonnull final File file ) |
1491 | |
{ |
1492 | |
List<String> list; |
1493 | |
|
1494 | 0 | getLog().debug( "Reading list from: " + file ); |
1495 | |
|
1496 | 0 | if ( !file.exists() ) |
1497 | |
{ |
1498 | 0 | throw new RuntimeException( "Failed to load list from file: " + file ); |
1499 | |
} |
1500 | |
|
1501 | |
try |
1502 | |
{ |
1503 | 0 | list = FileUtils.loadFile( file ); |
1504 | |
} |
1505 | 0 | catch ( IOException e ) |
1506 | |
{ |
1507 | 0 | throw new RuntimeException( "Failed to load list from file: " + file, e ); |
1508 | 0 | } |
1509 | |
|
1510 | 0 | if ( getLog().isDebugEnabled() ) |
1511 | |
{ |
1512 | 0 | getLog().debug( "List contents:" ); |
1513 | 0 | for ( String entry : list ) |
1514 | |
{ |
1515 | 0 | getLog().debug( " " + entry ); |
1516 | 0 | } |
1517 | |
} |
1518 | 0 | return list; |
1519 | |
} |
1520 | |
|
1521 | |
private void maybeAppendList( final List<String> base, final List<String> list ) |
1522 | |
{ |
1523 | 0 | if ( list != null ) |
1524 | |
{ |
1525 | 0 | base.addAll( list ); |
1526 | |
} |
1527 | 0 | } |
1528 | |
|
1529 | |
private @Nonnull List<String> getExcludeList() |
1530 | |
{ |
1531 | 0 | List<String> excludes = null; |
1532 | 0 | if ( isSpecificTestSpecified() ) |
1533 | |
{ |
1534 | |
|
1535 | |
|
1536 | |
|
1537 | |
|
1538 | 0 | excludes = new ArrayList<String>(); |
1539 | |
} |
1540 | |
else |
1541 | |
{ |
1542 | 0 | if ( getExcludesFile() != null ) |
1543 | |
{ |
1544 | 0 | excludes = readListFromFile( getExcludesFile() ); |
1545 | |
} |
1546 | |
|
1547 | |
|
1548 | 0 | if ( excludes == null ) |
1549 | |
{ |
1550 | 0 | excludes = this.getExcludes(); |
1551 | |
} |
1552 | |
else |
1553 | |
{ |
1554 | 0 | maybeAppendList( excludes, this.getExcludes() ); |
1555 | |
} |
1556 | |
|
1557 | |
|
1558 | |
|
1559 | 0 | if ( excludes == null || excludes.size() == 0 ) |
1560 | |
{ |
1561 | 0 | excludes = Arrays.asList( "**/*$*" ); |
1562 | |
} |
1563 | |
} |
1564 | 0 | return filterNulls( excludes ); |
1565 | |
} |
1566 | |
|
1567 | |
private List<String> getIncludeList() |
1568 | |
{ |
1569 | 0 | List<String> includes = null; |
1570 | 0 | if ( isSpecificTestSpecified() && !isMultipleExecutionBlocksDetected() ) |
1571 | |
{ |
1572 | 0 | includes = getSpecificTests(); |
1573 | |
} |
1574 | |
else |
1575 | |
{ |
1576 | 0 | if ( getIncludesFile() != null ) |
1577 | |
{ |
1578 | 0 | includes = readListFromFile( getIncludesFile() ); |
1579 | |
} |
1580 | |
|
1581 | |
|
1582 | 0 | if ( includes == null ) |
1583 | |
{ |
1584 | 0 | includes = this.getIncludes(); |
1585 | |
} |
1586 | |
else |
1587 | |
{ |
1588 | 0 | maybeAppendList( includes, this.getIncludes() ); |
1589 | |
} |
1590 | |
} |
1591 | |
|
1592 | |
|
1593 | |
|
1594 | 0 | if ( includes == null || includes.size() == 0 ) |
1595 | |
{ |
1596 | 0 | includes = Arrays.asList( getDefaultIncludes() ); |
1597 | |
} |
1598 | |
|
1599 | 0 | return filterNulls( includes ); |
1600 | |
} |
1601 | |
|
1602 | |
private @Nonnull List<String> filterNulls( @Nonnull List<String> toFilter ) |
1603 | |
{ |
1604 | 0 | List<String> result = new ArrayList<String>( toFilter.size() ); |
1605 | 0 | for ( String item : toFilter ) |
1606 | |
{ |
1607 | 0 | if ( item != null ) |
1608 | |
{ |
1609 | 0 | result.add( item ); |
1610 | |
} |
1611 | 0 | } |
1612 | |
|
1613 | 0 | return result; |
1614 | |
} |
1615 | |
|
1616 | |
private boolean isMultipleExecutionBlocksDetected() |
1617 | |
{ |
1618 | 0 | MavenProject project = getProject(); |
1619 | 0 | if ( project != null ) |
1620 | |
{ |
1621 | 0 | String key = getPluginDescriptor().getPluginLookupKey(); |
1622 | 0 | Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key ); |
1623 | |
|
1624 | 0 | if ( plugin != null ) |
1625 | |
{ |
1626 | 0 | @SuppressWarnings( "rawtypes" ) List executions = plugin.getExecutions(); |
1627 | 0 | return executions != null && executions.size() > 1; |
1628 | |
} |
1629 | |
} |
1630 | |
|
1631 | 0 | return false; |
1632 | |
} |
1633 | |
|
1634 | |
private List<String> getSpecificTests() |
1635 | |
{ |
1636 | 0 | if ( !isSpecificTestSpecified() ) |
1637 | |
{ |
1638 | 0 | return Collections.emptyList(); |
1639 | |
} |
1640 | |
|
1641 | 0 | List<String> specificTests = new ArrayList<String>(); |
1642 | 0 | String[] testRegexes = StringUtils.split( getTest(), "," ); |
1643 | |
|
1644 | 0 | for ( String testRegexe : testRegexes ) |
1645 | |
{ |
1646 | 0 | String testRegex = testRegexe; |
1647 | 0 | if ( testRegex.endsWith( ".java" ) ) |
1648 | |
{ |
1649 | 0 | testRegex = testRegex.substring( 0, testRegex.length() - 5 ); |
1650 | |
} |
1651 | |
|
1652 | 0 | testRegex = testRegex.replace( '.', '/' ); |
1653 | 0 | specificTests.add( "**/" + testRegex + ".java" ); |
1654 | |
} |
1655 | |
|
1656 | 0 | return specificTests; |
1657 | |
} |
1658 | |
|
1659 | |
private Artifact getTestNgArtifact() |
1660 | |
throws MojoExecutionException |
1661 | |
{ |
1662 | 0 | Artifact artifact = getProjectArtifactMap().get( getTestNGArtifactName() ); |
1663 | |
|
1664 | 0 | if ( artifact != null ) |
1665 | |
{ |
1666 | 0 | VersionRange range = createVersionRange(); |
1667 | 0 | if ( !range.containsVersion( new DefaultArtifactVersion( artifact.getVersion() ) ) ) |
1668 | |
{ |
1669 | 0 | throw new MojoExecutionException( |
1670 | |
"TestNG support requires version 4.7 or above. You have declared version " |
1671 | |
+ artifact.getVersion() ); |
1672 | |
} |
1673 | |
} |
1674 | 0 | return artifact; |
1675 | |
|
1676 | |
} |
1677 | |
|
1678 | |
private VersionRange createVersionRange() |
1679 | |
{ |
1680 | |
try |
1681 | |
{ |
1682 | 0 | return VersionRange.createFromVersionSpec( "[4.7,)" ); |
1683 | |
} |
1684 | 0 | catch ( InvalidVersionSpecificationException e ) |
1685 | |
{ |
1686 | 0 | throw new RuntimeException( e ); |
1687 | |
} |
1688 | |
} |
1689 | |
|
1690 | |
private Artifact getJunitArtifact() |
1691 | |
{ |
1692 | 0 | return getProjectArtifactMap().get( getJunitArtifactName() ); |
1693 | |
} |
1694 | |
|
1695 | |
private Artifact getJunitDepArtifact() |
1696 | |
{ |
1697 | 0 | return getProjectArtifactMap().get( "junit:junit-dep" ); |
1698 | |
} |
1699 | |
|
1700 | |
protected ForkStarter createForkStarter( ProviderInfo provider, ForkConfiguration forkConfiguration, |
1701 | |
ClassLoaderConfiguration classLoaderConfiguration, |
1702 | |
RunOrderParameters runOrderParameters, Log log ) |
1703 | |
throws MojoExecutionException, MojoFailureException |
1704 | |
{ |
1705 | 0 | StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration ); |
1706 | 0 | String configChecksum = getConfigChecksum(); |
1707 | 0 | StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum ); |
1708 | 0 | ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters ); |
1709 | 0 | return new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration, |
1710 | |
getForkedProcessTimeoutInSeconds(), startupReportConfiguration, log ); |
1711 | |
} |
1712 | |
|
1713 | |
protected InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider, |
1714 | |
ClassLoaderConfiguration classLoaderConfiguration, |
1715 | |
RunOrderParameters runOrderParameters ) |
1716 | |
throws MojoExecutionException, MojoFailureException |
1717 | |
{ |
1718 | 0 | StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration ); |
1719 | 0 | String configChecksum = getConfigChecksum(); |
1720 | 0 | StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum ); |
1721 | 0 | ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters ); |
1722 | 0 | return new InPluginVMSurefireStarter( startupConfiguration, providerConfiguration, startupReportConfiguration ); |
1723 | |
|
1724 | |
} |
1725 | |
|
1726 | |
protected ForkConfiguration getForkConfiguration() |
1727 | |
{ |
1728 | 0 | File tmpDir = getSurefireTempDir(); |
1729 | |
|
1730 | 0 | tmpDir.mkdirs(); |
1731 | |
|
1732 | 0 | Artifact shadeFire = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-shadefire" ); |
1733 | |
|
1734 | 0 | final Classpath bootClasspathConfiguration = |
1735 | |
getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact ); |
1736 | |
|
1737 | 0 | return new ForkConfiguration( bootClasspathConfiguration, tmpDir, getEffectiveDebugForkedProcess(), |
1738 | |
getEffectiveJvm(), |
1739 | |
getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(), |
1740 | |
getArgLine(), getEnvironmentVariables(), getLog().isDebugEnabled(), |
1741 | |
getEffectiveForkCount(), reuseForks ); |
1742 | |
} |
1743 | |
|
1744 | |
private void convertDeprecatedForkMode() |
1745 | |
{ |
1746 | 0 | String effectiveForkMode = getEffectiveForkMode(); |
1747 | |
|
1748 | 0 | if ( ForkConfiguration.FORK_PERTHREAD.equals( effectiveForkMode ) ) |
1749 | |
{ |
1750 | 0 | forkCount = String.valueOf( threadCount ); |
1751 | |
} |
1752 | 0 | else if ( ForkConfiguration.FORK_NEVER.equals( effectiveForkMode ) ) |
1753 | |
{ |
1754 | 0 | forkCount = "0"; |
1755 | |
} |
1756 | 0 | else if ( ForkConfiguration.FORK_ALWAYS.equals( effectiveForkMode ) ) |
1757 | |
{ |
1758 | 0 | forkCount = "1"; |
1759 | 0 | reuseForks = false; |
1760 | |
} |
1761 | |
|
1762 | 0 | if ( !ForkConfiguration.FORK_ONCE.equals( getForkMode() ) ) |
1763 | |
{ |
1764 | 0 | getLog().warn( |
1765 | |
"The parameter forkMode is deprecated since version 2.14. Use forkCount and reuseForks instead." ); |
1766 | |
} |
1767 | 0 | } |
1768 | |
|
1769 | |
protected int getEffectiveForkCount() |
1770 | |
{ |
1771 | 0 | if ( effectiveForkCount < 0 ) |
1772 | |
{ |
1773 | |
try |
1774 | |
{ |
1775 | 0 | effectiveForkCount = convertWithCoreCount( forkCount ); |
1776 | |
} |
1777 | 0 | catch ( NumberFormatException ignored ) |
1778 | |
{ |
1779 | 0 | } |
1780 | |
|
1781 | 0 | if ( effectiveForkCount < 0 ) |
1782 | |
{ |
1783 | 0 | throw new IllegalArgumentException( "Fork count " + forkCount.trim() + " is not a legal value." ); |
1784 | |
} |
1785 | |
} |
1786 | |
|
1787 | 0 | return effectiveForkCount; |
1788 | |
} |
1789 | |
|
1790 | |
protected int convertWithCoreCount( String count ) |
1791 | |
{ |
1792 | 0 | String trimmed = count.trim(); |
1793 | 0 | if ( trimmed.endsWith( "C" ) ) |
1794 | |
{ |
1795 | 0 | double multiplier = Double.parseDouble( trimmed.substring( 0, trimmed.length() - 1 ) ); |
1796 | 0 | return (int) ( multiplier * ( (double) Runtime.getRuntime().availableProcessors() ) ); |
1797 | |
} |
1798 | |
else |
1799 | |
{ |
1800 | 0 | return Integer.parseInt( trimmed ); |
1801 | |
} |
1802 | |
} |
1803 | |
|
1804 | |
private String getEffectiveDebugForkedProcess() |
1805 | |
{ |
1806 | 0 | String debugForkedProcess = getDebugForkedProcess(); |
1807 | 0 | if ( "true".equals( debugForkedProcess ) ) |
1808 | |
{ |
1809 | 0 | return "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"; |
1810 | |
} |
1811 | 0 | return debugForkedProcess; |
1812 | |
} |
1813 | |
|
1814 | |
private String getEffectiveJvm() |
1815 | |
{ |
1816 | 0 | String jvmToUse = getJvm(); |
1817 | 0 | if ( toolchain != null && jvmToUse == null ) |
1818 | |
{ |
1819 | 0 | jvmToUse = toolchain.findTool( "java" ); |
1820 | |
} |
1821 | |
|
1822 | 0 | if ( StringUtils.isEmpty( jvmToUse ) ) |
1823 | |
{ |
1824 | |
|
1825 | 0 | jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; |
1826 | 0 | getLog().debug( "Using JVM: " + jvmToUse ); |
1827 | |
} |
1828 | |
|
1829 | 0 | return jvmToUse; |
1830 | |
} |
1831 | |
|
1832 | |
|
1833 | |
private Artifact getSurefireBooterArtifact() |
1834 | |
{ |
1835 | 0 | Artifact artifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
1836 | 0 | if ( artifact == null ) |
1837 | |
{ |
1838 | 0 | throw new RuntimeException( "Unable to locate surefire-booter in the list of plugin artifacts" ); |
1839 | |
} |
1840 | 0 | artifact.isSnapshot(); |
1841 | 0 | return artifact; |
1842 | |
} |
1843 | |
|
1844 | |
|
1845 | |
|
1846 | |
|
1847 | |
|
1848 | |
|
1849 | |
|
1850 | |
private File getSurefireTempDir() |
1851 | |
{ |
1852 | 0 | return new File( getReportsDirectory().getParentFile(), "surefire" ); |
1853 | |
} |
1854 | |
|
1855 | |
|
1856 | |
|
1857 | |
|
1858 | |
|
1859 | |
|
1860 | |
private String getConfigChecksum() |
1861 | |
{ |
1862 | 0 | ChecksumCalculator checksum = new ChecksumCalculator(); |
1863 | 0 | checksum.add( getPluginName() ); |
1864 | 0 | checksum.add( isSkipTests() ); |
1865 | 0 | checksum.add( isSkipExec() ); |
1866 | 0 | checksum.add( isSkip() ); |
1867 | 0 | checksum.add( getTestClassesDirectory() ); |
1868 | 0 | checksum.add( getClassesDirectory() ); |
1869 | 0 | checksum.add( getClasspathDependencyExcludes() ); |
1870 | 0 | checksum.add( getClasspathDependencyScopeExclude() ); |
1871 | 0 | checksum.add( getAdditionalClasspathElements() ); |
1872 | 0 | checksum.add( getReportsDirectory() ); |
1873 | 0 | checksum.add( getTestSourceDirectory() ); |
1874 | 0 | checksum.add( getTest() ); |
1875 | 0 | checksum.add( getIncludes() ); |
1876 | 0 | checksum.add( getExcludes() ); |
1877 | 0 | checksum.add( getLocalRepository() ); |
1878 | 0 | checksum.add( getSystemProperties() ); |
1879 | 0 | checksum.add( getSystemPropertyVariables() ); |
1880 | 0 | checksum.add( getSystemPropertiesFile() ); |
1881 | 0 | checksum.add( getProperties() ); |
1882 | 0 | checksum.add( isPrintSummary() ); |
1883 | 0 | checksum.add( getReportFormat() ); |
1884 | 0 | checksum.add( getReportNameSuffix() ); |
1885 | 0 | checksum.add( isUseFile() ); |
1886 | 0 | checksum.add( isRedirectTestOutputToFile() ); |
1887 | 0 | checksum.add( getForkMode() ); |
1888 | 0 | checksum.add( getForkCount() ); |
1889 | 0 | checksum.add( isReuseForks() ); |
1890 | 0 | checksum.add( getJvm() ); |
1891 | 0 | checksum.add( getArgLine() ); |
1892 | 0 | checksum.add( getDebugForkedProcess() ); |
1893 | 0 | checksum.add( getForkedProcessTimeoutInSeconds() ); |
1894 | 0 | checksum.add( getParallelTestsTimeoutInSeconds() ); |
1895 | 0 | checksum.add( getParallelTestsTimeoutForcedInSeconds() ); |
1896 | 0 | checksum.add( getEnvironmentVariables() ); |
1897 | 0 | checksum.add( getWorkingDirectory() ); |
1898 | 0 | checksum.add( isChildDelegation() ); |
1899 | 0 | checksum.add( getGroups() ); |
1900 | 0 | checksum.add( getExcludedGroups() ); |
1901 | 0 | checksum.add( getSuiteXmlFiles() ); |
1902 | 0 | checksum.add( getJunitArtifact() ); |
1903 | 0 | checksum.add( getTestNGArtifactName() ); |
1904 | 0 | checksum.add( getThreadCount() ); |
1905 | 0 | checksum.add( getThreadCountSuites() ); |
1906 | 0 | checksum.add( getThreadCountClasses() ); |
1907 | 0 | checksum.add( getThreadCountMethods() ); |
1908 | 0 | checksum.add( getPerCoreThreadCount() ); |
1909 | 0 | checksum.add( getUseUnlimitedThreads() ); |
1910 | 0 | checksum.add( getParallel() ); |
1911 | 0 | checksum.add( isTrimStackTrace() ); |
1912 | 0 | checksum.add( getRemoteRepositories() ); |
1913 | 0 | checksum.add( isDisableXmlReport() ); |
1914 | 0 | checksum.add( isUseSystemClassLoader() ); |
1915 | 0 | checksum.add( isUseManifestOnlyJar() ); |
1916 | 0 | checksum.add( isEnableAssertions() ); |
1917 | 0 | checksum.add( getObjectFactory() ); |
1918 | 0 | checksum.add( getFailIfNoTests() ); |
1919 | 0 | checksum.add( getRunOrder() ); |
1920 | 0 | checksum.add( getDependenciesToScan() ); |
1921 | 0 | addPluginSpecificChecksumItems( checksum ); |
1922 | 0 | return checksum.getSha1(); |
1923 | |
|
1924 | |
} |
1925 | |
|
1926 | |
protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum ) |
1927 | |
{ |
1928 | |
|
1929 | 0 | } |
1930 | |
|
1931 | |
protected boolean hasExecutedBefore() |
1932 | |
{ |
1933 | |
|
1934 | 0 | String configChecksum = getConfigChecksum(); |
1935 | 0 | @SuppressWarnings( "unchecked" ) Map<String, String> pluginContext = getPluginContext(); |
1936 | 0 | if ( pluginContext.containsKey( configChecksum ) ) |
1937 | |
{ |
1938 | 0 | getLog().info( "Skipping execution of surefire because it has already been run for this configuration" ); |
1939 | 0 | return true; |
1940 | |
} |
1941 | 0 | pluginContext.put( configChecksum, configChecksum ); |
1942 | |
|
1943 | 0 | return false; |
1944 | |
} |
1945 | |
|
1946 | |
protected ClassLoaderConfiguration getClassLoaderConfiguration( boolean isForking ) |
1947 | |
{ |
1948 | 0 | return isForking |
1949 | |
? new ClassLoaderConfiguration( isUseSystemClassLoader(), isUseManifestOnlyJar() ) |
1950 | |
: new ClassLoaderConfiguration( false, false ); |
1951 | |
} |
1952 | |
|
1953 | |
protected abstract String[] getDefaultIncludes(); |
1954 | |
|
1955 | |
|
1956 | |
|
1957 | |
|
1958 | |
|
1959 | |
|
1960 | |
|
1961 | |
|
1962 | |
|
1963 | |
|
1964 | |
|
1965 | |
Classpath generateTestClasspath() |
1966 | |
throws InvalidVersionSpecificationException, MojoFailureException, ArtifactResolutionException, |
1967 | |
ArtifactNotFoundException, MojoExecutionException |
1968 | |
{ |
1969 | 0 | List<String> classpath = new ArrayList<String>( 2 + getProject().getArtifacts().size() ); |
1970 | |
|
1971 | 0 | classpath.add( getTestClassesDirectory().getAbsolutePath() ); |
1972 | |
|
1973 | 0 | classpath.add( getClassesDirectory().getAbsolutePath() ); |
1974 | |
|
1975 | 0 | @SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts = getProject().getArtifacts(); |
1976 | |
|
1977 | 0 | if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().equals( "" ) ) |
1978 | |
{ |
1979 | 0 | ArtifactFilter dependencyFilter = new ScopeArtifactFilter( getClasspathDependencyScopeExclude() ); |
1980 | 0 | classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter ); |
1981 | |
} |
1982 | |
|
1983 | 0 | if ( getClasspathDependencyExcludes() != null ) |
1984 | |
{ |
1985 | 0 | ArtifactFilter dependencyFilter = new PatternIncludesArtifactFilter( Arrays.asList( getClasspathDependencyExcludes() ) ); |
1986 | 0 | classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter ); |
1987 | |
} |
1988 | |
|
1989 | 0 | for ( Artifact artifact : classpathArtifacts ) |
1990 | |
{ |
1991 | 0 | if ( artifact.getArtifactHandler().isAddedToClasspath() ) |
1992 | |
{ |
1993 | 0 | File file = artifact.getFile(); |
1994 | 0 | if ( file != null ) |
1995 | |
{ |
1996 | 0 | classpath.add( file.getPath() ); |
1997 | |
} |
1998 | |
} |
1999 | 0 | } |
2000 | |
|
2001 | |
|
2002 | 0 | if ( getAdditionalClasspathElements() != null ) |
2003 | |
{ |
2004 | 0 | for ( String classpathElement : getAdditionalClasspathElements() ) |
2005 | |
{ |
2006 | 0 | if ( classpathElement != null ) |
2007 | |
{ |
2008 | 0 | classpath.add( classpathElement ); |
2009 | |
} |
2010 | |
} |
2011 | |
} |
2012 | |
|
2013 | |
|
2014 | |
|
2015 | 0 | if ( getTestNgArtifact() != null ) |
2016 | |
{ |
2017 | 0 | addTestNgUtilsArtifacts( classpath ); |
2018 | |
} |
2019 | |
|
2020 | 0 | return new Classpath( classpath ); |
2021 | |
} |
2022 | |
|
2023 | |
void addTestNgUtilsArtifacts( List<String> classpath ) |
2024 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2025 | |
{ |
2026 | 0 | Artifact surefireArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
2027 | 0 | String surefireVersion = surefireArtifact.getBaseVersion(); |
2028 | |
|
2029 | 0 | Artifact[] extraTestNgArtifacts = |
2030 | |
{ getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-testng-utils", |
2031 | |
surefireVersion, "runtime", "jar" ), |
2032 | |
getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-grouper", surefireVersion, |
2033 | |
"runtime", "jar" ) }; |
2034 | |
|
2035 | 0 | for ( Artifact artifact : extraTestNgArtifacts ) |
2036 | |
{ |
2037 | 0 | getArtifactResolver().resolve( artifact, getRemoteRepositories(), getLocalRepository() ); |
2038 | |
|
2039 | 0 | String path = artifact.getFile().getPath(); |
2040 | 0 | classpath.add( path ); |
2041 | |
} |
2042 | 0 | } |
2043 | |
|
2044 | |
|
2045 | |
|
2046 | |
|
2047 | |
|
2048 | |
|
2049 | |
|
2050 | |
|
2051 | |
private Set<Artifact> filterArtifacts( Set<Artifact> artifacts, ArtifactFilter filter ) |
2052 | |
{ |
2053 | 0 | Set<Artifact> filteredArtifacts = new LinkedHashSet<Artifact>(); |
2054 | |
|
2055 | 0 | for ( Artifact artifact : artifacts ) |
2056 | |
{ |
2057 | 0 | if ( !filter.include( artifact ) ) |
2058 | |
{ |
2059 | 0 | filteredArtifacts.add( artifact ); |
2060 | |
} |
2061 | 0 | } |
2062 | |
|
2063 | 0 | return filteredArtifacts; |
2064 | |
} |
2065 | |
|
2066 | |
private void showMap( Map<?, ?> map, String setting ) |
2067 | |
{ |
2068 | 0 | for ( Object o : map.keySet() ) |
2069 | |
{ |
2070 | 0 | String key = (String) o; |
2071 | 0 | String value = (String) map.get( key ); |
2072 | 0 | getLog().debug( "Setting " + setting + " [" + key + "]=[" + value + "]" ); |
2073 | 0 | } |
2074 | 0 | } |
2075 | |
|
2076 | |
|
2077 | |
private ArtifactResolutionResult resolveArtifact( Artifact filteredArtifact, Artifact providerArtifact ) |
2078 | |
{ |
2079 | 0 | ArtifactFilter filter = null; |
2080 | 0 | if ( filteredArtifact != null ) |
2081 | |
{ |
2082 | 0 | filter = new ExcludesArtifactFilter( |
2083 | |
Collections.singletonList( filteredArtifact.getGroupId() + ":" + filteredArtifact.getArtifactId() ) ); |
2084 | |
} |
2085 | |
|
2086 | 0 | Artifact originatingArtifact = getArtifactFactory().createBuildArtifact( "dummy", "dummy", "1.0", "jar" ); |
2087 | |
|
2088 | |
try |
2089 | |
{ |
2090 | 0 | return getArtifactResolver().resolveTransitively( Collections.singleton( providerArtifact ), |
2091 | |
originatingArtifact, getLocalRepository(), |
2092 | |
getRemoteRepositories(), getMetadataSource(), filter ); |
2093 | |
} |
2094 | 0 | catch ( ArtifactResolutionException e ) |
2095 | |
{ |
2096 | 0 | throw new NestedRuntimeException( e ); |
2097 | |
} |
2098 | 0 | catch ( ArtifactNotFoundException e ) |
2099 | |
{ |
2100 | 0 | throw new NestedRuntimeException( e ); |
2101 | |
} |
2102 | |
} |
2103 | |
|
2104 | |
private Classpath getArtifactClasspath( Artifact surefireArtifact ) |
2105 | |
{ |
2106 | 0 | Classpath existing = ClasspathCache.getCachedClassPath( surefireArtifact.getArtifactId() ); |
2107 | 0 | if ( existing == null ) |
2108 | |
{ |
2109 | 0 | ArtifactResolutionResult result = resolveArtifact( null, surefireArtifact ); |
2110 | |
|
2111 | 0 | List<String> items = new ArrayList<String>(); |
2112 | 0 | for ( Object o : result.getArtifacts() ) |
2113 | |
{ |
2114 | 0 | Artifact artifact = (Artifact) o; |
2115 | |
|
2116 | 0 | getLog().debug( |
2117 | |
"Adding to " + getPluginName() + " booter test classpath: " + artifact.getFile().getAbsolutePath() + |
2118 | |
" Scope: " + artifact.getScope() ); |
2119 | |
|
2120 | 0 | items.add( artifact.getFile().getAbsolutePath() ); |
2121 | 0 | } |
2122 | 0 | existing = new Classpath( items ); |
2123 | 0 | ClasspathCache.setCachedClasspath( surefireArtifact.getArtifactId(), existing ); |
2124 | |
} |
2125 | 0 | return existing; |
2126 | |
} |
2127 | |
|
2128 | |
private Properties getUserProperties() |
2129 | |
{ |
2130 | 0 | Properties props = null; |
2131 | |
try |
2132 | |
{ |
2133 | |
|
2134 | 0 | Method getUserProperties = getSession().getClass().getMethod( "getUserProperties" ); |
2135 | 0 | props = (Properties) getUserProperties.invoke( getSession() ); |
2136 | |
} |
2137 | 0 | catch ( Exception e ) |
2138 | |
{ |
2139 | 0 | String msg = "Build uses Maven 2.0.x, cannot propagate system properties" |
2140 | |
+ " from command line to tests (cf. SUREFIRE-121)"; |
2141 | 0 | if ( getLog().isDebugEnabled() ) |
2142 | |
{ |
2143 | 0 | getLog().warn( msg, e ); |
2144 | |
} |
2145 | |
else |
2146 | |
{ |
2147 | 0 | getLog().warn( msg ); |
2148 | |
} |
2149 | 0 | } |
2150 | 0 | if ( props == null ) |
2151 | |
{ |
2152 | 0 | props = new Properties(); |
2153 | |
} |
2154 | 0 | return props; |
2155 | |
} |
2156 | |
|
2157 | |
|
2158 | |
void ensureWorkingDirectoryExists() |
2159 | |
throws MojoFailureException |
2160 | |
{ |
2161 | 0 | if ( getWorkingDirectory() == null ) |
2162 | |
{ |
2163 | 0 | throw new MojoFailureException( "workingDirectory cannot be null" ); |
2164 | |
} |
2165 | |
|
2166 | 0 | if ( !getWorkingDirectory().exists() ) |
2167 | |
{ |
2168 | 0 | if ( !getWorkingDirectory().mkdirs() ) |
2169 | |
{ |
2170 | 0 | throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() ); |
2171 | |
} |
2172 | |
} |
2173 | |
|
2174 | 0 | if ( !getWorkingDirectory().isDirectory() ) |
2175 | |
{ |
2176 | 0 | throw new MojoFailureException( |
2177 | |
"workingDirectory " + getWorkingDirectory() + " exists and is not a directory" ); |
2178 | |
} |
2179 | 0 | } |
2180 | |
|
2181 | |
void ensureParallelRunningCompatibility() |
2182 | |
throws MojoFailureException |
2183 | |
{ |
2184 | 0 | if ( isMavenParallel() && isNotForking() ) |
2185 | |
{ |
2186 | 0 | throw new MojoFailureException( "parallel maven execution is not compatible with surefire forkCount 0" ); |
2187 | |
} |
2188 | 0 | } |
2189 | |
|
2190 | |
void ensureThreadCountWithPerThread() |
2191 | |
throws MojoFailureException |
2192 | |
{ |
2193 | 0 | if ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) && getThreadCount() < 1 ) |
2194 | |
{ |
2195 | 0 | throw new MojoFailureException( "Fork mode perthread requires a thread count" ); |
2196 | |
} |
2197 | 0 | } |
2198 | |
|
2199 | |
void warnIfUselessUseSystemClassLoaderParameter() |
2200 | |
{ |
2201 | 0 | if ( isUseSystemClassLoader() && isNotForking() ) |
2202 | |
{ |
2203 | 0 | getLog().warn( "useSystemClassloader setting has no effect when not forking" ); |
2204 | |
} |
2205 | 0 | } |
2206 | |
|
2207 | |
private boolean isNotForking() |
2208 | |
{ |
2209 | 0 | return !isForking(); |
2210 | |
} |
2211 | |
|
2212 | |
void warnIfDefunctGroupsCombinations() |
2213 | |
throws MojoFailureException, MojoExecutionException |
2214 | |
{ |
2215 | 0 | if ( isAnyGroupsSelected() ) |
2216 | |
{ |
2217 | 0 | if ( getTestNgArtifact() != null ) |
2218 | |
{ |
2219 | 0 | return; |
2220 | |
} |
2221 | 0 | Artifact junitArtifact = getJunitArtifact(); |
2222 | 0 | boolean junit47Compatible = isJunit47Compatible( junitArtifact ); |
2223 | 0 | if ( junit47Compatible ) |
2224 | |
{ |
2225 | 0 | return; |
2226 | |
} |
2227 | 0 | if ( junitArtifact != null && !junit47Compatible ) |
2228 | |
{ |
2229 | 0 | throw new MojoFailureException( "groups/excludedGroups are specified but JUnit version on classpath" |
2230 | |
+ " is too old to support groups. Check your dependency:tree to see if your project is picking up an old junit version" ); |
2231 | |
} |
2232 | 0 | throw new MojoFailureException( |
2233 | |
"groups/excludedGroups require TestNG or JUnit48+ on project test classpath" ); |
2234 | |
|
2235 | |
} |
2236 | 0 | } |
2237 | |
|
2238 | |
class TestNgProviderInfo |
2239 | |
implements ProviderInfo |
2240 | |
{ |
2241 | |
private final Artifact testNgArtifact; |
2242 | |
|
2243 | |
TestNgProviderInfo( Artifact testNgArtifact ) |
2244 | 0 | { |
2245 | 0 | this.testNgArtifact = testNgArtifact; |
2246 | 0 | } |
2247 | |
|
2248 | |
public @Nonnull String getProviderName() |
2249 | |
{ |
2250 | 0 | return "org.apache.maven.surefire.testng.TestNGProvider"; |
2251 | |
} |
2252 | |
|
2253 | |
public boolean isApplicable() |
2254 | |
{ |
2255 | 0 | return testNgArtifact != null; |
2256 | |
} |
2257 | |
|
2258 | |
public void addProviderProperties() throws MojoExecutionException |
2259 | |
{ |
2260 | 0 | convertTestNGParameters(); |
2261 | 0 | } |
2262 | |
|
2263 | |
public Classpath getProviderClasspath() |
2264 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2265 | |
{ |
2266 | 0 | Artifact surefireArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
2267 | 0 | return dependencyResolver.getProviderClasspath( "surefire-testng", surefireArtifact.getBaseVersion(), |
2268 | |
testNgArtifact ); |
2269 | |
} |
2270 | |
} |
2271 | |
|
2272 | 0 | class JUnit3ProviderInfo |
2273 | |
implements ProviderInfo |
2274 | |
{ |
2275 | |
@Nonnull public String getProviderName() |
2276 | |
{ |
2277 | 0 | return "org.apache.maven.surefire.junit.JUnit3Provider"; |
2278 | |
} |
2279 | |
|
2280 | |
public boolean isApplicable() |
2281 | |
{ |
2282 | 0 | return true; |
2283 | |
} |
2284 | |
|
2285 | |
public void addProviderProperties() throws MojoExecutionException |
2286 | |
{ |
2287 | 0 | } |
2288 | |
|
2289 | |
public Classpath getProviderClasspath() |
2290 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2291 | |
{ |
2292 | |
|
2293 | |
|
2294 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit3", surefireBooterArtifact.getBaseVersion(), |
2295 | |
null ); |
2296 | |
|
2297 | |
} |
2298 | |
|
2299 | |
} |
2300 | |
|
2301 | |
class JUnit4ProviderInfo |
2302 | |
implements ProviderInfo |
2303 | |
{ |
2304 | |
private final Artifact junitArtifact; |
2305 | |
|
2306 | |
private final Artifact junitDepArtifact; |
2307 | |
|
2308 | |
JUnit4ProviderInfo( Artifact junitArtifact, Artifact junitDepArtifact ) |
2309 | 0 | { |
2310 | 0 | this.junitArtifact = junitArtifact; |
2311 | 0 | this.junitDepArtifact = junitDepArtifact; |
2312 | 0 | } |
2313 | |
|
2314 | |
@Nonnull public String getProviderName() |
2315 | |
{ |
2316 | 0 | return "org.apache.maven.surefire.junit4.JUnit4Provider"; |
2317 | |
} |
2318 | |
|
2319 | |
public boolean isApplicable() |
2320 | |
{ |
2321 | 0 | return junitDepArtifact != null || isAnyJunit4( junitArtifact ); |
2322 | |
} |
2323 | |
|
2324 | |
public void addProviderProperties() throws MojoExecutionException |
2325 | |
{ |
2326 | 0 | } |
2327 | |
|
2328 | |
public Classpath getProviderClasspath() |
2329 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2330 | |
{ |
2331 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit4", surefireBooterArtifact.getBaseVersion(), |
2332 | |
null ); |
2333 | |
|
2334 | |
} |
2335 | |
|
2336 | |
} |
2337 | |
|
2338 | |
class JUnitCoreProviderInfo |
2339 | |
implements ProviderInfo |
2340 | |
{ |
2341 | |
private final Artifact junitArtifact; |
2342 | |
|
2343 | |
private final Artifact junitDepArtifact; |
2344 | |
|
2345 | |
JUnitCoreProviderInfo( Artifact junitArtifact, Artifact junitDepArtifact ) |
2346 | 0 | { |
2347 | 0 | this.junitArtifact = junitArtifact; |
2348 | 0 | this.junitDepArtifact = junitDepArtifact; |
2349 | 0 | } |
2350 | |
|
2351 | |
@Nonnull public String getProviderName() |
2352 | |
{ |
2353 | 0 | return "org.apache.maven.surefire.junitcore.JUnitCoreProvider"; |
2354 | |
} |
2355 | |
|
2356 | |
private boolean is47CompatibleJunitDep() |
2357 | |
{ |
2358 | 0 | return junitDepArtifact != null && isJunit47Compatible( junitDepArtifact ); |
2359 | |
} |
2360 | |
|
2361 | |
public boolean isApplicable() |
2362 | |
{ |
2363 | 0 | final boolean isJunitArtifact47 = isAnyJunit4( junitArtifact ) && isJunit47Compatible( junitArtifact ); |
2364 | 0 | final boolean isAny47ProvidersForcers = isAnyConcurrencySelected() || isAnyGroupsSelected(); |
2365 | 0 | return isAny47ProvidersForcers && ( isJunitArtifact47 || is47CompatibleJunitDep() ); |
2366 | |
} |
2367 | |
|
2368 | |
public void addProviderProperties() throws MojoExecutionException |
2369 | |
{ |
2370 | 0 | convertJunitCoreParameters(); |
2371 | 0 | convertGroupParameters(); |
2372 | 0 | } |
2373 | |
|
2374 | |
public Classpath getProviderClasspath() |
2375 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2376 | |
{ |
2377 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit47", surefireBooterArtifact.getBaseVersion(), |
2378 | |
null ); |
2379 | |
} |
2380 | |
|
2381 | |
} |
2382 | |
|
2383 | 0 | public class DynamicProviderInfo |
2384 | |
implements ConfigurableProviderInfo |
2385 | |
{ |
2386 | |
final String providerName; |
2387 | |
|
2388 | |
DynamicProviderInfo( String providerName ) |
2389 | 0 | { |
2390 | 0 | this.providerName = providerName; |
2391 | 0 | } |
2392 | |
|
2393 | |
public ProviderInfo instantiate( String providerName ) |
2394 | |
{ |
2395 | 0 | return new DynamicProviderInfo( providerName ); |
2396 | |
} |
2397 | |
|
2398 | |
@Nonnull |
2399 | |
public String getProviderName() |
2400 | |
{ |
2401 | 0 | return providerName; |
2402 | |
} |
2403 | |
|
2404 | |
public boolean isApplicable() |
2405 | |
{ |
2406 | 0 | return true; |
2407 | |
} |
2408 | |
|
2409 | |
public void addProviderProperties() throws MojoExecutionException |
2410 | |
{ |
2411 | |
|
2412 | 0 | convertJunitCoreParameters(); |
2413 | 0 | convertTestNGParameters(); |
2414 | 0 | } |
2415 | |
|
2416 | |
|
2417 | |
public Classpath getProviderClasspath() |
2418 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2419 | |
{ |
2420 | 0 | final Map<String, Artifact> pluginArtifactMap = getPluginArtifactMap(); |
2421 | 0 | Artifact plugin = pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" ); |
2422 | 0 | return dependencyResolver.addProviderToClasspath( pluginArtifactMap, plugin ); |
2423 | |
} |
2424 | |
|
2425 | |
} |
2426 | |
|
2427 | |
|
2428 | |
public abstract List<String> getIncludes(); |
2429 | |
|
2430 | |
public File getIncludesFile() |
2431 | |
{ |
2432 | 0 | return includesFile; |
2433 | |
} |
2434 | |
|
2435 | |
public abstract void setIncludes( List<String> includes ); |
2436 | |
|
2437 | |
public List<String> getExcludes() |
2438 | |
{ |
2439 | 0 | return excludes; |
2440 | |
} |
2441 | |
|
2442 | |
public File getExcludesFile() |
2443 | |
{ |
2444 | 0 | return excludesFile; |
2445 | |
} |
2446 | |
|
2447 | |
public void setExcludes( List<String> excludes ) |
2448 | |
{ |
2449 | 0 | this.excludes = excludes; |
2450 | 0 | } |
2451 | |
|
2452 | |
public ArtifactRepository getLocalRepository() |
2453 | |
{ |
2454 | 0 | return localRepository; |
2455 | |
} |
2456 | |
|
2457 | |
public void setLocalRepository( ArtifactRepository localRepository ) |
2458 | |
{ |
2459 | 0 | this.localRepository = localRepository; |
2460 | 0 | } |
2461 | |
|
2462 | |
|
2463 | |
|
2464 | |
|
2465 | |
public Properties getSystemProperties() |
2466 | |
{ |
2467 | 0 | return systemProperties; |
2468 | |
} |
2469 | |
|
2470 | |
@SuppressWarnings( { "UnusedDeclaration", "deprecation" } ) |
2471 | |
public void setSystemProperties( Properties systemProperties ) |
2472 | |
{ |
2473 | 0 | this.systemProperties = systemProperties; |
2474 | 0 | } |
2475 | |
|
2476 | |
public Map<String, String> getSystemPropertyVariables() |
2477 | |
{ |
2478 | 0 | return systemPropertyVariables; |
2479 | |
} |
2480 | |
|
2481 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2482 | |
public void setSystemPropertyVariables( Map<String, String> systemPropertyVariables ) |
2483 | |
{ |
2484 | 0 | this.systemPropertyVariables = systemPropertyVariables; |
2485 | 0 | } |
2486 | |
|
2487 | |
public File getSystemPropertiesFile() |
2488 | |
{ |
2489 | 0 | return systemPropertiesFile; |
2490 | |
} |
2491 | |
|
2492 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2493 | |
public void setSystemPropertiesFile( File systemPropertiesFile ) |
2494 | |
{ |
2495 | 0 | this.systemPropertiesFile = systemPropertiesFile; |
2496 | 0 | } |
2497 | |
|
2498 | |
public Properties getProperties() |
2499 | |
{ |
2500 | 0 | return properties; |
2501 | |
} |
2502 | |
|
2503 | |
public void setProperties( Properties properties ) |
2504 | |
{ |
2505 | 0 | this.properties = properties; |
2506 | 0 | } |
2507 | |
|
2508 | |
public Map<String, Artifact> getPluginArtifactMap() |
2509 | |
{ |
2510 | 0 | return pluginArtifactMap; |
2511 | |
} |
2512 | |
|
2513 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2514 | |
public void setPluginArtifactMap( Map<String, Artifact> pluginArtifactMap ) |
2515 | |
{ |
2516 | 0 | this.pluginArtifactMap = pluginArtifactMap; |
2517 | 0 | } |
2518 | |
|
2519 | |
public Map<String, Artifact> getProjectArtifactMap() |
2520 | |
{ |
2521 | 0 | return projectArtifactMap; |
2522 | |
} |
2523 | |
|
2524 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2525 | |
public void setProjectArtifactMap( Map<String, Artifact> projectArtifactMap ) |
2526 | |
{ |
2527 | 0 | this.projectArtifactMap = projectArtifactMap; |
2528 | 0 | } |
2529 | |
|
2530 | |
|
2531 | |
public String getReportNameSuffix() |
2532 | |
{ |
2533 | 0 | return reportNameSuffix; |
2534 | |
} |
2535 | |
|
2536 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2537 | |
public void setReportNameSuffix( String reportNameSuffix ) |
2538 | |
{ |
2539 | 0 | this.reportNameSuffix = reportNameSuffix; |
2540 | 0 | } |
2541 | |
|
2542 | |
|
2543 | |
public boolean isRedirectTestOutputToFile() |
2544 | |
{ |
2545 | 0 | return redirectTestOutputToFile; |
2546 | |
} |
2547 | |
|
2548 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2549 | |
public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile ) |
2550 | |
{ |
2551 | 0 | this.redirectTestOutputToFile = redirectTestOutputToFile; |
2552 | 0 | } |
2553 | |
|
2554 | |
|
2555 | |
public Boolean getFailIfNoTests() |
2556 | |
{ |
2557 | 0 | return failIfNoTests; |
2558 | |
} |
2559 | |
|
2560 | |
public void setFailIfNoTests( Boolean failIfNoTests ) |
2561 | |
{ |
2562 | 0 | this.failIfNoTests = failIfNoTests; |
2563 | 0 | } |
2564 | |
|
2565 | |
public String getForkMode() |
2566 | |
{ |
2567 | 0 | return forkMode; |
2568 | |
} |
2569 | |
|
2570 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2571 | |
public void setForkMode( String forkMode ) |
2572 | |
{ |
2573 | 0 | this.forkMode = forkMode; |
2574 | 0 | } |
2575 | |
|
2576 | |
public String getJvm() |
2577 | |
{ |
2578 | 0 | return jvm; |
2579 | |
} |
2580 | |
|
2581 | |
public String getArgLine() |
2582 | |
{ |
2583 | 0 | return argLine; |
2584 | |
} |
2585 | |
|
2586 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2587 | |
public void setArgLine( String argLine ) |
2588 | |
{ |
2589 | 0 | this.argLine = argLine; |
2590 | 0 | } |
2591 | |
|
2592 | |
|
2593 | |
public Map<String, String> getEnvironmentVariables() |
2594 | |
{ |
2595 | 0 | return environmentVariables; |
2596 | |
} |
2597 | |
|
2598 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2599 | |
public void setEnvironmentVariables( Map<String, String> environmentVariables ) |
2600 | |
{ |
2601 | 0 | this.environmentVariables = environmentVariables; |
2602 | 0 | } |
2603 | |
|
2604 | |
public File getWorkingDirectory() |
2605 | |
{ |
2606 | 0 | return workingDirectory; |
2607 | |
} |
2608 | |
|
2609 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2610 | |
public void setWorkingDirectory( File workingDirectory ) |
2611 | |
{ |
2612 | 0 | this.workingDirectory = workingDirectory; |
2613 | 0 | } |
2614 | |
|
2615 | |
public boolean isChildDelegation() |
2616 | |
{ |
2617 | 0 | return childDelegation; |
2618 | |
} |
2619 | |
|
2620 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2621 | |
public void setChildDelegation( boolean childDelegation ) |
2622 | |
{ |
2623 | 0 | this.childDelegation = childDelegation; |
2624 | 0 | } |
2625 | |
|
2626 | |
public String getGroups() |
2627 | |
{ |
2628 | 0 | return groups; |
2629 | |
} |
2630 | |
|
2631 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2632 | |
public void setGroups( String groups ) |
2633 | |
{ |
2634 | 0 | this.groups = groups; |
2635 | 0 | } |
2636 | |
|
2637 | |
public String getExcludedGroups() |
2638 | |
{ |
2639 | 0 | return excludedGroups; |
2640 | |
} |
2641 | |
|
2642 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2643 | |
public void setExcludedGroups( String excludedGroups ) |
2644 | |
{ |
2645 | 0 | this.excludedGroups = excludedGroups; |
2646 | 0 | } |
2647 | |
|
2648 | |
public File[] getSuiteXmlFiles() |
2649 | |
{ |
2650 | 0 | return suiteXmlFiles; |
2651 | |
} |
2652 | |
|
2653 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2654 | |
public void setSuiteXmlFiles( File[] suiteXmlFiles ) |
2655 | |
{ |
2656 | 0 | this.suiteXmlFiles = suiteXmlFiles; |
2657 | 0 | } |
2658 | |
|
2659 | |
public String getJunitArtifactName() |
2660 | |
{ |
2661 | 0 | return junitArtifactName; |
2662 | |
} |
2663 | |
|
2664 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2665 | |
public void setJunitArtifactName( String junitArtifactName ) |
2666 | |
{ |
2667 | 0 | this.junitArtifactName = junitArtifactName; |
2668 | 0 | } |
2669 | |
|
2670 | |
public String getTestNGArtifactName() |
2671 | |
{ |
2672 | 0 | return testNGArtifactName; |
2673 | |
} |
2674 | |
|
2675 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2676 | |
public void setTestNGArtifactName( String testNGArtifactName ) |
2677 | |
{ |
2678 | 0 | this.testNGArtifactName = testNGArtifactName; |
2679 | 0 | } |
2680 | |
|
2681 | |
public int getThreadCount() |
2682 | |
{ |
2683 | 0 | return threadCount; |
2684 | |
} |
2685 | |
|
2686 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2687 | |
public void setThreadCount( int threadCount ) |
2688 | |
{ |
2689 | 0 | this.threadCount = threadCount; |
2690 | 0 | } |
2691 | |
|
2692 | |
public boolean getPerCoreThreadCount() |
2693 | |
{ |
2694 | 0 | return perCoreThreadCount; |
2695 | |
} |
2696 | |
|
2697 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2698 | |
public void setPerCoreThreadCount( boolean perCoreThreadCount ) |
2699 | |
{ |
2700 | 0 | this.perCoreThreadCount = perCoreThreadCount; |
2701 | 0 | } |
2702 | |
|
2703 | |
public boolean getUseUnlimitedThreads() |
2704 | |
{ |
2705 | 0 | return useUnlimitedThreads; |
2706 | |
} |
2707 | |
|
2708 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2709 | |
public void setUseUnlimitedThreads( boolean useUnlimitedThreads ) |
2710 | |
{ |
2711 | 0 | this.useUnlimitedThreads = useUnlimitedThreads; |
2712 | 0 | } |
2713 | |
|
2714 | |
public String getParallel() |
2715 | |
{ |
2716 | 0 | return parallel; |
2717 | |
} |
2718 | |
|
2719 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2720 | |
public void setParallel( String parallel ) |
2721 | |
{ |
2722 | 0 | this.parallel = parallel; |
2723 | 0 | } |
2724 | |
|
2725 | |
public int getThreadCountSuites() |
2726 | |
{ |
2727 | 0 | return threadCountSuites; |
2728 | |
} |
2729 | |
|
2730 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2731 | |
public void setThreadCountSuites( int threadCountSuites ) |
2732 | |
{ |
2733 | 0 | this.threadCountSuites = threadCountSuites; |
2734 | 0 | } |
2735 | |
|
2736 | |
public int getThreadCountClasses() |
2737 | |
{ |
2738 | 0 | return threadCountClasses; |
2739 | |
} |
2740 | |
|
2741 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2742 | |
public void setThreadCountClasses( int threadCountClasses ) |
2743 | |
{ |
2744 | 0 | this.threadCountClasses = threadCountClasses; |
2745 | 0 | } |
2746 | |
|
2747 | |
public int getThreadCountMethods() |
2748 | |
{ |
2749 | 0 | return threadCountMethods; |
2750 | |
} |
2751 | |
|
2752 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2753 | |
public void setThreadCountMethods( int threadCountMethods ) |
2754 | |
{ |
2755 | 0 | this.threadCountMethods = threadCountMethods; |
2756 | 0 | } |
2757 | |
|
2758 | |
public boolean isTrimStackTrace() |
2759 | |
{ |
2760 | 0 | return trimStackTrace; |
2761 | |
} |
2762 | |
|
2763 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2764 | |
public void setTrimStackTrace( boolean trimStackTrace ) |
2765 | |
{ |
2766 | 0 | this.trimStackTrace = trimStackTrace; |
2767 | 0 | } |
2768 | |
|
2769 | |
public ArtifactResolver getArtifactResolver() |
2770 | |
{ |
2771 | 0 | return artifactResolver; |
2772 | |
} |
2773 | |
|
2774 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2775 | |
public void setArtifactResolver( ArtifactResolver artifactResolver ) |
2776 | |
{ |
2777 | 0 | this.artifactResolver = artifactResolver; |
2778 | 0 | } |
2779 | |
|
2780 | |
public ArtifactFactory getArtifactFactory() |
2781 | |
{ |
2782 | 0 | return artifactFactory; |
2783 | |
} |
2784 | |
|
2785 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2786 | |
public void setArtifactFactory( ArtifactFactory artifactFactory ) |
2787 | |
{ |
2788 | 0 | this.artifactFactory = artifactFactory; |
2789 | 0 | } |
2790 | |
|
2791 | |
public List<ArtifactRepository> getRemoteRepositories() |
2792 | |
{ |
2793 | 0 | return remoteRepositories; |
2794 | |
} |
2795 | |
|
2796 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2797 | |
public void setRemoteRepositories( List<ArtifactRepository> remoteRepositories ) |
2798 | |
{ |
2799 | 0 | this.remoteRepositories = remoteRepositories; |
2800 | 0 | } |
2801 | |
|
2802 | |
public ArtifactMetadataSource getMetadataSource() |
2803 | |
{ |
2804 | 0 | return metadataSource; |
2805 | |
} |
2806 | |
|
2807 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2808 | |
public void setMetadataSource( ArtifactMetadataSource metadataSource ) |
2809 | |
{ |
2810 | 0 | this.metadataSource = metadataSource; |
2811 | 0 | } |
2812 | |
|
2813 | |
|
2814 | |
public boolean isDisableXmlReport() |
2815 | |
{ |
2816 | 0 | return disableXmlReport; |
2817 | |
} |
2818 | |
|
2819 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2820 | |
public void setDisableXmlReport( boolean disableXmlReport ) |
2821 | |
{ |
2822 | 0 | this.disableXmlReport = disableXmlReport; |
2823 | 0 | } |
2824 | |
|
2825 | |
|
2826 | |
public boolean isEnableAssertions() |
2827 | |
{ |
2828 | 0 | return enableAssertions; |
2829 | |
} |
2830 | |
|
2831 | |
public boolean effectiveIsEnableAssertions() |
2832 | |
{ |
2833 | 0 | if ( getArgLine() != null ) |
2834 | |
{ |
2835 | 0 | List<String> args = Arrays.asList( getArgLine().split( " " ) ); |
2836 | 0 | if ( args.contains( "-da" ) || args.contains( "-disableassertions" ) ) |
2837 | |
{ |
2838 | 0 | return false; |
2839 | |
} |
2840 | |
} |
2841 | 0 | return isEnableAssertions(); |
2842 | |
} |
2843 | |
|
2844 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2845 | |
public void setEnableAssertions( boolean enableAssertions ) |
2846 | |
{ |
2847 | 0 | this.enableAssertions = enableAssertions; |
2848 | 0 | } |
2849 | |
|
2850 | |
public MavenSession getSession() |
2851 | |
{ |
2852 | 0 | return session; |
2853 | |
} |
2854 | |
|
2855 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2856 | |
public void setSession( MavenSession session ) |
2857 | |
{ |
2858 | 0 | this.session = session; |
2859 | 0 | } |
2860 | |
|
2861 | |
public String getObjectFactory() |
2862 | |
{ |
2863 | 0 | return objectFactory; |
2864 | |
} |
2865 | |
|
2866 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2867 | |
public void setObjectFactory( String objectFactory ) |
2868 | |
{ |
2869 | 0 | this.objectFactory = objectFactory; |
2870 | 0 | } |
2871 | |
|
2872 | |
public ToolchainManager getToolchainManager() |
2873 | |
{ |
2874 | 0 | return toolchainManager; |
2875 | |
} |
2876 | |
|
2877 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2878 | |
public void setToolchainManager( ToolchainManager toolchainManager ) |
2879 | |
{ |
2880 | 0 | this.toolchainManager = toolchainManager; |
2881 | 0 | } |
2882 | |
|
2883 | |
public boolean isMavenParallel() |
2884 | |
{ |
2885 | 0 | return parallelMavenExecution != null && parallelMavenExecution; |
2886 | |
} |
2887 | |
|
2888 | |
public String getRunOrder() |
2889 | |
{ |
2890 | 0 | return runOrder; |
2891 | |
} |
2892 | |
|
2893 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2894 | |
public void setRunOrder( String runOrder ) |
2895 | |
{ |
2896 | 0 | this.runOrder = runOrder; |
2897 | 0 | } |
2898 | |
|
2899 | |
public String[] getDependenciesToScan() |
2900 | |
{ |
2901 | 0 | return dependenciesToScan; |
2902 | |
} |
2903 | |
|
2904 | |
public void setDependenciesToScan( String[] dependenciesToScan ) |
2905 | |
{ |
2906 | 0 | this.dependenciesToScan = dependenciesToScan; |
2907 | 0 | } |
2908 | |
|
2909 | |
public PluginDescriptor getPluginDescriptor() |
2910 | |
{ |
2911 | 0 | return pluginDescriptor; |
2912 | |
} |
2913 | |
|
2914 | |
public MavenProject getProject() |
2915 | |
{ |
2916 | 0 | return project; |
2917 | |
} |
2918 | |
|
2919 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2920 | |
public void setProject( MavenProject project ) |
2921 | |
{ |
2922 | 0 | this.project = project; |
2923 | 0 | } |
2924 | |
|
2925 | |
public File getTestSourceDirectory() |
2926 | |
{ |
2927 | 0 | return testSourceDirectory; |
2928 | |
} |
2929 | |
|
2930 | |
public void setTestSourceDirectory( File testSourceDirectory ) |
2931 | |
{ |
2932 | 0 | this.testSourceDirectory = testSourceDirectory; |
2933 | 0 | } |
2934 | |
|
2935 | |
public String getForkCount() |
2936 | |
{ |
2937 | 0 | return forkCount; |
2938 | |
} |
2939 | |
|
2940 | |
public boolean isReuseForks() |
2941 | |
{ |
2942 | 0 | return reuseForks; |
2943 | |
} |
2944 | |
|
2945 | |
public String[] getAdditionalClasspathElements() |
2946 | |
{ |
2947 | 0 | return additionalClasspathElements; |
2948 | |
} |
2949 | |
|
2950 | |
public void setAdditionalClasspathElements( String[] additionalClasspathElements ) |
2951 | |
{ |
2952 | 0 | this.additionalClasspathElements = additionalClasspathElements; |
2953 | 0 | } |
2954 | |
|
2955 | |
public String[] getClasspathDependencyExcludes() |
2956 | |
{ |
2957 | 0 | return classpathDependencyExcludes; |
2958 | |
} |
2959 | |
|
2960 | |
public void setClasspathDependencyExcludes( String[] classpathDependencyExcludes ) |
2961 | |
{ |
2962 | 0 | this.classpathDependencyExcludes = classpathDependencyExcludes; |
2963 | 0 | } |
2964 | |
|
2965 | |
public String getClasspathDependencyScopeExclude() |
2966 | |
{ |
2967 | 0 | return classpathDependencyScopeExclude; |
2968 | |
} |
2969 | |
|
2970 | |
public void setClasspathDependencyScopeExclude( String classpathDependencyScopeExclude ) |
2971 | |
{ |
2972 | 0 | this.classpathDependencyScopeExclude = classpathDependencyScopeExclude; |
2973 | 0 | } |
2974 | |
} |