Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EclipseWriterConfig |
|
| 1.0238095238095237;1.024 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.maven.plugin.eclipse.writers; | |
20 | ||
21 | import java.io.File; | |
22 | import java.util.Arrays; | |
23 | import java.util.Comparator; | |
24 | import java.util.List; | |
25 | import java.util.Map; | |
26 | ||
27 | import org.apache.maven.artifact.repository.ArtifactRepository; | |
28 | import org.apache.maven.plugin.eclipse.EclipsePlugin; | |
29 | import org.apache.maven.plugin.eclipse.EclipseSourceDir; | |
30 | import org.apache.maven.plugin.ide.IdeDependency; | |
31 | import org.apache.maven.project.MavenProject; | |
32 | ||
33 | /** | |
34 | * @author Fabrizio Giustina | |
35 | * @version $Id: EclipseWriterConfig.java 599684 2007-11-30 03:02:08Z aheritier $ | |
36 | */ | |
37 | 2 | public class EclipseWriterConfig |
38 | { | |
39 | /** | |
40 | * The maven project. | |
41 | */ | |
42 | private MavenProject project; | |
43 | ||
44 | /** | |
45 | * The maven project packaging. | |
46 | */ | |
47 | private String packaging; | |
48 | ||
49 | /** | |
50 | * Eclipse project dir. | |
51 | */ | |
52 | private File eclipseProjectDirectory; | |
53 | ||
54 | /** | |
55 | * The name of the project in eclipse. | |
56 | */ | |
57 | private String eclipseProjectName; | |
58 | ||
59 | /** | |
60 | * Base project dir. | |
61 | */ | |
62 | private File projectBaseDir; | |
63 | ||
64 | /** | |
65 | * List of IDE dependencies. | |
66 | */ | |
67 | 2 | private IdeDependency[] deps = new IdeDependency[0]; |
68 | ||
69 | /** | |
70 | * List of IDE dependencies ordered. | |
71 | */ | |
72 | 2 | private IdeDependency[] orderedDeps = new IdeDependency[0]; |
73 | ||
74 | /** | |
75 | * Source directories. | |
76 | */ | |
77 | private EclipseSourceDir[] sourceDirs; | |
78 | ||
79 | /** | |
80 | * Local maven repo. | |
81 | */ | |
82 | private ArtifactRepository localRepository; | |
83 | ||
84 | /** | |
85 | * Build output directory for eclipse. | |
86 | */ | |
87 | private File buildOutputDirectory; | |
88 | ||
89 | /** | |
90 | * Manifest file. | |
91 | */ | |
92 | private File manifestFile; | |
93 | ||
94 | /** | |
95 | * PDE mode. | |
96 | */ | |
97 | private boolean pde; | |
98 | ||
99 | /** | |
100 | * Project natures. | |
101 | */ | |
102 | private List projectnatures; | |
103 | ||
104 | /** | |
105 | * Project facets. | |
106 | */ | |
107 | private Map projectFacets; | |
108 | ||
109 | /** | |
110 | * Build commands. List<BuildCommand> | |
111 | */ | |
112 | private List buildCommands; | |
113 | ||
114 | /** | |
115 | * Classpath containers. | |
116 | */ | |
117 | private List classpathContainers; | |
118 | ||
119 | /** | |
120 | * Appends the version number to the project name if <tt>true</tt>. | |
121 | * | |
122 | * @deprecated use {@link #projectNameTemplate} | |
123 | */ | |
124 | private boolean addVersionToProjectName; | |
125 | ||
126 | /** | |
127 | * @see EclipsePlugin#getProjectNameTemplate() | |
128 | */ | |
129 | private String projectNameTemplate; | |
130 | ||
131 | /** | |
132 | * @see EclipsePlugin#deployName() | |
133 | */ | |
134 | ||
135 | private String contextName; | |
136 | ||
137 | /** | |
138 | * @see EclipsePlugin#wtpapplicationxml() | |
139 | */ | |
140 | private boolean wtpapplicationxml; | |
141 | ||
142 | /** | |
143 | * @see EclipsePlugin#getWtpversion() | |
144 | */ | |
145 | private float wtpVersion; | |
146 | ||
147 | /** | |
148 | * Getter for <code>deps</code>. | |
149 | * | |
150 | * @return Returns the deps. | |
151 | */ | |
152 | public IdeDependency[] getDeps() | |
153 | { | |
154 | return this.deps; | |
155 | } | |
156 | ||
157 | /** | |
158 | * Setter for <code>deps</code>. | |
159 | * | |
160 | * @param deps The deps to set. | |
161 | */ | |
162 | public void setDeps( IdeDependency[] deps ) | |
163 | { | |
164 | this.deps = deps; | |
165 | if ( deps != null ) | |
166 | { | |
167 | // TODO get the right comparator depending on orderDependencies={name,nearness..}; | |
168 | // if none specified it could use a NullComparator to reduce the number of | |
169 | // conditions that have to be checked | |
170 | Comparator depsByArtifactId = new Comparator() | |
171 | { | |
172 | public int compare( Object o1, Object o2 ) | |
173 | { | |
174 | return ( (IdeDependency) o1 ).getArtifactId().compareToIgnoreCase( | |
175 | ( (IdeDependency) o2 ).getArtifactId() ); | |
176 | } | |
177 | }; | |
178 | ||
179 | orderedDeps = new IdeDependency[deps.length]; | |
180 | System.arraycopy( deps, 0, orderedDeps, 0, deps.length ); | |
181 | Arrays.sort( orderedDeps, depsByArtifactId ); | |
182 | } | |
183 | } | |
184 | ||
185 | /** | |
186 | * Getter for <code>eclipseProjectDir</code>. | |
187 | * | |
188 | * @return Returns the eclipseProjectDir. | |
189 | */ | |
190 | public File getEclipseProjectDirectory() | |
191 | { | |
192 | 3 | return this.eclipseProjectDirectory; |
193 | } | |
194 | ||
195 | /** | |
196 | * Setter for <code>eclipseProjectDir</code>. | |
197 | * | |
198 | * @param eclipseProjectDir The eclipseProjectDir to set. | |
199 | */ | |
200 | public void setEclipseProjectDirectory( File eclipseProjectDir ) | |
201 | { | |
202 | 1 | this.eclipseProjectDirectory = eclipseProjectDir; |
203 | 1 | } |
204 | ||
205 | /** | |
206 | * Getter for <code>eclipseProjectName</code>. | |
207 | * | |
208 | * @return Returns the project name used in eclipse. | |
209 | */ | |
210 | public String getEclipseProjectName() | |
211 | { | |
212 | 3 | return eclipseProjectName; |
213 | } | |
214 | ||
215 | /** | |
216 | * Setter for <code>eclipseProjectName</code>. | |
217 | * | |
218 | * @param eclipseProjectName the project name used in eclipse. | |
219 | */ | |
220 | public void setEclipseProjectName( String eclipseProjectName ) | |
221 | { | |
222 | 1 | this.eclipseProjectName = eclipseProjectName; |
223 | 1 | } |
224 | ||
225 | /** | |
226 | * Getter for <code>project</code>. | |
227 | * | |
228 | * @return Returns the project. | |
229 | */ | |
230 | public MavenProject getProject() | |
231 | { | |
232 | return this.project; | |
233 | } | |
234 | ||
235 | /** | |
236 | * Setter for <code>project</code>. | |
237 | * | |
238 | * @param project The project to set. | |
239 | */ | |
240 | public void setProject( MavenProject project ) | |
241 | { | |
242 | this.project = project; | |
243 | } | |
244 | ||
245 | /** | |
246 | * Getter for <code>sourceDirs</code>. | |
247 | * | |
248 | * @return Returns the sourceDirs. | |
249 | */ | |
250 | public EclipseSourceDir[] getSourceDirs() | |
251 | { | |
252 | 10 | return this.sourceDirs; |
253 | } | |
254 | ||
255 | /** | |
256 | * Setter for <code>sourceDirs</code>. | |
257 | * | |
258 | * @param sourceDirs The sourceDirs to set. | |
259 | */ | |
260 | public void setSourceDirs( EclipseSourceDir[] sourceDirs ) | |
261 | { | |
262 | 1 | this.sourceDirs = sourceDirs; |
263 | 1 | } |
264 | ||
265 | /** | |
266 | * Getter for <code>buildOutputDirectory</code>. | |
267 | * | |
268 | * @return Returns the buildOutputDirectory. | |
269 | */ | |
270 | public File getBuildOutputDirectory() | |
271 | { | |
272 | 1 | return this.buildOutputDirectory; |
273 | } | |
274 | ||
275 | /** | |
276 | * Setter for <code>buildOutputDirectory</code>. | |
277 | * | |
278 | * @param buildOutputDirectory The buildOutputDirectory to set. | |
279 | */ | |
280 | public void setBuildOutputDirectory( File buildOutputDirectory ) | |
281 | { | |
282 | 1 | this.buildOutputDirectory = buildOutputDirectory; |
283 | 1 | } |
284 | ||
285 | /** | |
286 | * Getter for <code>localRepository</code>. | |
287 | * | |
288 | * @return Returns the localRepository. | |
289 | */ | |
290 | public ArtifactRepository getLocalRepository() | |
291 | { | |
292 | return this.localRepository; | |
293 | } | |
294 | ||
295 | /** | |
296 | * Setter for <code>localRepository</code>. | |
297 | * | |
298 | * @param localRepository The localRepository to set. | |
299 | */ | |
300 | public void setLocalRepository( ArtifactRepository localRepository ) | |
301 | { | |
302 | this.localRepository = localRepository; | |
303 | } | |
304 | ||
305 | /** | |
306 | * Getter for <code>manifestFile</code>. | |
307 | * | |
308 | * @return Returns the manifestFile. | |
309 | */ | |
310 | public File getManifestFile() | |
311 | { | |
312 | return this.manifestFile; | |
313 | } | |
314 | ||
315 | /** | |
316 | * Setter for <code>manifestFile</code>. | |
317 | * | |
318 | * @param manifestFile The manifestFile to set. | |
319 | */ | |
320 | public void setManifestFile( File manifestFile ) | |
321 | { | |
322 | this.manifestFile = manifestFile; | |
323 | } | |
324 | ||
325 | /** | |
326 | * Getter for <code>classpathContainers</code>. | |
327 | * | |
328 | * @return Returns the classpathContainers. | |
329 | */ | |
330 | public List getClasspathContainers() | |
331 | { | |
332 | 1 | return this.classpathContainers; |
333 | } | |
334 | ||
335 | /** | |
336 | * Setter for <code>classpathContainers</code>. | |
337 | * | |
338 | * @param classpathContainers The classpathContainers to set. | |
339 | */ | |
340 | public void setClasspathContainers( List classpathContainers ) | |
341 | { | |
342 | this.classpathContainers = classpathContainers; | |
343 | } | |
344 | ||
345 | /** | |
346 | * Getter for <code>pde</code>. | |
347 | * | |
348 | * @return Returns the pde. | |
349 | */ | |
350 | public boolean isPde() | |
351 | { | |
352 | return this.pde; | |
353 | } | |
354 | ||
355 | /** | |
356 | * Setter for <code>pde</code>. | |
357 | * | |
358 | * @param pde The pde to set. | |
359 | */ | |
360 | public void setPde( boolean pde ) | |
361 | { | |
362 | this.pde = pde; | |
363 | } | |
364 | ||
365 | /** | |
366 | * Getter for <code>buildCommands</code>. | |
367 | * | |
368 | * @return Returns the buildCommands. | |
369 | */ | |
370 | public List getBuildCommands() | |
371 | { | |
372 | 1 | return this.buildCommands; |
373 | } | |
374 | ||
375 | /** | |
376 | * Setter for <code>buildCommands</code>. | |
377 | * | |
378 | * @param buildCommands The buildCommands to set. | |
379 | */ | |
380 | public void setBuildCommands( List buildCommands ) | |
381 | { | |
382 | this.buildCommands = buildCommands; | |
383 | } | |
384 | ||
385 | /** | |
386 | * Getter for <code>projectnatures</code>. | |
387 | * | |
388 | * @return Returns the projectnatures. | |
389 | */ | |
390 | public List getProjectnatures() | |
391 | { | |
392 | return this.projectnatures; | |
393 | } | |
394 | ||
395 | /** | |
396 | * Setter for <code>projectnatures</code>. | |
397 | * | |
398 | * @param projectnatures The projectnatures to set. | |
399 | */ | |
400 | public void setProjectnatures( List projectnatures ) | |
401 | { | |
402 | this.projectnatures = projectnatures; | |
403 | } | |
404 | ||
405 | /** | |
406 | * Getter for <code>projectFacets</code>. | |
407 | * | |
408 | * @return Returns the projectFacets | |
409 | */ | |
410 | public Map getProjectFacets() | |
411 | { | |
412 | return projectFacets; | |
413 | } | |
414 | ||
415 | /** | |
416 | * Setter for <code>projectFacets</code> | |
417 | * | |
418 | * @param projectFacets The projectFacets to set. | |
419 | */ | |
420 | public void setProjectFacets( Map projectFacets ) | |
421 | { | |
422 | this.projectFacets = projectFacets; | |
423 | } | |
424 | ||
425 | /** | |
426 | * Getter for <code>projectBaseDir</code>. | |
427 | * | |
428 | * @return Returns the projectBaseDir. | |
429 | */ | |
430 | public File getProjectBaseDir() | |
431 | { | |
432 | 1 | return this.projectBaseDir; |
433 | } | |
434 | ||
435 | /** | |
436 | * Setter for <code>projectBaseDir</code>. | |
437 | * | |
438 | * @param projectBaseDir The projectBaseDir to set. | |
439 | */ | |
440 | public void setProjectBaseDir( File projectBaseDir ) | |
441 | { | |
442 | 1 | this.projectBaseDir = projectBaseDir; |
443 | 1 | } |
444 | ||
445 | /** | |
446 | * Getter for <code>addVersionToProjectName</code>. | |
447 | * | |
448 | * @deprecated use {@link #getProjectNameTemplate()} | |
449 | */ | |
450 | public boolean isAddVersionToProjectName() | |
451 | { | |
452 | return addVersionToProjectName; | |
453 | } | |
454 | ||
455 | /** | |
456 | * Setter for <code>addVersionToProjectName</code>. | |
457 | * | |
458 | * @deprecated use {@link #setProjectNameTemplate(String)} | |
459 | */ | |
460 | public void setAddVersionToProjectName( boolean addVersionToProjectName ) | |
461 | { | |
462 | this.addVersionToProjectName = addVersionToProjectName; | |
463 | } | |
464 | ||
465 | public void setProjectNameTemplate( String projectNameTemplate ) | |
466 | { | |
467 | this.projectNameTemplate = projectNameTemplate; | |
468 | } | |
469 | ||
470 | public String getProjectNameTemplate() | |
471 | { | |
472 | return projectNameTemplate; | |
473 | } | |
474 | ||
475 | public String getContextName() | |
476 | { | |
477 | return this.contextName; | |
478 | } | |
479 | ||
480 | public void setContextName( String deployName ) | |
481 | { | |
482 | this.contextName = deployName; | |
483 | } | |
484 | ||
485 | /** | |
486 | * @return the packaging | |
487 | */ | |
488 | public String getPackaging() | |
489 | { | |
490 | return this.packaging; | |
491 | } | |
492 | ||
493 | /** | |
494 | * @param packaging the packaging to set | |
495 | */ | |
496 | public void setPackaging( String packaging ) | |
497 | { | |
498 | this.packaging = packaging; | |
499 | } | |
500 | ||
501 | /** | |
502 | * Getter for <code>wtpapplicationxml</code>. | |
503 | * | |
504 | * @return Returns the wtpapplicationxml. | |
505 | */ | |
506 | public boolean getWtpapplicationxml() | |
507 | { | |
508 | return this.wtpapplicationxml; | |
509 | } | |
510 | ||
511 | /** | |
512 | * Setter for <code>buildCommands</code>. | |
513 | * | |
514 | * @param buildCommands The buildCommands to set. | |
515 | */ | |
516 | public void setWtpapplicationxml( boolean wtpapplicationxml ) | |
517 | { | |
518 | this.wtpapplicationxml = wtpapplicationxml; | |
519 | } | |
520 | ||
521 | /** | |
522 | * Getter for <code>wtpVersion</code>. | |
523 | * | |
524 | * @return Returns the wtpVersion. | |
525 | */ | |
526 | public float getWtpVersion() | |
527 | { | |
528 | return wtpVersion; | |
529 | } | |
530 | ||
531 | /** | |
532 | * Setter for <code>wtpVersion</code>. | |
533 | * | |
534 | * @param wtpVersion The wtpVersion to set. | |
535 | */ | |
536 | public void setWtpVersion( float wtpVersion ) | |
537 | { | |
538 | this.wtpVersion = wtpVersion; | |
539 | } | |
540 | ||
541 | /** | |
542 | * @return an ordered list of dependencies | |
543 | */ | |
544 | public IdeDependency[] getDepsOrdered() | |
545 | { | |
546 | 1 | return orderedDeps; |
547 | } | |
548 | ||
549 | } |