1 package org.codehaus.mojo.weblogic;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.maven.plugin.MojoExecutionException;
20 import org.apache.tools.ant.Project;
21 import org.apache.tools.ant.types.Path;
22 import org.codehaus.mojo.weblogic.util.WeblogicMojoUtilities;
23 import weblogic.wsee.tools.anttasks.JwsFileSet;
24 import weblogic.wsee.tools.anttasks.JwsModule.Descriptor;
25 import weblogic.wsee.tools.anttasks.JwscTask;
26 import weblogic.wsee.tools.anttasks.MultipleJwsModule;
27
28 import java.io.File;
29 import java.util.Iterator;
30
31
32
33
34
35
36
37
38
39
40
41 public class JwscMojo
42 extends AbstractWeblogicMojo
43 {
44
45
46
47
48
49
50 private String outputDir;
51
52
53
54
55
56
57 private String inputDir;
58
59
60
61
62
63
64
65 private String outputName;
66
67
68
69
70
71
72 private boolean verbose;
73
74
75
76
77
78
79 private boolean debug;
80
81
82
83
84
85
86 private boolean explode;
87
88
89
90
91
92
93 private boolean optimize;
94
95
96
97
98
99
100
101 private String contextPath;
102
103
104
105
106
107
108
109 private String descriptor;
110
111
112
113
114
115
116 public void execute()
117 throws MojoExecutionException
118 {
119 super.execute();
120 if ( getLog().isInfoEnabled() )
121 {
122 getLog().info( "Weblogic jwsc beginning for output " + this.outputName );
123 }
124 if ( getLog().isDebugEnabled() )
125 {
126 getLog().debug( "inputDir=" + this.inputDir + " contextPath=" + this.contextPath );
127 }
128 if ( this.contextPath == null )
129 {
130 getLog().warn( "Context path is null. It will be required if " + "more than one web service is present." );
131 }
132 try
133 {
134 Iterator iter = getDependencies().iterator();
135 while ( iter.hasNext() )
136 {
137 getLog().debug( iter.next().toString() );
138 }
139 final JwscTask task = new JwscTask();
140 final Project project = new Project();
141 project.addBuildListener( getDefaultLogger() );
142 project.setName( "jwsc" );
143 final Path path = new Path( project, WeblogicMojoUtilities
144 .getDependencies( this.getArtifacts(), this.getPluginArtifacts() ) );
145 if ( getLog().isDebugEnabled() )
146 {
147 getLog().debug( "Path=" + path.toString() );
148 }
149 task.setProject( project );
150 task.setTaskName( project.getName() );
151 task.setNowarn( false );
152
153 task.setClasspath( path );
154 task.setDestdir( new File( this.outputDir ) );
155 task.setVerbose( this.verbose );
156 task.setOptimize( this.optimize );
157 task.setDebug( this.debug );
158 task.setSrcdir( new File( this.inputDir ) );
159 final MultipleJwsModule module = task.createModule();
160 final JwsFileSet jwsFileSet = module.createJwsFileSet();
161 jwsFileSet.setProject( project );
162 jwsFileSet.setSrcdir( new Path( project, this.inputDir ) );
163 if ( getLog().isInfoEnabled() )
164 {
165 getLog().info( "fileset=" + jwsFileSet.getSrcdir().toString() );
166 }
167 if ( this.descriptor != null )
168 {
169 final Descriptor descriptor = module.createDescriptor();
170 descriptor.setFile( new File( this.descriptor ) );
171 }
172 module.setName( this.outputName );
173 module.setExplode( this.explode );
174 module.setContextPath( this.contextPath );
175 task.execute();
176 }
177 catch ( Exception ex )
178 {
179 getLog().error( "Exception encountered during jwsc", ex );
180 throw new MojoExecutionException( "Exception encountered during jwsc", ex );
181 }
182 }
183
184
185
186
187 public String getOutputName()
188 {
189 return outputName;
190 }
191
192
193
194
195 public void setOutputName( String outputName )
196 {
197 this.outputName = outputName;
198 }
199
200
201
202
203 public String getOutputDir()
204 {
205 return outputDir;
206 }
207
208
209
210
211 public void setOutputDir( String outputDir )
212 {
213 this.outputDir = outputDir;
214 }
215
216
217
218
219
220
221 public String getInputDir()
222 {
223 return inputDir;
224 }
225
226
227
228
229
230
231 public void setInputDir( String inputDir )
232 {
233 this.inputDir = inputDir;
234 }
235
236
237
238
239
240
241 public boolean isVerbose()
242 {
243 return verbose;
244 }
245
246
247
248
249 public void setVerbose( boolean verbose )
250 {
251 this.verbose = verbose;
252 }
253
254
255
256
257 public boolean isDebug()
258 {
259 return debug;
260 }
261
262
263
264
265 public void setDebug( boolean debug )
266 {
267 this.debug = debug;
268 }
269
270
271
272
273 public boolean isExplode()
274 {
275 return explode;
276 }
277
278
279
280
281 public void setExplode( boolean explode )
282 {
283 this.explode = explode;
284 }
285
286
287
288
289 public boolean isOptimize()
290 {
291 return optimize;
292 }
293
294
295
296
297 public void setOptimize( boolean optimize )
298 {
299 this.optimize = optimize;
300 }
301
302
303
304
305 public String getContextPath()
306 {
307 return contextPath;
308 }
309
310
311
312
313 public void setContextPath( String contextPath )
314 {
315 this.contextPath = contextPath;
316 }
317
318
319
320
321 public String getDescriptor()
322 {
323 return descriptor;
324 }
325
326
327
328
329 public void setDescriptor( String descriptor )
330 {
331 this.descriptor = descriptor;
332 }
333
334
335
336
337
338
339 public String toString()
340 {
341 return "JwscMojo{" + "outputDir='" + outputDir + '\'' + ", inputDir='" + inputDir + '\'' + ", outputName='" +
342 outputName + '\'' + ", verbose=" + verbose + ", debug=" + debug + ", explode=" + explode + ", optimize=" +
343 optimize + ", contextPath='" + contextPath + '\'' + ", descriptor='" + descriptor + '\'' + '}';
344 }
345 }