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 | |
@Parameter |
356 | 0 | 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 | |
@Parameter( property = "parallel" ) |
491 | |
protected String parallel; |
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
|
498 | |
@Parameter( property = "trimStackTrace", defaultValue = "true" ) |
499 | |
protected boolean trimStackTrace; |
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
@Component |
505 | |
protected ArtifactResolver artifactResolver; |
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
@Component |
511 | |
protected ArtifactFactory artifactFactory; |
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
@Parameter( defaultValue = "${project.pluginArtifactRepositories}" ) |
519 | |
protected List<ArtifactRepository> remoteRepositories; |
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
@Component |
525 | |
protected ArtifactMetadataSource metadataSource; |
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
@Parameter( property = "disableXmlReport", defaultValue = "false" ) |
533 | |
protected boolean disableXmlReport; |
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
@Parameter( property = "enableAssertions", defaultValue = "true" ) |
542 | |
protected boolean enableAssertions; |
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
@Component |
548 | |
protected MavenSession session; |
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
@Parameter( property = "objectFactory" ) |
556 | |
protected String objectFactory; |
557 | |
|
558 | |
|
559 | |
|
560 | |
|
561 | |
@Parameter( defaultValue = "${session.parallel}", readonly = true ) |
562 | |
protected Boolean parallelMavenExecution; |
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
|
580 | |
|
581 | |
|
582 | |
|
583 | |
|
584 | |
@Parameter( defaultValue = "filesystem" ) |
585 | |
protected String runOrder; |
586 | |
|
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | |
@Parameter( property = "dependenciesToScan" ) |
594 | |
private String[] dependenciesToScan; |
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
@Component |
600 | |
protected ToolchainManager toolchainManager; |
601 | |
|
602 | |
private Artifact surefireBooterArtifact; |
603 | |
|
604 | |
private Toolchain toolchain; |
605 | |
|
606 | 0 | private int effectiveForkCount = -1; |
607 | |
|
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
public static final String THREAD_NUMBER_PLACEHOLDER = "${surefire.threadNumber}"; |
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
public static final String FORK_NUMBER_PLACEHOLDER = "${surefire.forkNumber}"; |
620 | |
|
621 | |
protected abstract String getPluginName(); |
622 | |
|
623 | |
private SurefireDependencyResolver dependencyResolver; |
624 | |
|
625 | |
public void execute() |
626 | |
throws MojoExecutionException, MojoFailureException |
627 | |
{ |
628 | |
|
629 | 0 | setupStuff(); |
630 | |
|
631 | 0 | if ( verifyParameters() && !hasExecutedBefore() ) |
632 | |
{ |
633 | 0 | DefaultScanResult scan = scanForTestClasses(); |
634 | 0 | if ( !isValidSuiteXmlFileConfig() && scan.isEmpty() ) |
635 | |
{ |
636 | 0 | if ( getEffectiveFailIfNoTests() ) |
637 | |
{ |
638 | 0 | throw new MojoFailureException( |
639 | |
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); |
640 | |
} |
641 | 0 | handleSummary( RunResult.noTestsRun(), null ); |
642 | 0 | return; |
643 | |
} |
644 | 0 | logReportsDirectory(); |
645 | 0 | executeAfterPreconditionsChecked( scan ); |
646 | |
} |
647 | 0 | } |
648 | |
|
649 | |
private void setupStuff() |
650 | |
{ |
651 | 0 | createDependencyResolver(); |
652 | 0 | surefireBooterArtifact = getSurefireBooterArtifact(); |
653 | 0 | toolchain = getToolchain(); |
654 | 0 | } |
655 | |
|
656 | |
private DefaultScanResult scanForTestClasses() |
657 | |
{ |
658 | 0 | DefaultScanResult scan = scanDirectories(); |
659 | 0 | DefaultScanResult scanDeps = scanDependencies(); |
660 | 0 | return scan.append( scanDeps ); |
661 | |
} |
662 | |
|
663 | |
private DefaultScanResult scanDirectories() |
664 | |
{ |
665 | 0 | return new DirectoryScanner( getTestClassesDirectory(), getIncludeList(), getExcludeList(), |
666 | |
getSpecificTests() ).scan(); |
667 | |
} |
668 | |
|
669 | |
private DefaultScanResult scanDependencies() |
670 | |
{ |
671 | 0 | if ( getDependenciesToScan() == null ) |
672 | |
{ |
673 | 0 | return null; |
674 | |
} |
675 | |
else |
676 | |
{ |
677 | |
try |
678 | |
{ |
679 | |
|
680 | 0 | return new DependencyScanner( DependencyScanner.filter( project.getTestArtifacts(), |
681 | |
Arrays.asList( getDependenciesToScan() ) ), |
682 | |
getIncludeList(), getExcludeList(), getSpecificTests() ).scan(); |
683 | |
} |
684 | 0 | catch ( Exception e ) |
685 | |
{ |
686 | 0 | throw new RuntimeException( e ); |
687 | |
} |
688 | |
} |
689 | |
} |
690 | |
|
691 | |
boolean verifyParameters() |
692 | |
throws MojoFailureException, MojoExecutionException |
693 | |
{ |
694 | 0 | setProperties( new SurefireProperties( getProperties() ) ); |
695 | 0 | if ( isSkipExecution() ) |
696 | |
{ |
697 | 0 | getLog().info( "Tests are skipped." ); |
698 | 0 | return false; |
699 | |
} |
700 | |
|
701 | 0 | String jvmToUse = getJvm(); |
702 | 0 | if ( toolchain != null ) |
703 | |
{ |
704 | 0 | getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + toolchain ); |
705 | 0 | if ( jvmToUse != null ) |
706 | |
{ |
707 | 0 | getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse ); |
708 | |
} |
709 | |
} |
710 | |
|
711 | 0 | if ( !getTestClassesDirectory().exists() |
712 | |
&& ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) ) |
713 | |
{ |
714 | 0 | if ( Boolean.TRUE.equals( getFailIfNoTests() ) ) |
715 | |
{ |
716 | 0 | throw new MojoFailureException( "No tests to run!" ); |
717 | |
} |
718 | 0 | getLog().info( "No tests to run." ); |
719 | |
} |
720 | |
else |
721 | |
{ |
722 | 0 | convertDeprecatedForkMode(); |
723 | 0 | ensureWorkingDirectoryExists(); |
724 | 0 | ensureParallelRunningCompatibility(); |
725 | 0 | ensureThreadCountWithPerThread(); |
726 | 0 | warnIfUselessUseSystemClassLoaderParameter(); |
727 | 0 | warnIfDefunctGroupsCombinations(); |
728 | |
} |
729 | 0 | return true; |
730 | |
} |
731 | |
|
732 | |
protected abstract boolean isSkipExecution(); |
733 | |
|
734 | |
protected void executeAfterPreconditionsChecked( DefaultScanResult scanResult ) |
735 | |
throws MojoExecutionException, MojoFailureException |
736 | |
{ |
737 | |
|
738 | 0 | List<ProviderInfo> providers = createProviders(); |
739 | |
|
740 | 0 | RunResult current = RunResult.noTestsRun(); |
741 | |
|
742 | 0 | NestedCheckedException firstForkException = null; |
743 | 0 | for ( ProviderInfo provider : providers ) |
744 | |
{ |
745 | |
try |
746 | |
{ |
747 | 0 | current = current.aggregate( executeProvider( provider, scanResult ) ); |
748 | |
} |
749 | 0 | catch ( SurefireBooterForkException e ) |
750 | |
{ |
751 | 0 | if ( firstForkException == null ) |
752 | |
{ |
753 | 0 | firstForkException = e; |
754 | |
} |
755 | |
} |
756 | 0 | catch ( SurefireExecutionException e ) |
757 | |
{ |
758 | 0 | if ( firstForkException == null ) |
759 | |
{ |
760 | 0 | firstForkException = e; |
761 | |
} |
762 | |
} |
763 | 0 | catch ( TestSetFailedException e ) |
764 | |
{ |
765 | 0 | if ( firstForkException == null ) |
766 | |
{ |
767 | 0 | firstForkException = e; |
768 | |
} |
769 | 0 | } |
770 | |
} |
771 | |
|
772 | 0 | if ( firstForkException != null ) |
773 | |
{ |
774 | 0 | current = RunResult.failure( current, firstForkException ); |
775 | |
} |
776 | |
|
777 | 0 | handleSummary( current, firstForkException ); |
778 | 0 | } |
779 | |
|
780 | |
|
781 | |
private void createDependencyResolver() |
782 | |
{ |
783 | 0 | dependencyResolver = |
784 | |
new SurefireDependencyResolver( getArtifactResolver(), getArtifactFactory(), getLog(), getLocalRepository(), |
785 | |
getRemoteRepositories(), getMetadataSource(), getPluginName() ); |
786 | 0 | } |
787 | |
|
788 | |
protected List<ProviderInfo> createProviders() |
789 | |
throws MojoFailureException, MojoExecutionException |
790 | |
{ |
791 | 0 | final Artifact junitDepArtifact = getJunitDepArtifact(); |
792 | 0 | ProviderList wellKnownProviders = |
793 | |
new ProviderList( new DynamicProviderInfo( null ), new TestNgProviderInfo( getTestNgArtifact() ), |
794 | |
new JUnitCoreProviderInfo( getJunitArtifact(), junitDepArtifact ), |
795 | |
new JUnit4ProviderInfo( getJunitArtifact(), junitDepArtifact ), |
796 | |
new JUnit3ProviderInfo() ); |
797 | |
|
798 | 0 | return wellKnownProviders.resolve( getLog() ); |
799 | |
} |
800 | |
|
801 | |
private SurefireProperties setupProperties() |
802 | |
{ |
803 | 0 | SurefireProperties sysProps = null; |
804 | |
try { |
805 | 0 | sysProps = SurefireProperties.loadProperties( systemPropertiesFile ); |
806 | |
} |
807 | 0 | catch ( IOException e ) |
808 | |
{ |
809 | 0 | String msg = "The system property file '" + systemPropertiesFile.getAbsolutePath() + "' can't be read."; |
810 | 0 | if ( getLog().isDebugEnabled() ) |
811 | |
{ |
812 | 0 | getLog().warn( msg, e ); |
813 | |
} |
814 | |
else |
815 | |
{ |
816 | 0 | getLog().warn( msg ); |
817 | |
} |
818 | 0 | } |
819 | |
|
820 | 0 | SurefireProperties result = |
821 | |
SurefireProperties.calculateEffectiveProperties( getSystemProperties(), getSystemPropertyVariables(), |
822 | |
getUserProperties(), sysProps ); |
823 | |
|
824 | 0 | result.setProperty( "basedir", getBasedir().getAbsolutePath() ); |
825 | 0 | result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() ); |
826 | 0 | result.setProperty( "localRepository", getLocalRepository().getBasedir() ); |
827 | |
|
828 | 0 | for ( Object o : result.propertiesThatCannotBeSetASystemProperties() ) |
829 | |
{ |
830 | 0 | getLog().warn( o + " cannot be set as system property, use <argLine>-D" + o + "=...<argLine> instead" ); |
831 | |
|
832 | |
} |
833 | 0 | if ( getLog().isDebugEnabled() ) |
834 | |
{ |
835 | 0 | showToLog( result, getLog(), "system property" ); |
836 | |
} |
837 | 0 | return result; |
838 | |
} |
839 | |
|
840 | |
public void showToLog( SurefireProperties props, org.apache.maven.plugin.logging.Log log, String setting ) |
841 | |
{ |
842 | 0 | for ( Object key : props.getStringKeySet() ) |
843 | |
{ |
844 | 0 | String value = props.getProperty( (String) key ); |
845 | 0 | log.debug( "Setting " + setting + " [" + key + "]=[" + value + "]" ); |
846 | 0 | } |
847 | 0 | } |
848 | |
|
849 | |
|
850 | |
private RunResult executeProvider( ProviderInfo provider, DefaultScanResult scanResult ) |
851 | |
throws MojoExecutionException, MojoFailureException, SurefireExecutionException, SurefireBooterForkException, |
852 | |
TestSetFailedException |
853 | |
{ |
854 | 0 | SurefireProperties effectiveProperties = setupProperties(); |
855 | 0 | ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration( isForking() ); |
856 | |
|
857 | 0 | RunOrderParameters runOrderParameters = |
858 | |
new RunOrderParameters( getRunOrder(), getStatisticsFileName( getConfigChecksum() ) ); |
859 | |
|
860 | |
final RunResult result; |
861 | 0 | if ( isNotForking() ) |
862 | |
{ |
863 | 0 | createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties(); |
864 | |
|
865 | 0 | InPluginVMSurefireStarter surefireStarter = |
866 | |
createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters ); |
867 | 0 | result = surefireStarter.runSuitesInProcess( scanResult ); |
868 | 0 | } |
869 | |
else |
870 | |
{ |
871 | 0 | ForkConfiguration forkConfiguration = getForkConfiguration(); |
872 | 0 | if ( getLog().isDebugEnabled() ) |
873 | |
{ |
874 | 0 | showMap( getEnvironmentVariables(), "environment variable" ); |
875 | |
} |
876 | |
|
877 | 0 | Properties originalSystemProperties = (Properties) System.getProperties().clone(); |
878 | |
try |
879 | |
{ |
880 | 0 | ForkStarter forkStarter = |
881 | |
createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters, |
882 | |
getLog() ); |
883 | 0 | result = forkStarter.run( effectiveProperties, scanResult ); |
884 | |
} |
885 | |
finally |
886 | |
{ |
887 | 0 | System.setProperties( originalSystemProperties ); |
888 | 0 | cleanupForkConfiguration( forkConfiguration ); |
889 | 0 | } |
890 | |
} |
891 | 0 | return result; |
892 | |
} |
893 | |
|
894 | |
|
895 | |
public static SurefireProperties createCopyAndReplaceForkNumPlaceholder( |
896 | |
SurefireProperties effectiveSystemProperties, int threadNumber ) |
897 | |
{ |
898 | 0 | SurefireProperties filteredProperties = new SurefireProperties( ( KeyValueSource) effectiveSystemProperties ); |
899 | 0 | String threadNumberString = String.valueOf( threadNumber ); |
900 | 0 | for ( Entry<Object, Object> entry : effectiveSystemProperties.entrySet() ) |
901 | |
{ |
902 | 0 | if ( entry.getValue() instanceof String ) |
903 | |
{ |
904 | 0 | String value = (String) entry.getValue(); |
905 | 0 | value = value.replace( THREAD_NUMBER_PLACEHOLDER, threadNumberString ); |
906 | 0 | value = value.replace( FORK_NUMBER_PLACEHOLDER, threadNumberString ); |
907 | |
|
908 | 0 | filteredProperties.put( entry.getKey(), value ); |
909 | 0 | } |
910 | |
} |
911 | 0 | return filteredProperties; |
912 | |
} |
913 | |
|
914 | |
protected void cleanupForkConfiguration( ForkConfiguration forkConfiguration ) |
915 | |
{ |
916 | 0 | if ( !getLog().isDebugEnabled() && forkConfiguration != null ) |
917 | |
{ |
918 | 0 | File tempDirectory = forkConfiguration.getTempDirectory(); |
919 | |
try |
920 | |
{ |
921 | 0 | FileUtils.deleteDirectory( tempDirectory ); |
922 | |
} |
923 | 0 | catch ( IOException ioe ) |
924 | |
{ |
925 | 0 | getLog().warn( "Could not delete temp direcotry " + tempDirectory + " because " + ioe.getMessage() ); |
926 | 0 | } |
927 | |
} |
928 | 0 | } |
929 | |
|
930 | |
protected abstract void handleSummary( RunResult summary, NestedCheckedException firstForkException ) |
931 | |
throws MojoExecutionException, MojoFailureException; |
932 | |
|
933 | |
protected void logReportsDirectory() |
934 | |
{ |
935 | 0 | getLog().info( |
936 | |
StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() ); |
937 | 0 | } |
938 | |
|
939 | |
|
940 | |
final Toolchain getToolchain() |
941 | |
{ |
942 | 0 | Toolchain tc = null; |
943 | |
|
944 | 0 | if ( getToolchainManager() != null ) |
945 | |
{ |
946 | 0 | tc = getToolchainManager().getToolchainFromBuildContext( "jdk", getSession() ); |
947 | |
} |
948 | |
|
949 | 0 | return tc; |
950 | |
} |
951 | |
|
952 | |
|
953 | |
|
954 | |
|
955 | |
|
956 | |
private void convertTestNGParameters() throws MojoExecutionException |
957 | |
{ |
958 | 0 | if ( this.getParallel() != null ) |
959 | |
{ |
960 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_PROP, this.getParallel() ); |
961 | |
} |
962 | 0 | convertGroupParameters(); |
963 | |
|
964 | 0 | if ( this.getThreadCount() > 0 ) |
965 | |
{ |
966 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, |
967 | |
Integer.toString( this.getThreadCount() ) ); |
968 | |
} |
969 | 0 | if ( this.getObjectFactory() != null ) |
970 | |
{ |
971 | 0 | getProperties().setProperty( "objectfactory", this.getObjectFactory() ); |
972 | |
} |
973 | 0 | if ( this.getTestClassesDirectory() != null ) |
974 | |
{ |
975 | 0 | getProperties().setProperty( "testng.test.classpath", getTestClassesDirectory().getAbsolutePath() ); |
976 | |
} |
977 | |
|
978 | 0 | Artifact testNgArtifact = getTestNgArtifact(); |
979 | 0 | if ( testNgArtifact != null){ |
980 | |
|
981 | 0 | DefaultArtifactVersion defaultArtifactVersion = new DefaultArtifactVersion( testNgArtifact.getVersion() ); |
982 | 0 | getProperties().setProperty( "testng.configurator", getConfiguratorName( defaultArtifactVersion ) ); |
983 | |
} |
984 | |
|
985 | |
|
986 | 0 | } |
987 | |
|
988 | |
private static String getConfiguratorName( ArtifactVersion version ) |
989 | |
throws MojoExecutionException |
990 | |
{ |
991 | |
try |
992 | |
{ |
993 | 0 | VersionRange range = VersionRange.createFromVersionSpec( "[4.7,5.1]" ); |
994 | 0 | if ( range.containsVersion( version ) ) |
995 | |
{ |
996 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG4751Configurator"; |
997 | |
} |
998 | 0 | range = VersionRange.createFromVersionSpec( "[5.2]" ); |
999 | 0 | if ( range.containsVersion( version ) ) |
1000 | |
{ |
1001 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG52Configurator"; |
1002 | |
} |
1003 | 0 | range = VersionRange.createFromVersionSpec( "[5.3,6.4]" ); |
1004 | 0 | if ( range.containsVersion( version ) ) |
1005 | |
{ |
1006 | 0 | return "org.apache.maven.surefire.testng.conf.TestNGMapConfigurator"; |
1007 | |
} |
1008 | 0 | range = VersionRange.createFromVersionSpec( "[6.5,)" ); |
1009 | 0 | if ( range.containsVersion( version ) ) |
1010 | |
{ |
1011 | 0 | return "org.apache.maven.surefire.testng.conf.TestNG652Configurator"; |
1012 | |
} |
1013 | |
|
1014 | 0 | throw new MojoExecutionException( "Unknown TestNG version " + version ); |
1015 | |
} |
1016 | 0 | catch ( InvalidVersionSpecificationException invsex ) |
1017 | |
{ |
1018 | 0 | throw new MojoExecutionException( "Bug in plugin. Please report it with the attached stacktrace", invsex ); |
1019 | |
} |
1020 | |
} |
1021 | |
|
1022 | |
|
1023 | |
private void convertGroupParameters() |
1024 | |
{ |
1025 | 0 | if ( this.getExcludedGroups() != null ) |
1026 | |
{ |
1027 | 0 | getProperties().setProperty( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP, this.getExcludedGroups() ); |
1028 | |
} |
1029 | 0 | if ( this.getGroups() != null ) |
1030 | |
{ |
1031 | 0 | getProperties().setProperty( ProviderParameterNames.TESTNG_GROUPS_PROP, this.getGroups() ); |
1032 | |
} |
1033 | 0 | } |
1034 | |
|
1035 | |
protected boolean isAnyConcurrencySelected() |
1036 | |
{ |
1037 | 0 | return this.getParallel() != null && this.getParallel().trim().length() > 0; |
1038 | |
} |
1039 | |
|
1040 | |
protected boolean isAnyGroupsSelected() |
1041 | |
{ |
1042 | 0 | return this.getGroups() != null || this.getExcludedGroups() != null; |
1043 | |
} |
1044 | |
|
1045 | |
|
1046 | |
|
1047 | |
|
1048 | |
|
1049 | |
private void convertJunitCoreParameters() |
1050 | |
{ |
1051 | 0 | String usedParallel = ( getParallel() != null ) ? getParallel() : "none"; |
1052 | 0 | String usedThreadCount = ( getThreadCount() > 0 ) ? Integer.toString( getThreadCount() ) : "2"; |
1053 | |
|
1054 | 0 | getProperties().setProperty( ProviderParameterNames.PARALLEL_PROP, usedParallel ); |
1055 | 0 | getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, usedThreadCount ); |
1056 | 0 | getProperties().setProperty( "perCoreThreadCount", Boolean.toString( getPerCoreThreadCount() ) ); |
1057 | 0 | getProperties().setProperty( "useUnlimitedThreads", Boolean.toString( getUseUnlimitedThreads() ) ); |
1058 | |
|
1059 | 0 | String message = |
1060 | |
"parallel='" + usedParallel + '\'' + ", perCoreThreadCount=" + getPerCoreThreadCount() + ", threadCount=" |
1061 | |
+ usedThreadCount + ", useUnlimitedThreads=" + getUseUnlimitedThreads(); |
1062 | |
|
1063 | 0 | getLog().info( message ); |
1064 | 0 | } |
1065 | |
|
1066 | |
private boolean isJunit47Compatible( Artifact artifact ) |
1067 | |
{ |
1068 | 0 | return dependencyResolver.isWithinVersionSpec( artifact, "[4.7,)" ); |
1069 | |
} |
1070 | |
|
1071 | |
private boolean isAnyJunit4( Artifact artifact ) |
1072 | |
{ |
1073 | 0 | return dependencyResolver.isWithinVersionSpec( artifact, "[4.0,)" ); |
1074 | |
} |
1075 | |
|
1076 | |
static boolean isForkModeNever( String forkMode ) |
1077 | |
{ |
1078 | 0 | return ForkConfiguration.FORK_NEVER.equals( forkMode ); |
1079 | |
} |
1080 | |
|
1081 | |
boolean isForking() |
1082 | |
{ |
1083 | 0 | return 0 < getEffectiveForkCount(); |
1084 | |
} |
1085 | |
|
1086 | |
String getEffectiveForkMode() |
1087 | |
{ |
1088 | 0 | String forkMode1 = getForkMode(); |
1089 | |
|
1090 | 0 | if ( toolchain != null && isForkModeNever( forkMode1 ) ) |
1091 | |
{ |
1092 | 0 | return ForkConfiguration.FORK_ONCE; |
1093 | |
} |
1094 | |
|
1095 | 0 | return ForkConfiguration.getEffectiveForkMode( forkMode1 ); |
1096 | |
} |
1097 | |
|
1098 | |
private List<RunOrder> getRunOrders() |
1099 | |
{ |
1100 | 0 | String runOrderString = getRunOrder(); |
1101 | 0 | RunOrder[] runOrder = runOrderString == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrderString ); |
1102 | 0 | return Arrays.asList( runOrder ); |
1103 | |
} |
1104 | |
|
1105 | |
private boolean requiresRunHistory() |
1106 | |
{ |
1107 | 0 | final List<RunOrder> runOrders = getRunOrders(); |
1108 | 0 | return runOrders.contains( RunOrder.BALANCED ) || runOrders.contains( RunOrder.FAILEDFIRST ); |
1109 | |
} |
1110 | |
|
1111 | |
private boolean getEffectiveFailIfNoTests() |
1112 | |
{ |
1113 | 0 | if ( isSpecificTestSpecified() ) |
1114 | |
{ |
1115 | 0 | if ( getFailIfNoSpecifiedTests() != null ) |
1116 | |
{ |
1117 | 0 | return getFailIfNoSpecifiedTests(); |
1118 | |
} |
1119 | 0 | else if ( getFailIfNoTests() != null ) |
1120 | |
{ |
1121 | 0 | return getFailIfNoTests(); |
1122 | |
} |
1123 | |
else |
1124 | |
{ |
1125 | 0 | return true; |
1126 | |
} |
1127 | |
} |
1128 | |
else |
1129 | |
{ |
1130 | 0 | return getFailIfNoTests() != null && getFailIfNoTests(); |
1131 | |
} |
1132 | |
} |
1133 | |
|
1134 | |
private ProviderConfiguration createProviderConfiguration( RunOrderParameters runOrderParameters ) |
1135 | |
throws MojoExecutionException, MojoFailureException |
1136 | |
{ |
1137 | 0 | ReporterConfiguration reporterConfiguration = |
1138 | |
new ReporterConfiguration( getReportsDirectory(), isTrimStackTrace() ); |
1139 | |
|
1140 | |
Artifact testNgArtifact; |
1141 | 0 | testNgArtifact = getTestNgArtifact(); |
1142 | |
|
1143 | 0 | DirectoryScannerParameters directoryScannerParameters = null; |
1144 | 0 | final boolean isTestNg = testNgArtifact != null; |
1145 | 0 | TestArtifactInfo testNg = |
1146 | |
isTestNg ? new TestArtifactInfo( testNgArtifact.getVersion(), testNgArtifact.getClassifier() ) : null; |
1147 | 0 | List<File> testXml = getSuiteXmlFiles() != null ? Arrays.asList( getSuiteXmlFiles() ) : null; |
1148 | 0 | TestRequest testSuiteDefinition = |
1149 | |
new TestRequest( testXml, getTestSourceDirectory(), getTest(), getTestMethod() ); |
1150 | |
final boolean failIfNoTests; |
1151 | |
|
1152 | 0 | if ( isValidSuiteXmlFileConfig() && getTest() == null ) |
1153 | |
{ |
1154 | 0 | failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests(); |
1155 | 0 | if ( !isTestNg ) |
1156 | |
{ |
1157 | 0 | throw new MojoExecutionException( "suiteXmlFiles is configured, but there is no TestNG dependency" ); |
1158 | |
} |
1159 | |
} |
1160 | |
else |
1161 | |
{ |
1162 | 0 | if ( isSpecificTestSpecified() ) |
1163 | |
{ |
1164 | 0 | failIfNoTests = getEffectiveFailIfNoTests(); |
1165 | 0 | setFailIfNoTests( failIfNoTests ); |
1166 | |
} |
1167 | |
else |
1168 | |
{ |
1169 | 0 | failIfNoTests = getFailIfNoTests() != null && getFailIfNoTests(); |
1170 | |
} |
1171 | |
|
1172 | 0 | List<String> includes = getIncludeList(); |
1173 | 0 | List<String> excludes = getExcludeList(); |
1174 | 0 | List<String> specificTests = getSpecificTests(); |
1175 | 0 | directoryScannerParameters = |
1176 | |
new DirectoryScannerParameters( getTestClassesDirectory(), includes, excludes, specificTests, |
1177 | |
failIfNoTests, getRunOrder() ); |
1178 | |
} |
1179 | |
|
1180 | 0 | Properties providerProperties = getProperties(); |
1181 | |
|
1182 | 0 | return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, failIfNoTests, |
1183 | |
reporterConfiguration, testNg, testSuiteDefinition, providerProperties, null, |
1184 | |
false ); |
1185 | |
} |
1186 | |
|
1187 | |
public String getStatisticsFileName( String configurationHash ) |
1188 | |
{ |
1189 | 0 | return getReportsDirectory().getParentFile().getParentFile() + File.separator + ".surefire-" |
1190 | |
+ configurationHash; |
1191 | |
} |
1192 | |
|
1193 | |
|
1194 | |
StartupConfiguration createStartupConfiguration( ProviderInfo provider, |
1195 | |
ClassLoaderConfiguration classLoaderConfiguration ) |
1196 | |
throws MojoExecutionException, MojoFailureException |
1197 | |
{ |
1198 | |
|
1199 | |
try |
1200 | |
{ |
1201 | 0 | provider.addProviderProperties(); |
1202 | |
|
1203 | 0 | String providerName = provider.getProviderName(); |
1204 | 0 | Classpath providerClasspath = ClasspathCache.getCachedClassPath( providerName ); |
1205 | 0 | if ( providerClasspath == null ) |
1206 | |
{ |
1207 | 0 | providerClasspath = provider.getProviderClasspath(); |
1208 | 0 | ClasspathCache.setCachedClasspath( providerName, providerClasspath ); |
1209 | |
|
1210 | |
} |
1211 | 0 | Artifact surefireArtifact = getCommonArtifact(); |
1212 | 0 | Classpath inprocClassPath = providerClasspath.addClassPathElementUrl( surefireArtifact.getFile().getAbsolutePath() ); |
1213 | |
|
1214 | 0 | final Classpath testClasspath = generateTestClasspath(); |
1215 | |
|
1216 | 0 | getLog().debug( testClasspath.getLogMessage( "test" ) ); |
1217 | 0 | getLog().debug( providerClasspath.getLogMessage( "provider" ) ); |
1218 | |
|
1219 | 0 | getLog().debug( testClasspath.getCompactLogMessage( "test(compact)" ) ); |
1220 | 0 | getLog().debug( providerClasspath.getCompactLogMessage( "provider(compact)" ) ); |
1221 | |
|
1222 | 0 | final ClasspathConfiguration classpathConfiguration = |
1223 | |
new ClasspathConfiguration( testClasspath, providerClasspath, inprocClassPath, |
1224 | |
effectiveIsEnableAssertions(), isChildDelegation() ); |
1225 | |
|
1226 | 0 | return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, |
1227 | |
isForking(), false ); |
1228 | |
} |
1229 | 0 | catch ( ArtifactResolutionException e ) |
1230 | |
{ |
1231 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1232 | |
} |
1233 | 0 | catch ( ArtifactNotFoundException e ) |
1234 | |
{ |
1235 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1236 | |
} |
1237 | 0 | catch ( InvalidVersionSpecificationException e ) |
1238 | |
{ |
1239 | 0 | throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); |
1240 | |
} |
1241 | |
|
1242 | |
} |
1243 | |
|
1244 | |
private Artifact getCommonArtifact() |
1245 | |
{ |
1246 | 0 | return getPluginArtifactMap().get( "org.apache.maven.surefire:maven-surefire-common" ); |
1247 | |
} |
1248 | |
|
1249 | |
private StartupReportConfiguration getStartupReportConfiguration( String configChecksum ) |
1250 | |
{ |
1251 | 0 | return new StartupReportConfiguration( isUseFile(), isPrintSummary(), getReportFormat(), |
1252 | |
isRedirectTestOutputToFile(), isDisableXmlReport(), |
1253 | |
getReportsDirectory(), isTrimStackTrace(), getReportNameSuffix(), |
1254 | |
configChecksum, requiresRunHistory() ); |
1255 | |
} |
1256 | |
|
1257 | |
private boolean isSpecificTestSpecified() |
1258 | |
{ |
1259 | 0 | return getTest() != null; |
1260 | |
} |
1261 | |
|
1262 | |
private boolean isValidSuiteXmlFileConfig() |
1263 | |
{ |
1264 | 0 | return getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0; |
1265 | |
} |
1266 | |
|
1267 | |
@Nonnull private List<String> readListFromFile( @Nonnull final File file ) |
1268 | |
{ |
1269 | |
List<String> list; |
1270 | |
|
1271 | 0 | getLog().debug( "Reading list from: " + file ); |
1272 | |
|
1273 | 0 | if ( !file.exists() ) |
1274 | |
{ |
1275 | 0 | throw new RuntimeException( "Failed to load list from file: " + file ); |
1276 | |
} |
1277 | |
|
1278 | |
try |
1279 | |
{ |
1280 | 0 | list = FileUtils.loadFile( file ); |
1281 | |
} |
1282 | 0 | catch ( IOException e ) |
1283 | |
{ |
1284 | 0 | throw new RuntimeException( "Failed to load list from file: " + file, e ); |
1285 | 0 | } |
1286 | |
|
1287 | 0 | if ( getLog().isDebugEnabled() ) |
1288 | |
{ |
1289 | 0 | getLog().debug( "List contents:" ); |
1290 | 0 | for ( String entry : list ) |
1291 | |
{ |
1292 | 0 | getLog().debug( " " + entry ); |
1293 | |
} |
1294 | |
} |
1295 | 0 | return list; |
1296 | |
} |
1297 | |
|
1298 | |
private void maybeAppendList( final List<String> base, final List<String> list ) |
1299 | |
{ |
1300 | 0 | if ( list != null ) |
1301 | |
{ |
1302 | 0 | base.addAll( list ); |
1303 | |
} |
1304 | 0 | } |
1305 | |
|
1306 | |
private @Nonnull List<String> getExcludeList() |
1307 | |
{ |
1308 | 0 | List<String> excludes = null; |
1309 | 0 | if ( isSpecificTestSpecified() ) |
1310 | |
{ |
1311 | |
|
1312 | |
|
1313 | |
|
1314 | |
|
1315 | 0 | excludes = new ArrayList<String>(); |
1316 | |
} |
1317 | |
else |
1318 | |
{ |
1319 | 0 | if ( getExcludesFile() != null ) |
1320 | |
{ |
1321 | 0 | excludes = readListFromFile( getExcludesFile() ); |
1322 | |
} |
1323 | |
|
1324 | |
|
1325 | 0 | if ( excludes == null ) |
1326 | |
{ |
1327 | 0 | excludes = this.getExcludes(); |
1328 | |
} |
1329 | |
else |
1330 | |
{ |
1331 | 0 | maybeAppendList( excludes, this.getExcludes() ); |
1332 | |
} |
1333 | |
|
1334 | |
|
1335 | |
|
1336 | 0 | if ( excludes == null || excludes.size() == 0 ) |
1337 | |
{ |
1338 | 0 | excludes = Arrays.asList( "**/*$*" ); |
1339 | |
} |
1340 | |
} |
1341 | 0 | return filterNulls( excludes ); |
1342 | |
} |
1343 | |
|
1344 | |
private List<String> getIncludeList() |
1345 | |
{ |
1346 | 0 | List<String> includes = null; |
1347 | 0 | if ( isSpecificTestSpecified() && !isMultipleExecutionBlocksDetected() ) |
1348 | |
{ |
1349 | 0 | includes = getSpecificTests(); |
1350 | |
} |
1351 | |
else |
1352 | |
{ |
1353 | 0 | if ( getIncludesFile() != null ) |
1354 | |
{ |
1355 | 0 | includes = readListFromFile( getIncludesFile() ); |
1356 | |
} |
1357 | |
|
1358 | |
|
1359 | 0 | if ( includes == null ) |
1360 | |
{ |
1361 | 0 | includes = this.getIncludes(); |
1362 | |
} |
1363 | |
else |
1364 | |
{ |
1365 | 0 | maybeAppendList( includes, this.getIncludes() ); |
1366 | |
} |
1367 | |
} |
1368 | |
|
1369 | |
|
1370 | |
|
1371 | 0 | if ( includes == null || includes.size() == 0 ) |
1372 | |
{ |
1373 | 0 | includes = Arrays.asList( getDefaultIncludes() ); |
1374 | |
} |
1375 | |
|
1376 | 0 | return filterNulls( includes ); |
1377 | |
} |
1378 | |
|
1379 | |
private @Nonnull List<String> filterNulls( @Nonnull List<String> toFilter ) |
1380 | |
{ |
1381 | 0 | List<String> result = new ArrayList<String>( toFilter.size() ); |
1382 | 0 | for ( String item : toFilter ) |
1383 | |
{ |
1384 | 0 | if ( item != null ) |
1385 | |
{ |
1386 | 0 | result.add( item ); |
1387 | |
} |
1388 | |
} |
1389 | |
|
1390 | 0 | return result; |
1391 | |
} |
1392 | |
|
1393 | |
private boolean isMultipleExecutionBlocksDetected() |
1394 | |
{ |
1395 | 0 | MavenProject project = getProject(); |
1396 | 0 | if ( project != null ) |
1397 | |
{ |
1398 | 0 | String key = getPluginDescriptor().getPluginLookupKey(); |
1399 | 0 | Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key ); |
1400 | |
|
1401 | 0 | if ( plugin != null ) |
1402 | |
{ |
1403 | 0 | @SuppressWarnings( "rawtypes" ) List executions = plugin.getExecutions(); |
1404 | 0 | return executions != null && executions.size() > 1; |
1405 | |
} |
1406 | |
} |
1407 | |
|
1408 | 0 | return false; |
1409 | |
} |
1410 | |
|
1411 | |
private List<String> getSpecificTests() |
1412 | |
{ |
1413 | 0 | if ( !isSpecificTestSpecified() ) |
1414 | |
{ |
1415 | 0 | return Collections.emptyList(); |
1416 | |
} |
1417 | |
|
1418 | 0 | List<String> specificTests = new ArrayList<String>(); |
1419 | 0 | String[] testRegexes = StringUtils.split( getTest(), "," ); |
1420 | |
|
1421 | 0 | for ( String testRegexe : testRegexes ) |
1422 | |
{ |
1423 | 0 | String testRegex = testRegexe; |
1424 | 0 | if ( testRegex.endsWith( ".java" ) ) |
1425 | |
{ |
1426 | 0 | testRegex = testRegex.substring( 0, testRegex.length() - 5 ); |
1427 | |
} |
1428 | |
|
1429 | 0 | testRegex = testRegex.replace( '.', '/' ); |
1430 | 0 | specificTests.add( "**/" + testRegex + ".java" ); |
1431 | |
} |
1432 | |
|
1433 | 0 | return specificTests; |
1434 | |
} |
1435 | |
|
1436 | |
private Artifact getTestNgArtifact() |
1437 | |
throws MojoExecutionException |
1438 | |
{ |
1439 | 0 | Artifact artifact = getProjectArtifactMap().get( getTestNGArtifactName() ); |
1440 | |
|
1441 | 0 | if ( artifact != null ) |
1442 | |
{ |
1443 | 0 | VersionRange range = createVersionRange(); |
1444 | 0 | if ( !range.containsVersion( new DefaultArtifactVersion( artifact.getVersion() ) ) ) |
1445 | |
{ |
1446 | 0 | throw new MojoExecutionException( |
1447 | |
"TestNG support requires version 4.7 or above. You have declared version " |
1448 | |
+ artifact.getVersion() ); |
1449 | |
} |
1450 | |
} |
1451 | 0 | return artifact; |
1452 | |
|
1453 | |
} |
1454 | |
|
1455 | |
private VersionRange createVersionRange() |
1456 | |
{ |
1457 | |
try |
1458 | |
{ |
1459 | 0 | return VersionRange.createFromVersionSpec( "[4.7,)" ); |
1460 | |
} |
1461 | 0 | catch ( InvalidVersionSpecificationException e ) |
1462 | |
{ |
1463 | 0 | throw new RuntimeException( e ); |
1464 | |
} |
1465 | |
} |
1466 | |
|
1467 | |
private Artifact getJunitArtifact() |
1468 | |
{ |
1469 | 0 | return getProjectArtifactMap().get( getJunitArtifactName() ); |
1470 | |
} |
1471 | |
|
1472 | |
private Artifact getJunitDepArtifact() |
1473 | |
{ |
1474 | 0 | return getProjectArtifactMap().get( "junit:junit-dep" ); |
1475 | |
} |
1476 | |
|
1477 | |
protected ForkStarter createForkStarter( ProviderInfo provider, ForkConfiguration forkConfiguration, |
1478 | |
ClassLoaderConfiguration classLoaderConfiguration, |
1479 | |
RunOrderParameters runOrderParameters, Log log ) |
1480 | |
throws MojoExecutionException, MojoFailureException |
1481 | |
{ |
1482 | 0 | StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration ); |
1483 | 0 | String configChecksum = getConfigChecksum(); |
1484 | 0 | StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum ); |
1485 | 0 | ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters ); |
1486 | 0 | return new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration, |
1487 | |
getForkedProcessTimeoutInSeconds(), startupReportConfiguration, log ); |
1488 | |
} |
1489 | |
|
1490 | |
protected InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider, |
1491 | |
ClassLoaderConfiguration classLoaderConfiguration, |
1492 | |
RunOrderParameters runOrderParameters ) |
1493 | |
throws MojoExecutionException, MojoFailureException |
1494 | |
{ |
1495 | 0 | StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration ); |
1496 | 0 | String configChecksum = getConfigChecksum(); |
1497 | 0 | StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum ); |
1498 | 0 | ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters ); |
1499 | 0 | return new InPluginVMSurefireStarter( startupConfiguration, providerConfiguration, startupReportConfiguration ); |
1500 | |
|
1501 | |
} |
1502 | |
|
1503 | |
protected ForkConfiguration getForkConfiguration() |
1504 | |
{ |
1505 | 0 | File tmpDir = getSurefireTempDir(); |
1506 | |
|
1507 | 0 | tmpDir.mkdirs(); |
1508 | |
|
1509 | 0 | Artifact shadeFire = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-shadefire" ); |
1510 | |
|
1511 | 0 | final Classpath bootClasspathConfiguration = |
1512 | |
getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact ); |
1513 | |
|
1514 | 0 | return new ForkConfiguration( bootClasspathConfiguration, tmpDir, getEffectiveDebugForkedProcess(), |
1515 | |
getEffectiveJvm(), |
1516 | |
getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(), |
1517 | |
getArgLine(), getEnvironmentVariables(), getLog().isDebugEnabled(), |
1518 | |
getEffectiveForkCount(), reuseForks ); |
1519 | |
} |
1520 | |
|
1521 | |
private void convertDeprecatedForkMode() |
1522 | |
{ |
1523 | 0 | String effectiveForkMode = getEffectiveForkMode(); |
1524 | |
|
1525 | 0 | if ( ForkConfiguration.FORK_PERTHREAD.equals( effectiveForkMode ) ) |
1526 | |
{ |
1527 | 0 | forkCount = String.valueOf( threadCount ); |
1528 | |
} |
1529 | 0 | else if ( ForkConfiguration.FORK_NEVER.equals( effectiveForkMode ) ) |
1530 | |
{ |
1531 | 0 | forkCount = "0"; |
1532 | |
} |
1533 | 0 | else if ( ForkConfiguration.FORK_ALWAYS.equals( effectiveForkMode ) ) |
1534 | |
{ |
1535 | 0 | forkCount = "1"; |
1536 | 0 | reuseForks = false; |
1537 | |
} |
1538 | |
|
1539 | 0 | if ( !ForkConfiguration.FORK_ONCE.equals( getForkMode() ) ) |
1540 | |
{ |
1541 | 0 | getLog().warn( |
1542 | |
"The parameter forkMode is deprecated since version 2.14. Use forkCount and reuseForks instead." ); |
1543 | |
} |
1544 | 0 | } |
1545 | |
|
1546 | |
protected int getEffectiveForkCount() |
1547 | |
{ |
1548 | 0 | if ( effectiveForkCount < 0 ) |
1549 | |
{ |
1550 | |
try |
1551 | |
{ |
1552 | 0 | effectiveForkCount = convertWithCoreCount( forkCount ); |
1553 | |
} |
1554 | 0 | catch ( NumberFormatException ignored ) |
1555 | |
{ |
1556 | 0 | } |
1557 | |
|
1558 | 0 | if ( effectiveForkCount < 0 ) |
1559 | |
{ |
1560 | 0 | throw new IllegalArgumentException( "Fork count " + forkCount.trim() + " is not a legal value." ); |
1561 | |
} |
1562 | |
} |
1563 | |
|
1564 | 0 | return effectiveForkCount; |
1565 | |
} |
1566 | |
|
1567 | |
protected int convertWithCoreCount( String count ) |
1568 | |
{ |
1569 | 0 | String trimmed = count.trim(); |
1570 | 0 | if ( trimmed.endsWith( "C" ) ) |
1571 | |
{ |
1572 | 0 | double multiplier = Double.parseDouble( trimmed.substring( 0, trimmed.length() - 1 ) ); |
1573 | 0 | return (int) ( multiplier * ( (double) Runtime.getRuntime().availableProcessors() ) ); |
1574 | |
} |
1575 | |
else |
1576 | |
{ |
1577 | 0 | return Integer.parseInt( trimmed ); |
1578 | |
} |
1579 | |
} |
1580 | |
|
1581 | |
private String getEffectiveDebugForkedProcess() |
1582 | |
{ |
1583 | 0 | String debugForkedProcess = getDebugForkedProcess(); |
1584 | 0 | if ( "true".equals( debugForkedProcess ) ) |
1585 | |
{ |
1586 | 0 | return "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"; |
1587 | |
} |
1588 | 0 | return debugForkedProcess; |
1589 | |
} |
1590 | |
|
1591 | |
private String getEffectiveJvm() |
1592 | |
{ |
1593 | 0 | String jvmToUse = getJvm(); |
1594 | 0 | if ( toolchain != null && jvmToUse == null ) |
1595 | |
{ |
1596 | 0 | jvmToUse = toolchain.findTool( "java" ); |
1597 | |
} |
1598 | |
|
1599 | 0 | if ( StringUtils.isEmpty( jvmToUse ) ) |
1600 | |
{ |
1601 | |
|
1602 | 0 | jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; |
1603 | 0 | getLog().debug( "Using JVM: " + jvmToUse ); |
1604 | |
} |
1605 | |
|
1606 | 0 | return jvmToUse; |
1607 | |
} |
1608 | |
|
1609 | |
|
1610 | |
private Artifact getSurefireBooterArtifact() |
1611 | |
{ |
1612 | 0 | Artifact artifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
1613 | 0 | if ( artifact == null ) |
1614 | |
{ |
1615 | 0 | throw new RuntimeException( "Unable to locate surefire-booter in the list of plugin artifacts" ); |
1616 | |
} |
1617 | 0 | artifact.isSnapshot(); |
1618 | 0 | return artifact; |
1619 | |
} |
1620 | |
|
1621 | |
|
1622 | |
|
1623 | |
|
1624 | |
|
1625 | |
|
1626 | |
|
1627 | |
private File getSurefireTempDir() |
1628 | |
{ |
1629 | 0 | return new File( getReportsDirectory().getParentFile(), "surefire" ); |
1630 | |
} |
1631 | |
|
1632 | |
|
1633 | |
|
1634 | |
|
1635 | |
|
1636 | |
|
1637 | |
private String getConfigChecksum() |
1638 | |
{ |
1639 | 0 | ChecksumCalculator checksum = new ChecksumCalculator(); |
1640 | 0 | checksum.add( getPluginName() ); |
1641 | 0 | checksum.add( isSkipTests() ); |
1642 | 0 | checksum.add( isSkipExec() ); |
1643 | 0 | checksum.add( isSkip() ); |
1644 | 0 | checksum.add( getTestClassesDirectory() ); |
1645 | 0 | checksum.add( getClassesDirectory() ); |
1646 | 0 | checksum.add( getClasspathDependencyExcludes() ); |
1647 | 0 | checksum.add( getClasspathDependencyScopeExclude() ); |
1648 | 0 | checksum.add( getAdditionalClasspathElements() ); |
1649 | 0 | checksum.add( getReportsDirectory() ); |
1650 | 0 | checksum.add( getTestSourceDirectory() ); |
1651 | 0 | checksum.add( getTest() ); |
1652 | 0 | checksum.add( getIncludes() ); |
1653 | 0 | checksum.add( getExcludes() ); |
1654 | 0 | checksum.add( getLocalRepository() ); |
1655 | 0 | checksum.add( getSystemProperties() ); |
1656 | 0 | checksum.add( getSystemPropertyVariables() ); |
1657 | 0 | checksum.add( getSystemPropertiesFile() ); |
1658 | 0 | checksum.add( getProperties() ); |
1659 | 0 | checksum.add( isPrintSummary() ); |
1660 | 0 | checksum.add( getReportFormat() ); |
1661 | 0 | checksum.add( getReportNameSuffix() ); |
1662 | 0 | checksum.add( isUseFile() ); |
1663 | 0 | checksum.add( isRedirectTestOutputToFile() ); |
1664 | 0 | checksum.add( getForkMode() ); |
1665 | 0 | checksum.add( getForkCount() ); |
1666 | 0 | checksum.add( isReuseForks() ); |
1667 | 0 | checksum.add( getJvm() ); |
1668 | 0 | checksum.add( getArgLine() ); |
1669 | 0 | checksum.add( getDebugForkedProcess() ); |
1670 | 0 | checksum.add( getForkedProcessTimeoutInSeconds() ); |
1671 | 0 | checksum.add( getEnvironmentVariables() ); |
1672 | 0 | checksum.add( getWorkingDirectory() ); |
1673 | 0 | checksum.add( isChildDelegation() ); |
1674 | 0 | checksum.add( getGroups() ); |
1675 | 0 | checksum.add( getExcludedGroups() ); |
1676 | 0 | checksum.add( getSuiteXmlFiles() ); |
1677 | 0 | checksum.add( getJunitArtifact() ); |
1678 | 0 | checksum.add( getTestNGArtifactName() ); |
1679 | 0 | checksum.add( getThreadCount() ); |
1680 | 0 | checksum.add( getPerCoreThreadCount() ); |
1681 | 0 | checksum.add( getUseUnlimitedThreads() ); |
1682 | 0 | checksum.add( getParallel() ); |
1683 | 0 | checksum.add( isTrimStackTrace() ); |
1684 | 0 | checksum.add( getRemoteRepositories() ); |
1685 | 0 | checksum.add( isDisableXmlReport() ); |
1686 | 0 | checksum.add( isUseSystemClassLoader() ); |
1687 | 0 | checksum.add( isUseManifestOnlyJar() ); |
1688 | 0 | checksum.add( isEnableAssertions() ); |
1689 | 0 | checksum.add( getObjectFactory() ); |
1690 | 0 | checksum.add( getFailIfNoTests() ); |
1691 | 0 | checksum.add( getRunOrder() ); |
1692 | 0 | checksum.add( getDependenciesToScan() ); |
1693 | 0 | addPluginSpecificChecksumItems( checksum ); |
1694 | 0 | return checksum.getSha1(); |
1695 | |
|
1696 | |
} |
1697 | |
|
1698 | |
protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum ) |
1699 | |
{ |
1700 | |
|
1701 | 0 | } |
1702 | |
|
1703 | |
protected boolean hasExecutedBefore() |
1704 | |
{ |
1705 | |
|
1706 | 0 | String configChecksum = getConfigChecksum(); |
1707 | 0 | @SuppressWarnings( "unchecked" ) Map<String, String> pluginContext = getPluginContext(); |
1708 | 0 | if ( pluginContext.containsKey( configChecksum ) ) |
1709 | |
{ |
1710 | 0 | getLog().info( "Skipping execution of surefire because it has already been run for this configuration" ); |
1711 | 0 | return true; |
1712 | |
} |
1713 | 0 | pluginContext.put( configChecksum, configChecksum ); |
1714 | |
|
1715 | 0 | return false; |
1716 | |
} |
1717 | |
|
1718 | |
protected ClassLoaderConfiguration getClassLoaderConfiguration( boolean isForking ) |
1719 | |
{ |
1720 | 0 | return isForking |
1721 | |
? new ClassLoaderConfiguration( isUseSystemClassLoader(), isUseManifestOnlyJar() ) |
1722 | |
: new ClassLoaderConfiguration( false, false ); |
1723 | |
} |
1724 | |
|
1725 | |
protected abstract String[] getDefaultIncludes(); |
1726 | |
|
1727 | |
|
1728 | |
|
1729 | |
|
1730 | |
|
1731 | |
|
1732 | |
|
1733 | |
|
1734 | |
|
1735 | |
|
1736 | |
|
1737 | |
Classpath generateTestClasspath() |
1738 | |
throws InvalidVersionSpecificationException, MojoFailureException, ArtifactResolutionException, |
1739 | |
ArtifactNotFoundException, MojoExecutionException |
1740 | |
{ |
1741 | 0 | List<String> classpath = new ArrayList<String>( 2 + getProject().getArtifacts().size() ); |
1742 | |
|
1743 | 0 | classpath.add( getTestClassesDirectory().getAbsolutePath() ); |
1744 | |
|
1745 | 0 | classpath.add( getClassesDirectory().getAbsolutePath() ); |
1746 | |
|
1747 | 0 | @SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts = getProject().getArtifacts(); |
1748 | |
|
1749 | 0 | if ( getClasspathDependencyScopeExclude() != null && !getClasspathDependencyScopeExclude().equals( "" ) ) |
1750 | |
{ |
1751 | 0 | ArtifactFilter dependencyFilter = new ScopeArtifactFilter( getClasspathDependencyScopeExclude() ); |
1752 | 0 | classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter ); |
1753 | |
} |
1754 | |
|
1755 | 0 | if ( getClasspathDependencyExcludes() != null ) |
1756 | |
{ |
1757 | 0 | ArtifactFilter dependencyFilter = new PatternIncludesArtifactFilter( Arrays.asList( getClasspathDependencyExcludes() ) ); |
1758 | 0 | classpathArtifacts = this.filterArtifacts( classpathArtifacts, dependencyFilter ); |
1759 | |
} |
1760 | |
|
1761 | 0 | for ( Artifact artifact : classpathArtifacts ) |
1762 | |
{ |
1763 | 0 | if ( artifact.getArtifactHandler().isAddedToClasspath() ) |
1764 | |
{ |
1765 | 0 | File file = artifact.getFile(); |
1766 | 0 | if ( file != null ) |
1767 | |
{ |
1768 | 0 | classpath.add( file.getPath() ); |
1769 | |
} |
1770 | 0 | } |
1771 | |
} |
1772 | |
|
1773 | |
|
1774 | 0 | if ( getAdditionalClasspathElements() != null ) |
1775 | |
{ |
1776 | 0 | for ( String classpathElement : getAdditionalClasspathElements() ) |
1777 | |
{ |
1778 | 0 | if ( classpathElement != null ) |
1779 | |
{ |
1780 | 0 | classpath.add( classpathElement ); |
1781 | |
} |
1782 | |
} |
1783 | |
} |
1784 | |
|
1785 | |
|
1786 | |
|
1787 | 0 | if ( getTestNgArtifact() != null ) |
1788 | |
{ |
1789 | 0 | addTestNgUtilsArtifacts( classpath ); |
1790 | |
} |
1791 | |
|
1792 | 0 | return new Classpath( classpath ); |
1793 | |
} |
1794 | |
|
1795 | |
void addTestNgUtilsArtifacts( List<String> classpath ) |
1796 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
1797 | |
{ |
1798 | 0 | Artifact surefireArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
1799 | 0 | String surefireVersion = surefireArtifact.getBaseVersion(); |
1800 | |
|
1801 | 0 | Artifact[] extraTestNgArtifacts = |
1802 | |
{ getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-testng-utils", |
1803 | |
surefireVersion, "runtime", "jar" ), |
1804 | |
getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-grouper", surefireVersion, |
1805 | |
"runtime", "jar" ) }; |
1806 | |
|
1807 | 0 | for ( Artifact artifact : extraTestNgArtifacts ) |
1808 | |
{ |
1809 | 0 | getArtifactResolver().resolve( artifact, getRemoteRepositories(), getLocalRepository() ); |
1810 | |
|
1811 | 0 | String path = artifact.getFile().getPath(); |
1812 | 0 | classpath.add( path ); |
1813 | |
} |
1814 | 0 | } |
1815 | |
|
1816 | |
|
1817 | |
|
1818 | |
|
1819 | |
|
1820 | |
|
1821 | |
|
1822 | |
|
1823 | |
private Set<Artifact> filterArtifacts( Set<Artifact> artifacts, ArtifactFilter filter ) |
1824 | |
{ |
1825 | 0 | Set<Artifact> filteredArtifacts = new LinkedHashSet<Artifact>(); |
1826 | |
|
1827 | 0 | for ( Artifact artifact : artifacts ) |
1828 | |
{ |
1829 | 0 | if ( !filter.include( artifact ) ) |
1830 | |
{ |
1831 | 0 | filteredArtifacts.add( artifact ); |
1832 | |
} |
1833 | |
} |
1834 | |
|
1835 | 0 | return filteredArtifacts; |
1836 | |
} |
1837 | |
|
1838 | |
private void showMap( Map<?, ?> map, String setting ) |
1839 | |
{ |
1840 | 0 | for ( Object o : map.keySet() ) |
1841 | |
{ |
1842 | 0 | String key = (String) o; |
1843 | 0 | String value = (String) map.get( key ); |
1844 | 0 | getLog().debug( "Setting " + setting + " [" + key + "]=[" + value + "]" ); |
1845 | 0 | } |
1846 | 0 | } |
1847 | |
|
1848 | |
|
1849 | |
private ArtifactResolutionResult resolveArtifact( Artifact filteredArtifact, Artifact providerArtifact ) |
1850 | |
{ |
1851 | 0 | ArtifactFilter filter = null; |
1852 | 0 | if ( filteredArtifact != null ) |
1853 | |
{ |
1854 | 0 | filter = new ExcludesArtifactFilter( |
1855 | |
Collections.singletonList( filteredArtifact.getGroupId() + ":" + filteredArtifact.getArtifactId() ) ); |
1856 | |
} |
1857 | |
|
1858 | 0 | Artifact originatingArtifact = getArtifactFactory().createBuildArtifact( "dummy", "dummy", "1.0", "jar" ); |
1859 | |
|
1860 | |
try |
1861 | |
{ |
1862 | 0 | return getArtifactResolver().resolveTransitively( Collections.singleton( providerArtifact ), |
1863 | |
originatingArtifact, getLocalRepository(), |
1864 | |
getRemoteRepositories(), getMetadataSource(), filter ); |
1865 | |
} |
1866 | 0 | catch ( ArtifactResolutionException e ) |
1867 | |
{ |
1868 | 0 | throw new NestedRuntimeException( e ); |
1869 | |
} |
1870 | 0 | catch ( ArtifactNotFoundException e ) |
1871 | |
{ |
1872 | 0 | throw new NestedRuntimeException( e ); |
1873 | |
} |
1874 | |
} |
1875 | |
|
1876 | |
private Classpath getArtifactClasspath( Artifact surefireArtifact ) |
1877 | |
{ |
1878 | 0 | Classpath existing = ClasspathCache.getCachedClassPath( surefireArtifact.getArtifactId() ); |
1879 | 0 | if ( existing == null ) |
1880 | |
{ |
1881 | 0 | ArtifactResolutionResult result = resolveArtifact( null, surefireArtifact ); |
1882 | |
|
1883 | 0 | List<String> items = new ArrayList<String>(); |
1884 | 0 | for ( Object o : result.getArtifacts() ) |
1885 | |
{ |
1886 | 0 | Artifact artifact = (Artifact) o; |
1887 | |
|
1888 | 0 | getLog().debug( |
1889 | |
"Adding to " + getPluginName() + " booter test classpath: " + artifact.getFile().getAbsolutePath() + |
1890 | |
" Scope: " + artifact.getScope() ); |
1891 | |
|
1892 | 0 | items.add( artifact.getFile().getAbsolutePath() ); |
1893 | 0 | } |
1894 | 0 | existing = new Classpath( items ); |
1895 | 0 | ClasspathCache.setCachedClasspath( surefireArtifact.getArtifactId(), existing ); |
1896 | |
} |
1897 | 0 | return existing; |
1898 | |
} |
1899 | |
|
1900 | |
private Properties getUserProperties() |
1901 | |
{ |
1902 | 0 | Properties props = null; |
1903 | |
try |
1904 | |
{ |
1905 | |
|
1906 | 0 | Method getUserProperties = getSession().getClass().getMethod( "getUserProperties" ); |
1907 | 0 | props = (Properties) getUserProperties.invoke( getSession() ); |
1908 | |
} |
1909 | 0 | catch ( Exception e ) |
1910 | |
{ |
1911 | 0 | String msg = "Build uses Maven 2.0.x, cannot propagate system properties" |
1912 | |
+ " from command line to tests (cf. SUREFIRE-121)"; |
1913 | 0 | if ( getLog().isDebugEnabled() ) |
1914 | |
{ |
1915 | 0 | getLog().warn( msg, e ); |
1916 | |
} |
1917 | |
else |
1918 | |
{ |
1919 | 0 | getLog().warn( msg ); |
1920 | |
} |
1921 | 0 | } |
1922 | 0 | if ( props == null ) |
1923 | |
{ |
1924 | 0 | props = new Properties(); |
1925 | |
} |
1926 | 0 | return props; |
1927 | |
} |
1928 | |
|
1929 | |
|
1930 | |
void ensureWorkingDirectoryExists() |
1931 | |
throws MojoFailureException |
1932 | |
{ |
1933 | 0 | if ( getWorkingDirectory() == null ) |
1934 | |
{ |
1935 | 0 | throw new MojoFailureException( "workingDirectory cannot be null" ); |
1936 | |
} |
1937 | |
|
1938 | 0 | if ( !getWorkingDirectory().exists() ) |
1939 | |
{ |
1940 | 0 | if ( !getWorkingDirectory().mkdirs() ) |
1941 | |
{ |
1942 | 0 | throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() ); |
1943 | |
} |
1944 | |
} |
1945 | |
|
1946 | 0 | if ( !getWorkingDirectory().isDirectory() ) |
1947 | |
{ |
1948 | 0 | throw new MojoFailureException( |
1949 | |
"workingDirectory " + getWorkingDirectory() + " exists and is not a directory" ); |
1950 | |
} |
1951 | 0 | } |
1952 | |
|
1953 | |
void ensureParallelRunningCompatibility() |
1954 | |
throws MojoFailureException |
1955 | |
{ |
1956 | 0 | if ( isMavenParallel() && isNotForking() ) |
1957 | |
{ |
1958 | 0 | throw new MojoFailureException( "parallel maven execution is not compatible with surefire forkCount 0" ); |
1959 | |
} |
1960 | 0 | } |
1961 | |
|
1962 | |
void ensureThreadCountWithPerThread() |
1963 | |
throws MojoFailureException |
1964 | |
{ |
1965 | 0 | if ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) && getThreadCount() < 1 ) |
1966 | |
{ |
1967 | 0 | throw new MojoFailureException( "Fork mode perthread requires a thread count" ); |
1968 | |
} |
1969 | 0 | } |
1970 | |
|
1971 | |
void warnIfUselessUseSystemClassLoaderParameter() |
1972 | |
{ |
1973 | 0 | if ( isUseSystemClassLoader() && isNotForking() ) |
1974 | |
{ |
1975 | 0 | getLog().warn( "useSystemClassloader setting has no effect when not forking" ); |
1976 | |
} |
1977 | 0 | } |
1978 | |
|
1979 | |
private boolean isNotForking() |
1980 | |
{ |
1981 | 0 | return !isForking(); |
1982 | |
} |
1983 | |
|
1984 | |
void warnIfDefunctGroupsCombinations() |
1985 | |
throws MojoFailureException, MojoExecutionException |
1986 | |
{ |
1987 | 0 | if ( isAnyGroupsSelected() ) |
1988 | |
{ |
1989 | 0 | if ( getTestNgArtifact() != null ) |
1990 | |
{ |
1991 | 0 | return; |
1992 | |
} |
1993 | 0 | Artifact junitArtifact = getJunitArtifact(); |
1994 | 0 | boolean junit47Compatible = isJunit47Compatible( junitArtifact ); |
1995 | 0 | if ( junit47Compatible ) |
1996 | |
{ |
1997 | 0 | return; |
1998 | |
} |
1999 | 0 | if ( junitArtifact != null && !junit47Compatible ) |
2000 | |
{ |
2001 | 0 | throw new MojoFailureException( "groups/excludedGroups are specified but JUnit version on classpath" |
2002 | |
+ " is too old to support groups. Check your dependency:tree to see if your project is picking up an old junit version" ); |
2003 | |
} |
2004 | 0 | throw new MojoFailureException( |
2005 | |
"groups/excludedGroups require TestNG or JUnit48+ on project test classpath" ); |
2006 | |
|
2007 | |
} |
2008 | 0 | } |
2009 | |
|
2010 | |
class TestNgProviderInfo |
2011 | |
implements ProviderInfo |
2012 | |
{ |
2013 | |
private final Artifact testNgArtifact; |
2014 | |
|
2015 | |
TestNgProviderInfo( Artifact testNgArtifact ) |
2016 | 0 | { |
2017 | 0 | this.testNgArtifact = testNgArtifact; |
2018 | 0 | } |
2019 | |
|
2020 | |
public @Nonnull String getProviderName() |
2021 | |
{ |
2022 | 0 | return "org.apache.maven.surefire.testng.TestNGProvider"; |
2023 | |
} |
2024 | |
|
2025 | |
public boolean isApplicable() |
2026 | |
{ |
2027 | 0 | return testNgArtifact != null; |
2028 | |
} |
2029 | |
|
2030 | |
public void addProviderProperties() throws MojoExecutionException |
2031 | |
{ |
2032 | 0 | convertTestNGParameters(); |
2033 | 0 | } |
2034 | |
|
2035 | |
public Classpath getProviderClasspath() |
2036 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2037 | |
{ |
2038 | 0 | Artifact surefireArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); |
2039 | 0 | return dependencyResolver.getProviderClasspath( "surefire-testng", surefireArtifact.getBaseVersion(), |
2040 | |
testNgArtifact ); |
2041 | |
} |
2042 | |
} |
2043 | |
|
2044 | 0 | class JUnit3ProviderInfo |
2045 | |
implements ProviderInfo |
2046 | |
{ |
2047 | |
@Nonnull public String getProviderName() |
2048 | |
{ |
2049 | 0 | return "org.apache.maven.surefire.junit.JUnit3Provider"; |
2050 | |
} |
2051 | |
|
2052 | |
public boolean isApplicable() |
2053 | |
{ |
2054 | 0 | return true; |
2055 | |
} |
2056 | |
|
2057 | |
public void addProviderProperties() |
2058 | |
{ |
2059 | 0 | } |
2060 | |
|
2061 | |
public Classpath getProviderClasspath() |
2062 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2063 | |
{ |
2064 | |
|
2065 | |
|
2066 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit3", surefireBooterArtifact.getBaseVersion(), |
2067 | |
null ); |
2068 | |
|
2069 | |
} |
2070 | |
|
2071 | |
} |
2072 | |
|
2073 | |
class JUnit4ProviderInfo |
2074 | |
implements ProviderInfo |
2075 | |
{ |
2076 | |
private final Artifact junitArtifact; |
2077 | |
|
2078 | |
private final Artifact junitDepArtifact; |
2079 | |
|
2080 | |
JUnit4ProviderInfo( Artifact junitArtifact, Artifact junitDepArtifact ) |
2081 | 0 | { |
2082 | 0 | this.junitArtifact = junitArtifact; |
2083 | 0 | this.junitDepArtifact = junitDepArtifact; |
2084 | 0 | } |
2085 | |
|
2086 | |
@Nonnull public String getProviderName() |
2087 | |
{ |
2088 | 0 | return "org.apache.maven.surefire.junit4.JUnit4Provider"; |
2089 | |
} |
2090 | |
|
2091 | |
public boolean isApplicable() |
2092 | |
{ |
2093 | 0 | return junitDepArtifact != null || isAnyJunit4( junitArtifact ); |
2094 | |
} |
2095 | |
|
2096 | |
public void addProviderProperties() |
2097 | |
{ |
2098 | 0 | } |
2099 | |
|
2100 | |
public Classpath getProviderClasspath() |
2101 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2102 | |
{ |
2103 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit4", surefireBooterArtifact.getBaseVersion(), |
2104 | |
null ); |
2105 | |
|
2106 | |
} |
2107 | |
|
2108 | |
} |
2109 | |
|
2110 | |
class JUnitCoreProviderInfo |
2111 | |
implements ProviderInfo |
2112 | |
{ |
2113 | |
private final Artifact junitArtifact; |
2114 | |
|
2115 | |
private final Artifact junitDepArtifact; |
2116 | |
|
2117 | |
JUnitCoreProviderInfo( Artifact junitArtifact, Artifact junitDepArtifact ) |
2118 | 0 | { |
2119 | 0 | this.junitArtifact = junitArtifact; |
2120 | 0 | this.junitDepArtifact = junitDepArtifact; |
2121 | 0 | } |
2122 | |
|
2123 | |
@Nonnull public String getProviderName() |
2124 | |
{ |
2125 | 0 | return "org.apache.maven.surefire.junitcore.JUnitCoreProvider"; |
2126 | |
} |
2127 | |
|
2128 | |
private boolean is47CompatibleJunitDep() |
2129 | |
{ |
2130 | 0 | return junitDepArtifact != null && isJunit47Compatible( junitDepArtifact ); |
2131 | |
} |
2132 | |
|
2133 | |
public boolean isApplicable() |
2134 | |
{ |
2135 | 0 | final boolean isJunitArtifact47 = isAnyJunit4( junitArtifact ) && isJunit47Compatible( junitArtifact ); |
2136 | 0 | final boolean isAny47ProvidersForcers = isAnyConcurrencySelected() || isAnyGroupsSelected(); |
2137 | 0 | return isAny47ProvidersForcers && ( isJunitArtifact47 || is47CompatibleJunitDep() ); |
2138 | |
} |
2139 | |
|
2140 | |
public void addProviderProperties() |
2141 | |
{ |
2142 | 0 | convertJunitCoreParameters(); |
2143 | 0 | convertGroupParameters(); |
2144 | 0 | } |
2145 | |
|
2146 | |
public Classpath getProviderClasspath() |
2147 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2148 | |
{ |
2149 | 0 | return dependencyResolver.getProviderClasspath( "surefire-junit47", surefireBooterArtifact.getBaseVersion(), |
2150 | |
null ); |
2151 | |
} |
2152 | |
|
2153 | |
} |
2154 | |
|
2155 | 0 | public class DynamicProviderInfo |
2156 | |
implements ConfigurableProviderInfo |
2157 | |
{ |
2158 | |
final String providerName; |
2159 | |
|
2160 | |
DynamicProviderInfo( String providerName ) |
2161 | 0 | { |
2162 | 0 | this.providerName = providerName; |
2163 | 0 | } |
2164 | |
|
2165 | |
public ProviderInfo instantiate( String providerName ) |
2166 | |
{ |
2167 | 0 | return new DynamicProviderInfo( providerName ); |
2168 | |
} |
2169 | |
|
2170 | |
@Nonnull |
2171 | |
public String getProviderName() |
2172 | |
{ |
2173 | 0 | return providerName; |
2174 | |
} |
2175 | |
|
2176 | |
public boolean isApplicable() |
2177 | |
{ |
2178 | 0 | return true; |
2179 | |
} |
2180 | |
|
2181 | |
public void addProviderProperties() throws MojoExecutionException |
2182 | |
{ |
2183 | |
|
2184 | 0 | convertJunitCoreParameters(); |
2185 | 0 | convertTestNGParameters(); |
2186 | 0 | } |
2187 | |
|
2188 | |
|
2189 | |
public Classpath getProviderClasspath() |
2190 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
2191 | |
{ |
2192 | 0 | final Map<String, Artifact> pluginArtifactMap = getPluginArtifactMap(); |
2193 | 0 | Artifact plugin = pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" ); |
2194 | 0 | return dependencyResolver.addProviderToClasspath( pluginArtifactMap, plugin ); |
2195 | |
} |
2196 | |
|
2197 | |
} |
2198 | |
|
2199 | |
|
2200 | |
public abstract List<String> getIncludes(); |
2201 | |
|
2202 | |
public File getIncludesFile() |
2203 | |
{ |
2204 | 0 | return includesFile; |
2205 | |
} |
2206 | |
|
2207 | |
public abstract void setIncludes( List<String> includes ); |
2208 | |
|
2209 | |
public List<String> getExcludes() |
2210 | |
{ |
2211 | 0 | return excludes; |
2212 | |
} |
2213 | |
|
2214 | |
public File getExcludesFile() |
2215 | |
{ |
2216 | 0 | return excludesFile; |
2217 | |
} |
2218 | |
|
2219 | |
public void setExcludes( List<String> excludes ) |
2220 | |
{ |
2221 | 0 | this.excludes = excludes; |
2222 | 0 | } |
2223 | |
|
2224 | |
public ArtifactRepository getLocalRepository() |
2225 | |
{ |
2226 | 0 | return localRepository; |
2227 | |
} |
2228 | |
|
2229 | |
public void setLocalRepository( ArtifactRepository localRepository ) |
2230 | |
{ |
2231 | 0 | this.localRepository = localRepository; |
2232 | 0 | } |
2233 | |
|
2234 | |
|
2235 | |
|
2236 | |
|
2237 | |
public Properties getSystemProperties() |
2238 | |
{ |
2239 | 0 | return systemProperties; |
2240 | |
} |
2241 | |
|
2242 | |
@SuppressWarnings( { "UnusedDeclaration", "deprecation" } ) |
2243 | |
public void setSystemProperties( Properties systemProperties ) |
2244 | |
{ |
2245 | 0 | this.systemProperties = systemProperties; |
2246 | 0 | } |
2247 | |
|
2248 | |
public Map<String, String> getSystemPropertyVariables() |
2249 | |
{ |
2250 | 0 | return systemPropertyVariables; |
2251 | |
} |
2252 | |
|
2253 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2254 | |
public void setSystemPropertyVariables( Map<String, String> systemPropertyVariables ) |
2255 | |
{ |
2256 | 0 | this.systemPropertyVariables = systemPropertyVariables; |
2257 | 0 | } |
2258 | |
|
2259 | |
public File getSystemPropertiesFile() |
2260 | |
{ |
2261 | 0 | return systemPropertiesFile; |
2262 | |
} |
2263 | |
|
2264 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2265 | |
public void setSystemPropertiesFile( File systemPropertiesFile ) |
2266 | |
{ |
2267 | 0 | this.systemPropertiesFile = systemPropertiesFile; |
2268 | 0 | } |
2269 | |
|
2270 | |
public Properties getProperties() |
2271 | |
{ |
2272 | 0 | return properties; |
2273 | |
} |
2274 | |
|
2275 | |
public void setProperties( Properties properties ) |
2276 | |
{ |
2277 | 0 | this.properties = properties; |
2278 | 0 | } |
2279 | |
|
2280 | |
public Map<String, Artifact> getPluginArtifactMap() |
2281 | |
{ |
2282 | 0 | return pluginArtifactMap; |
2283 | |
} |
2284 | |
|
2285 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2286 | |
public void setPluginArtifactMap( Map<String, Artifact> pluginArtifactMap ) |
2287 | |
{ |
2288 | 0 | this.pluginArtifactMap = pluginArtifactMap; |
2289 | 0 | } |
2290 | |
|
2291 | |
public Map<String, Artifact> getProjectArtifactMap() |
2292 | |
{ |
2293 | 0 | return projectArtifactMap; |
2294 | |
} |
2295 | |
|
2296 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2297 | |
public void setProjectArtifactMap( Map<String, Artifact> projectArtifactMap ) |
2298 | |
{ |
2299 | 0 | this.projectArtifactMap = projectArtifactMap; |
2300 | 0 | } |
2301 | |
|
2302 | |
|
2303 | |
public String getReportNameSuffix() |
2304 | |
{ |
2305 | 0 | return reportNameSuffix; |
2306 | |
} |
2307 | |
|
2308 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2309 | |
public void setReportNameSuffix( String reportNameSuffix ) |
2310 | |
{ |
2311 | 0 | this.reportNameSuffix = reportNameSuffix; |
2312 | 0 | } |
2313 | |
|
2314 | |
|
2315 | |
public boolean isRedirectTestOutputToFile() |
2316 | |
{ |
2317 | 0 | return redirectTestOutputToFile; |
2318 | |
} |
2319 | |
|
2320 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2321 | |
public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile ) |
2322 | |
{ |
2323 | 0 | this.redirectTestOutputToFile = redirectTestOutputToFile; |
2324 | 0 | } |
2325 | |
|
2326 | |
|
2327 | |
public Boolean getFailIfNoTests() |
2328 | |
{ |
2329 | 0 | return failIfNoTests; |
2330 | |
} |
2331 | |
|
2332 | |
public void setFailIfNoTests( Boolean failIfNoTests ) |
2333 | |
{ |
2334 | 0 | this.failIfNoTests = failIfNoTests; |
2335 | 0 | } |
2336 | |
|
2337 | |
public String getForkMode() |
2338 | |
{ |
2339 | 0 | return forkMode; |
2340 | |
} |
2341 | |
|
2342 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2343 | |
public void setForkMode( String forkMode ) |
2344 | |
{ |
2345 | 0 | this.forkMode = forkMode; |
2346 | 0 | } |
2347 | |
|
2348 | |
public String getJvm() |
2349 | |
{ |
2350 | 0 | return jvm; |
2351 | |
} |
2352 | |
|
2353 | |
public String getArgLine() |
2354 | |
{ |
2355 | 0 | return argLine; |
2356 | |
} |
2357 | |
|
2358 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2359 | |
public void setArgLine( String argLine ) |
2360 | |
{ |
2361 | 0 | this.argLine = argLine; |
2362 | 0 | } |
2363 | |
|
2364 | |
|
2365 | |
public Map<String, String> getEnvironmentVariables() |
2366 | |
{ |
2367 | 0 | return environmentVariables; |
2368 | |
} |
2369 | |
|
2370 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2371 | |
public void setEnvironmentVariables( Map<String, String> environmentVariables ) |
2372 | |
{ |
2373 | 0 | this.environmentVariables = environmentVariables; |
2374 | 0 | } |
2375 | |
|
2376 | |
public File getWorkingDirectory() |
2377 | |
{ |
2378 | 0 | return workingDirectory; |
2379 | |
} |
2380 | |
|
2381 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2382 | |
public void setWorkingDirectory( File workingDirectory ) |
2383 | |
{ |
2384 | 0 | this.workingDirectory = workingDirectory; |
2385 | 0 | } |
2386 | |
|
2387 | |
public boolean isChildDelegation() |
2388 | |
{ |
2389 | 0 | return childDelegation; |
2390 | |
} |
2391 | |
|
2392 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2393 | |
public void setChildDelegation( boolean childDelegation ) |
2394 | |
{ |
2395 | 0 | this.childDelegation = childDelegation; |
2396 | 0 | } |
2397 | |
|
2398 | |
public String getGroups() |
2399 | |
{ |
2400 | 0 | return groups; |
2401 | |
} |
2402 | |
|
2403 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2404 | |
public void setGroups( String groups ) |
2405 | |
{ |
2406 | 0 | this.groups = groups; |
2407 | 0 | } |
2408 | |
|
2409 | |
public String getExcludedGroups() |
2410 | |
{ |
2411 | 0 | return excludedGroups; |
2412 | |
} |
2413 | |
|
2414 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2415 | |
public void setExcludedGroups( String excludedGroups ) |
2416 | |
{ |
2417 | 0 | this.excludedGroups = excludedGroups; |
2418 | 0 | } |
2419 | |
|
2420 | |
public File[] getSuiteXmlFiles() |
2421 | |
{ |
2422 | 0 | return suiteXmlFiles; |
2423 | |
} |
2424 | |
|
2425 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2426 | |
public void setSuiteXmlFiles( File[] suiteXmlFiles ) |
2427 | |
{ |
2428 | 0 | this.suiteXmlFiles = suiteXmlFiles; |
2429 | 0 | } |
2430 | |
|
2431 | |
public String getJunitArtifactName() |
2432 | |
{ |
2433 | 0 | return junitArtifactName; |
2434 | |
} |
2435 | |
|
2436 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2437 | |
public void setJunitArtifactName( String junitArtifactName ) |
2438 | |
{ |
2439 | 0 | this.junitArtifactName = junitArtifactName; |
2440 | 0 | } |
2441 | |
|
2442 | |
public String getTestNGArtifactName() |
2443 | |
{ |
2444 | 0 | return testNGArtifactName; |
2445 | |
} |
2446 | |
|
2447 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2448 | |
public void setTestNGArtifactName( String testNGArtifactName ) |
2449 | |
{ |
2450 | 0 | this.testNGArtifactName = testNGArtifactName; |
2451 | 0 | } |
2452 | |
|
2453 | |
public int getThreadCount() |
2454 | |
{ |
2455 | 0 | return threadCount; |
2456 | |
} |
2457 | |
|
2458 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2459 | |
public void setThreadCount( int threadCount ) |
2460 | |
{ |
2461 | 0 | this.threadCount = threadCount; |
2462 | 0 | } |
2463 | |
|
2464 | |
public boolean getPerCoreThreadCount() |
2465 | |
{ |
2466 | 0 | return perCoreThreadCount; |
2467 | |
} |
2468 | |
|
2469 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2470 | |
public void setPerCoreThreadCount( boolean perCoreThreadCount ) |
2471 | |
{ |
2472 | 0 | this.perCoreThreadCount = perCoreThreadCount; |
2473 | 0 | } |
2474 | |
|
2475 | |
public boolean getUseUnlimitedThreads() |
2476 | |
{ |
2477 | 0 | return useUnlimitedThreads; |
2478 | |
} |
2479 | |
|
2480 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2481 | |
public void setUseUnlimitedThreads( boolean useUnlimitedThreads ) |
2482 | |
{ |
2483 | 0 | this.useUnlimitedThreads = useUnlimitedThreads; |
2484 | 0 | } |
2485 | |
|
2486 | |
public String getParallel() |
2487 | |
{ |
2488 | 0 | return parallel; |
2489 | |
} |
2490 | |
|
2491 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2492 | |
public void setParallel( String parallel ) |
2493 | |
{ |
2494 | 0 | this.parallel = parallel; |
2495 | 0 | } |
2496 | |
|
2497 | |
public boolean isTrimStackTrace() |
2498 | |
{ |
2499 | 0 | return trimStackTrace; |
2500 | |
} |
2501 | |
|
2502 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2503 | |
public void setTrimStackTrace( boolean trimStackTrace ) |
2504 | |
{ |
2505 | 0 | this.trimStackTrace = trimStackTrace; |
2506 | 0 | } |
2507 | |
|
2508 | |
public ArtifactResolver getArtifactResolver() |
2509 | |
{ |
2510 | 0 | return artifactResolver; |
2511 | |
} |
2512 | |
|
2513 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2514 | |
public void setArtifactResolver( ArtifactResolver artifactResolver ) |
2515 | |
{ |
2516 | 0 | this.artifactResolver = artifactResolver; |
2517 | 0 | } |
2518 | |
|
2519 | |
public ArtifactFactory getArtifactFactory() |
2520 | |
{ |
2521 | 0 | return artifactFactory; |
2522 | |
} |
2523 | |
|
2524 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2525 | |
public void setArtifactFactory( ArtifactFactory artifactFactory ) |
2526 | |
{ |
2527 | 0 | this.artifactFactory = artifactFactory; |
2528 | 0 | } |
2529 | |
|
2530 | |
public List<ArtifactRepository> getRemoteRepositories() |
2531 | |
{ |
2532 | 0 | return remoteRepositories; |
2533 | |
} |
2534 | |
|
2535 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2536 | |
public void setRemoteRepositories( List<ArtifactRepository> remoteRepositories ) |
2537 | |
{ |
2538 | 0 | this.remoteRepositories = remoteRepositories; |
2539 | 0 | } |
2540 | |
|
2541 | |
public ArtifactMetadataSource getMetadataSource() |
2542 | |
{ |
2543 | 0 | return metadataSource; |
2544 | |
} |
2545 | |
|
2546 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2547 | |
public void setMetadataSource( ArtifactMetadataSource metadataSource ) |
2548 | |
{ |
2549 | 0 | this.metadataSource = metadataSource; |
2550 | 0 | } |
2551 | |
|
2552 | |
|
2553 | |
public boolean isDisableXmlReport() |
2554 | |
{ |
2555 | 0 | return disableXmlReport; |
2556 | |
} |
2557 | |
|
2558 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2559 | |
public void setDisableXmlReport( boolean disableXmlReport ) |
2560 | |
{ |
2561 | 0 | this.disableXmlReport = disableXmlReport; |
2562 | 0 | } |
2563 | |
|
2564 | |
|
2565 | |
public boolean isEnableAssertions() |
2566 | |
{ |
2567 | 0 | return enableAssertions; |
2568 | |
} |
2569 | |
|
2570 | |
public boolean effectiveIsEnableAssertions() |
2571 | |
{ |
2572 | 0 | if ( getArgLine() != null ) |
2573 | |
{ |
2574 | 0 | List<String> args = Arrays.asList( getArgLine().split( " " ) ); |
2575 | 0 | if ( args.contains( "-da" ) || args.contains( "-disableassertions" ) ) |
2576 | |
{ |
2577 | 0 | return false; |
2578 | |
} |
2579 | |
} |
2580 | 0 | return isEnableAssertions(); |
2581 | |
} |
2582 | |
|
2583 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2584 | |
public void setEnableAssertions( boolean enableAssertions ) |
2585 | |
{ |
2586 | 0 | this.enableAssertions = enableAssertions; |
2587 | 0 | } |
2588 | |
|
2589 | |
public MavenSession getSession() |
2590 | |
{ |
2591 | 0 | return session; |
2592 | |
} |
2593 | |
|
2594 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2595 | |
public void setSession( MavenSession session ) |
2596 | |
{ |
2597 | 0 | this.session = session; |
2598 | 0 | } |
2599 | |
|
2600 | |
public String getObjectFactory() |
2601 | |
{ |
2602 | 0 | return objectFactory; |
2603 | |
} |
2604 | |
|
2605 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2606 | |
public void setObjectFactory( String objectFactory ) |
2607 | |
{ |
2608 | 0 | this.objectFactory = objectFactory; |
2609 | 0 | } |
2610 | |
|
2611 | |
public ToolchainManager getToolchainManager() |
2612 | |
{ |
2613 | 0 | return toolchainManager; |
2614 | |
} |
2615 | |
|
2616 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2617 | |
public void setToolchainManager( ToolchainManager toolchainManager ) |
2618 | |
{ |
2619 | 0 | this.toolchainManager = toolchainManager; |
2620 | 0 | } |
2621 | |
|
2622 | |
public boolean isMavenParallel() |
2623 | |
{ |
2624 | 0 | return parallelMavenExecution != null && parallelMavenExecution; |
2625 | |
} |
2626 | |
|
2627 | |
public String getRunOrder() |
2628 | |
{ |
2629 | 0 | return runOrder; |
2630 | |
} |
2631 | |
|
2632 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2633 | |
public void setRunOrder( String runOrder ) |
2634 | |
{ |
2635 | 0 | this.runOrder = runOrder; |
2636 | 0 | } |
2637 | |
|
2638 | |
public String[] getDependenciesToScan() |
2639 | |
{ |
2640 | 0 | return dependenciesToScan; |
2641 | |
} |
2642 | |
|
2643 | |
public void setDependenciesToScan( String[] dependenciesToScan ) |
2644 | |
{ |
2645 | 0 | this.dependenciesToScan = dependenciesToScan; |
2646 | 0 | } |
2647 | |
|
2648 | |
public PluginDescriptor getPluginDescriptor() |
2649 | |
{ |
2650 | 0 | return pluginDescriptor; |
2651 | |
} |
2652 | |
|
2653 | |
public MavenProject getProject() |
2654 | |
{ |
2655 | 0 | return project; |
2656 | |
} |
2657 | |
|
2658 | |
@SuppressWarnings( "UnusedDeclaration" ) |
2659 | |
public void setProject( MavenProject project ) |
2660 | |
{ |
2661 | 0 | this.project = project; |
2662 | 0 | } |
2663 | |
|
2664 | |
public File getTestSourceDirectory() |
2665 | |
{ |
2666 | 0 | return testSourceDirectory; |
2667 | |
} |
2668 | |
|
2669 | |
public void setTestSourceDirectory( File testSourceDirectory ) |
2670 | |
{ |
2671 | 0 | this.testSourceDirectory = testSourceDirectory; |
2672 | 0 | } |
2673 | |
|
2674 | |
public String getForkCount() |
2675 | |
{ |
2676 | 0 | return forkCount; |
2677 | |
} |
2678 | |
|
2679 | |
public boolean isReuseForks() |
2680 | |
{ |
2681 | 0 | return reuseForks; |
2682 | |
} |
2683 | |
|
2684 | |
public String[] getAdditionalClasspathElements() |
2685 | |
{ |
2686 | 0 | return additionalClasspathElements; |
2687 | |
} |
2688 | |
|
2689 | |
public void setAdditionalClasspathElements( String[] additionalClasspathElements ) |
2690 | |
{ |
2691 | 0 | this.additionalClasspathElements = additionalClasspathElements; |
2692 | 0 | } |
2693 | |
|
2694 | |
public String[] getClasspathDependencyExcludes() |
2695 | |
{ |
2696 | 0 | return classpathDependencyExcludes; |
2697 | |
} |
2698 | |
|
2699 | |
public void setClasspathDependencyExcludes( String[] classpathDependencyExcludes ) |
2700 | |
{ |
2701 | 0 | this.classpathDependencyExcludes = classpathDependencyExcludes; |
2702 | 0 | } |
2703 | |
|
2704 | |
public String getClasspathDependencyScopeExclude() |
2705 | |
{ |
2706 | 0 | return classpathDependencyScopeExclude; |
2707 | |
} |
2708 | |
|
2709 | |
public void setClasspathDependencyScopeExclude( String classpathDependencyScopeExclude ) |
2710 | |
{ |
2711 | 0 | this.classpathDependencyScopeExclude = classpathDependencyScopeExclude; |
2712 | 0 | } |
2713 | |
} |