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
37 package org.codehaus.mojo.jaxws;
38
39 import java.io.File;
40 import java.util.List;
41 import java.util.stream.Collectors;
42
43 import org.apache.maven.artifact.Artifact;
44 import org.apache.maven.plugin.MojoExecutionException;
45 import org.apache.maven.plugins.annotations.LifecyclePhase;
46 import org.apache.maven.plugins.annotations.Mojo;
47 import org.apache.maven.plugins.annotations.Parameter;
48 import org.apache.maven.plugins.annotations.ResolutionScope;
49
50
51
52
53
54
55
56
57
58
59
60 @Mojo( name = "wsimport-test", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES,
61 requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
62 public class TestWsImportMojo
63 extends WsImportMojo
64 {
65
66
67
68
69
70 @Parameter( defaultValue = "${project.build.testOutputDirectory}" )
71 private File destDir;
72
73
74
75
76 @Parameter( defaultValue = "${project.build.directory}/generated-sources/test-wsimport" )
77 private File sourceDestDir;
78
79
80
81
82 @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
83 private File implDestDir;
84
85
86
87
88 @Parameter( property = "maven.test.skip" )
89 private boolean skip;
90
91
92
93
94 @Override
95 protected File getDestDir()
96 {
97 return destDir;
98 }
99
100
101
102
103 @Override
104 protected File getSourceDestDir()
105 {
106 return sourceDestDir;
107 }
108
109 @Override
110 protected void addSourceRoot( String sourceDir )
111 {
112 if ( !project.getTestCompileSourceRoots().contains( sourceDir ) )
113 {
114 getLog().debug( "adding test src root: " + sourceDir );
115 project.addTestCompileSourceRoot( sourceDir );
116 }
117 else
118 {
119 getLog().debug( "existing test src root: " + sourceDir );
120 }
121 }
122
123 @Override
124 protected File getDefaultSrcOut()
125 {
126 return new File( project.getBuild().getDirectory(), "generated-sources/test-wsimport" );
127 }
128
129 @Override
130 protected File getImplDestDir()
131 {
132 return implDestDir;
133 }
134
135 @Override
136 protected List<String> getWSDLFileLookupClasspathElements()
137 {
138 return project.getDependencyArtifacts().stream()
139 .filter( a -> !Artifact.SCOPE_RUNTIME.equals(a.getScope() )
140 && null != a.getFile() )
141 .map( a -> a.getFile().getPath() ).collect( Collectors.toList() );
142 }
143
144 @Override
145 public void executeJaxws()
146 throws MojoExecutionException
147 {
148
149
150 if ( skip )
151 {
152 getLog().info( "Skipping tests, nothing to do." );
153 }
154 else
155 {
156 super.executeJaxws();
157 }
158 }
159 }