1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.codehaus.mojo.jaxws;
37
38 import java.io.File;
39
40 import org.apache.maven.plugin.MojoExecutionException;
41 import org.apache.maven.plugin.MojoFailureException;
42 import org.apache.maven.plugins.annotations.LifecyclePhase;
43 import org.apache.maven.plugins.annotations.Mojo;
44 import org.apache.maven.plugins.annotations.Parameter;
45 import org.apache.maven.plugins.annotations.ResolutionScope;
46
47
48
49
50
51
52
53
54
55
56
57 @Mojo( name = "wsgen-test", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES,
58 requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
59 public class TestWsGenMojo
60 extends AbstractWsGenMojo
61 {
62
63
64
65
66
67 @Parameter( defaultValue = "${project.build.testOutputDirectory}" )
68 private File destDir;
69
70
71
72
73 @Parameter( defaultValue = "${project.build.directory}/generated-sources/test-wsgen" )
74 private File sourceDestDir;
75
76
77
78
79 @Parameter( defaultValue = "${project.build.directory}/generated-sources/test-wsdl" )
80 private File resourceDestDir;
81
82
83
84
85 @Parameter( property = "maven.test.skip" )
86 private boolean skip;
87
88
89
90
91 @Override
92 protected File getDestDir()
93 {
94 return destDir;
95 }
96
97
98
99
100 @Override
101 protected File getSourceDestDir()
102 {
103 return sourceDestDir;
104 }
105
106 @Override
107 protected void addSourceRoot( String sourceDir )
108 {
109 if ( !project.getTestCompileSourceRoots().contains( sourceDir ) )
110 {
111 getLog().debug( "adding test src root: " + sourceDir );
112 project.addTestCompileSourceRoot( sourceDir );
113 }
114 else
115 {
116 getLog().debug( "existing test src root: " + sourceDir );
117 }
118 }
119
120 @Override
121 protected File getResourceDestDir()
122 {
123 return resourceDestDir;
124 }
125
126 @Override
127 protected File getDefaultSrcOut()
128 {
129 return new File( project.getBuild().getDirectory(), "generated-sources/test-wsgen" );
130 }
131
132 @Override
133 protected File getClassesDir()
134 {
135 return new File( project.getBuild().getTestOutputDirectory() );
136 }
137
138 @Override
139 protected String getExtraClasspath()
140 {
141 String cp = super.getExtraClasspath();
142 StringBuilder buf = new StringBuilder();
143 int i = cp.indexOf( File.pathSeparatorChar );
144 buf.append( i > 0 ? cp.substring( 0, i ) : cp );
145 buf.append( File.pathSeparatorChar );
146 buf.append( project.getBuild().getOutputDirectory() );
147 if ( i > 0 && cp.substring( i ).length() > 0 )
148 {
149 buf.append( cp.substring( i ) );
150 }
151 return buf.toString();
152 }
153
154 @Override
155 public void executeJaxws()
156 throws MojoExecutionException, MojoFailureException
157 {
158
159
160 if ( skip )
161 {
162 getLog().info( "Skipping tests, nothing to do." );
163 }
164 else
165 {
166 super.executeJaxws();
167 }
168 }
169 }