1 | |
package org.apache.maven.model.converter.plugins; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.model.converter.ProjectConverterException; |
23 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
24 | |
|
25 | |
import java.util.Iterator; |
26 | |
import java.util.List; |
27 | |
import java.util.Properties; |
28 | |
import java.util.StringTokenizer; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 4 | public class PCCSurefire |
38 | |
extends AbstractPluginConfigurationConverter |
39 | |
{ |
40 | |
|
41 | |
|
42 | |
|
43 | |
public String getArtifactId() |
44 | |
{ |
45 | 0 | return "maven-surefire-plugin"; |
46 | |
} |
47 | |
|
48 | |
public String getType() |
49 | |
{ |
50 | 0 | return TYPE_BUILD_PLUGIN; |
51 | |
} |
52 | |
|
53 | |
protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model, |
54 | |
Properties projectProperties ) |
55 | |
throws ProjectConverterException |
56 | |
{ |
57 | 4 | addConfigurationChild( configuration, projectProperties, "maven.junit.jvmargs", "argLine" ); |
58 | |
|
59 | 4 | String forkMode = projectProperties.getProperty( "maven.junit.forkmode" ); |
60 | 4 | if ( forkMode == null ) |
61 | |
{ |
62 | 2 | String fork = projectProperties.getProperty( "maven.junit.fork" ); |
63 | 2 | if ( fork != null ) |
64 | |
{ |
65 | 2 | boolean useFork = Boolean.valueOf( PropertyUtils.convertYesNoToBoolean( fork ) ).booleanValue(); |
66 | 2 | if ( useFork ) |
67 | |
{ |
68 | |
|
69 | 2 | addConfigurationChild( configuration, "forkMode", "once" ); |
70 | |
} |
71 | |
} |
72 | |
} |
73 | |
else |
74 | |
{ |
75 | 2 | addConfigurationChild( configuration, projectProperties, "maven.junit.forkmode", "forkMode" ); |
76 | |
} |
77 | |
|
78 | 4 | addConfigurationChild( configuration, projectProperties, "maven.junit.jvm", "jvm" ); |
79 | |
|
80 | 4 | addConfigurationChild( configuration, projectProperties, "maven.junit.printSummary", "printSummary" ); |
81 | |
|
82 | 4 | addConfigurationChild( configuration, projectProperties, "maven.junit.format", "reportFormat" ); |
83 | |
|
84 | 4 | addConfigurationChild( configuration, projectProperties, "maven.test.skip", "skip" ); |
85 | |
|
86 | 4 | String sysproperties = projectProperties.getProperty( "maven.junit.sysproperties" ); |
87 | 4 | if ( sysproperties != null ) |
88 | |
{ |
89 | 2 | StringTokenizer tokenizer = new StringTokenizer( sysproperties ); |
90 | 2 | if ( tokenizer.hasMoreTokens() ) |
91 | |
{ |
92 | 2 | Xpp3Dom systemProperties = new Xpp3Dom( "systemProperties" ); |
93 | 6 | while ( tokenizer.hasMoreTokens() ) |
94 | |
{ |
95 | 4 | String name = tokenizer.nextToken(); |
96 | 4 | String value = projectProperties.getProperty( name ); |
97 | 4 | addConfigurationChild( systemProperties, name, value ); |
98 | |
} |
99 | 2 | if ( systemProperties.getChildCount() > 0 ) |
100 | |
{ |
101 | 2 | configuration.addChild( systemProperties ); |
102 | |
} |
103 | |
} |
104 | |
} |
105 | |
|
106 | 4 | addConfigurationChild( configuration, projectProperties, "maven.test.failure.ignore", "testFailureIgnore" ); |
107 | |
|
108 | 4 | addConfigurationChild( configuration, projectProperties, "maven.junit.usefile", "useFile" ); |
109 | |
|
110 | 4 | if ( v3Model.getBuild() != null && v3Model.getBuild().getUnitTest() != null ) |
111 | |
{ |
112 | 4 | org.apache.maven.model.v3_0_0.UnitTest v3UnitTest = v3Model.getBuild().getUnitTest(); |
113 | |
|
114 | 4 | List excludes = v3UnitTest.getExcludes(); |
115 | 4 | if ( excludes != null && excludes.size() > 0 ) |
116 | |
{ |
117 | 0 | Xpp3Dom excludesConf = new Xpp3Dom( "excludes" ); |
118 | 0 | for ( Iterator iter = excludes.iterator(); iter.hasNext(); ) |
119 | |
{ |
120 | 0 | addConfigurationChild( excludesConf, "exclude", (String) iter.next() ); |
121 | |
} |
122 | 0 | configuration.addChild( excludesConf ); |
123 | |
} |
124 | |
|
125 | 4 | List includes = v3UnitTest.getIncludes(); |
126 | 4 | if ( includes != null && includes.size() > 0 ) |
127 | |
{ |
128 | 0 | Xpp3Dom includesConf = new Xpp3Dom( "includes" ); |
129 | 0 | for ( Iterator iter = includes.iterator(); iter.hasNext(); ) |
130 | |
{ |
131 | 0 | addConfigurationChild( includesConf, "include", (String) iter.next() ); |
132 | |
} |
133 | 0 | configuration.addChild( includesConf ); |
134 | |
} |
135 | |
} |
136 | 4 | } |
137 | |
} |