Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EclipseWriterConfig |
|
| 1.1666666666666667;1,167 | ||||
EclipseWriterConfig$1 |
|
| 1.1666666666666667;1,167 |
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.eclipse.WorkspaceConfiguration; | |
31 | import org.apache.maven.plugin.ide.IdeDependency; | |
32 | import org.apache.maven.project.MavenProject; | |
33 | ||
34 | /** | |
35 | * @author Fabrizio Giustina | |
36 | * @version $Id: EclipseWriterConfig.java 798336 2009-07-27 23:54:06Z aheritier $ | |
37 | */ | |
38 | 24 | public class EclipseWriterConfig |
39 | { | |
40 | /** | |
41 | * The maven project. | |
42 | */ | |
43 | private MavenProject project; | |
44 | ||
45 | /** | |
46 | * The maven project packaging. | |
47 | */ | |
48 | private String packaging; | |
49 | ||
50 | /** | |
51 | * Eclipse project dir. | |
52 | */ | |
53 | private File eclipseProjectDirectory; | |
54 | ||
55 | /** | |
56 | * The name of the project in eclipse. | |
57 | */ | |
58 | private String eclipseProjectName; | |
59 | ||
60 | /** | |
61 | * Base project dir. | |
62 | */ | |
63 | private File projectBaseDir; | |
64 | ||
65 | /** | |
66 | * List of IDE dependencies. | |
67 | */ | |
68 | 24 | private IdeDependency[] deps = new IdeDependency[0]; |
69 | ||
70 | /** | |
71 | * List of IDE dependencies ordered. | |
72 | */ | |
73 | 24 | private IdeDependency[] orderedDeps = new IdeDependency[0]; |
74 | ||
75 | /** | |
76 | * Source directories. | |
77 | */ | |
78 | private EclipseSourceDir[] sourceDirs; | |
79 | ||
80 | /** | |
81 | * Local maven repo. | |
82 | */ | |
83 | private ArtifactRepository localRepository; | |
84 | ||
85 | /** | |
86 | * Build output directory for eclipse. | |
87 | */ | |
88 | private File buildOutputDirectory; | |
89 | ||
90 | /** | |
91 | * Manifest file. | |
92 | */ | |
93 | private File osgiManifestFile; | |
94 | ||
95 | /** | |
96 | * PDE mode. | |
97 | */ | |
98 | private boolean pde; | |
99 | ||
100 | /** | |
101 | * Project natures. | |
102 | */ | |
103 | private List projectnatures; | |
104 | ||
105 | /** | |
106 | * Project facets. | |
107 | */ | |
108 | private Map projectFacets; | |
109 | ||
110 | /** | |
111 | * Build commands. List<BuildCommand> | |
112 | */ | |
113 | private List buildCommands; | |
114 | ||
115 | /** | |
116 | * Classpath containers. | |
117 | */ | |
118 | private List classpathContainers; | |
119 | ||
120 | /** | |
121 | * Appends the version number to the project name if <tt>true</tt>. | |
122 | * | |
123 | * @deprecated use {@link #projectNameTemplate} | |
124 | */ | |
125 | private boolean addVersionToProjectName; | |
126 | ||
127 | /** | |
128 | * @see EclipsePlugin#getProjectNameTemplate() | |
129 | */ | |
130 | private String projectNameTemplate; | |
131 | ||
132 | /** | |
133 | * @see EclipsePlugin#deployName() | |
134 | */ | |
135 | ||
136 | private String contextName; | |
137 | ||
138 | /** | |
139 | * @see EclipsePlugin#wtpapplicationxml() | |
140 | */ | |
141 | private boolean wtpapplicationxml; | |
142 | ||
143 | /** | |
144 | * @see EclipsePlugin#getWtpversion() | |
145 | */ | |
146 | private float wtpVersion; | |
147 | ||
148 | private float ajdtVersion; | |
149 | ||
150 | private WorkspaceConfiguration workspaceConfiguration; | |
151 | ||
152 | private List linkedResources; | |
153 | ||
154 | public WorkspaceConfiguration getWorkspaceConfiguration() | |
155 | { | |
156 | 0 | return workspaceConfiguration; |
157 | } | |
158 | ||
159 | public void setWorkspaceConfiguration( WorkspaceConfiguration workspaceConfiguration ) | |
160 | { | |
161 | 0 | this.workspaceConfiguration = workspaceConfiguration; |
162 | 0 | } |
163 | ||
164 | /** | |
165 | * Getter for <code>deps</code>. | |
166 | * | |
167 | * @return Returns the deps. | |
168 | */ | |
169 | public IdeDependency[] getDeps() | |
170 | { | |
171 | 0 | return deps; |
172 | } | |
173 | ||
174 | /** | |
175 | * Setter for <code>deps</code>. | |
176 | * | |
177 | * @param deps The deps to set. | |
178 | */ | |
179 | public void setDeps( IdeDependency[] deps ) | |
180 | { | |
181 | 12 | this.deps = deps; |
182 | 12 | if ( deps != null ) |
183 | { | |
184 | // TODO get the right comparator depending on orderDependencies={name,nearness..}; | |
185 | // if none specified it could use a NullComparator to reduce the number of | |
186 | // conditions that have to be checked | |
187 | 12 | Comparator depsByArtifactId = new Comparator() |
188 | { | |
189 | 12 | public int compare( Object o1, Object o2 ) |
190 | { | |
191 | 6 | int result = |
192 | ( (IdeDependency) o1 ).getArtifactId().compareToIgnoreCase( | |
193 | ( (IdeDependency) o2 ).getArtifactId() ); | |
194 | 6 | if ( result != 0 ) |
195 | { | |
196 | 6 | return result; |
197 | } | |
198 | 0 | if ( ( (IdeDependency) o1 ).getClassifier() != null |
199 | && ( (IdeDependency) o2 ).getClassifier() != null ) | |
200 | { | |
201 | 0 | result = |
202 | ( (IdeDependency) o1 ).getClassifier().compareToIgnoreCase( | |
203 | ( (IdeDependency) o2 ).getClassifier() ); | |
204 | 0 | if ( result != 0 ) |
205 | { | |
206 | 0 | return result; |
207 | } | |
208 | } | |
209 | 0 | result = ( (IdeDependency) o1 ).getType().compareToIgnoreCase( ( (IdeDependency) o2 ).getType() ); |
210 | 0 | if ( result != 0 ) |
211 | { | |
212 | 0 | return result; |
213 | } | |
214 | 0 | result = |
215 | ( (IdeDependency) o1 ).getGroupId().compareToIgnoreCase( ( (IdeDependency) o2 ).getGroupId() ); | |
216 | 0 | return result; |
217 | } | |
218 | }; | |
219 | ||
220 | 12 | orderedDeps = new IdeDependency[deps.length]; |
221 | 12 | System.arraycopy( deps, 0, orderedDeps, 0, deps.length ); |
222 | 12 | Arrays.sort( orderedDeps, depsByArtifactId ); |
223 | } | |
224 | 12 | } |
225 | ||
226 | /** | |
227 | * Getter for <code>eclipseProjectDir</code>. | |
228 | * | |
229 | * @return Returns the eclipseProjectDir. | |
230 | */ | |
231 | public File getEclipseProjectDirectory() | |
232 | { | |
233 | 54 | return eclipseProjectDirectory; |
234 | } | |
235 | ||
236 | /** | |
237 | * Setter for <code>eclipseProjectDir</code>. | |
238 | * | |
239 | * @param eclipseProjectDir The eclipseProjectDir to set. | |
240 | */ | |
241 | public void setEclipseProjectDirectory( File eclipseProjectDir ) | |
242 | { | |
243 | 24 | eclipseProjectDirectory = eclipseProjectDir; |
244 | 24 | } |
245 | ||
246 | /** | |
247 | * Getter for <code>eclipseProjectName</code>. | |
248 | * | |
249 | * @return Returns the project name used in eclipse. | |
250 | */ | |
251 | public String getEclipseProjectName() | |
252 | { | |
253 | 30 | return eclipseProjectName; |
254 | } | |
255 | ||
256 | /** | |
257 | * Setter for <code>eclipseProjectName</code>. | |
258 | * | |
259 | * @param eclipseProjectName the project name used in eclipse. | |
260 | */ | |
261 | public void setEclipseProjectName( String eclipseProjectName ) | |
262 | { | |
263 | 24 | this.eclipseProjectName = eclipseProjectName; |
264 | 24 | } |
265 | ||
266 | /** | |
267 | * Getter for <code>project</code>. | |
268 | * | |
269 | * @return Returns the project. | |
270 | */ | |
271 | public MavenProject getProject() | |
272 | { | |
273 | 42 | return project; |
274 | } | |
275 | ||
276 | /** | |
277 | * Setter for <code>project</code>. | |
278 | * | |
279 | * @param project The project to set. | |
280 | */ | |
281 | public void setProject( MavenProject project ) | |
282 | { | |
283 | 12 | this.project = project; |
284 | 12 | } |
285 | ||
286 | /** | |
287 | * Getter for <code>sourceDirs</code>. | |
288 | * | |
289 | * @return Returns the sourceDirs. | |
290 | */ | |
291 | public EclipseSourceDir[] getSourceDirs() | |
292 | { | |
293 | 78 | return sourceDirs; |
294 | } | |
295 | ||
296 | /** | |
297 | * Setter for <code>sourceDirs</code>. | |
298 | * | |
299 | * @param sourceDirs The sourceDirs to set. | |
300 | */ | |
301 | public void setSourceDirs( EclipseSourceDir[] sourceDirs ) | |
302 | { | |
303 | 6 | this.sourceDirs = sourceDirs; |
304 | 6 | } |
305 | ||
306 | /** | |
307 | * Getter for <code>buildOutputDirectory</code>. | |
308 | * | |
309 | * @return Returns the buildOutputDirectory. | |
310 | */ | |
311 | public File getBuildOutputDirectory() | |
312 | { | |
313 | 18 | return buildOutputDirectory; |
314 | } | |
315 | ||
316 | /** | |
317 | * Setter for <code>buildOutputDirectory</code>. | |
318 | * | |
319 | * @param buildOutputDirectory The buildOutputDirectory to set. | |
320 | */ | |
321 | public void setBuildOutputDirectory( File buildOutputDirectory ) | |
322 | { | |
323 | 12 | this.buildOutputDirectory = buildOutputDirectory; |
324 | 12 | } |
325 | ||
326 | /** | |
327 | * Getter for <code>localRepository</code>. | |
328 | * | |
329 | * @return Returns the localRepository. | |
330 | */ | |
331 | public ArtifactRepository getLocalRepository() | |
332 | { | |
333 | 12 | return localRepository; |
334 | } | |
335 | ||
336 | /** | |
337 | * Setter for <code>localRepository</code>. | |
338 | * | |
339 | * @param localRepository The localRepository to set. | |
340 | */ | |
341 | public void setLocalRepository( ArtifactRepository localRepository ) | |
342 | { | |
343 | 6 | this.localRepository = localRepository; |
344 | 6 | } |
345 | ||
346 | /** | |
347 | * Getter for <code>manifestFile</code>. | |
348 | * | |
349 | * @return Returns the manifestFile. | |
350 | */ | |
351 | public File getOSGIManifestFile() | |
352 | { | |
353 | 0 | return osgiManifestFile; |
354 | } | |
355 | ||
356 | /** | |
357 | * Setter for <code>manifestFile</code>. | |
358 | * | |
359 | * @param manifestFile The manifestFile to set. | |
360 | */ | |
361 | public void setOSGIManifestFile( File manifestFile ) | |
362 | { | |
363 | 0 | this.osgiManifestFile = manifestFile; |
364 | 0 | } |
365 | ||
366 | /** | |
367 | * Getter for <code>classpathContainers</code>. | |
368 | * | |
369 | * @return Returns the classpathContainers. | |
370 | */ | |
371 | public List getClasspathContainers() | |
372 | { | |
373 | 12 | return classpathContainers; |
374 | } | |
375 | ||
376 | /** | |
377 | * Setter for <code>classpathContainers</code>. | |
378 | * | |
379 | * @param classpathContainers The classpathContainers to set. | |
380 | */ | |
381 | public void setClasspathContainers( List classpathContainers ) | |
382 | { | |
383 | 0 | this.classpathContainers = classpathContainers; |
384 | 0 | } |
385 | ||
386 | /** | |
387 | * Getter for <code>pde</code>. | |
388 | * | |
389 | * @return Returns the pde. | |
390 | */ | |
391 | public boolean isPde() | |
392 | { | |
393 | 30 | return pde; |
394 | } | |
395 | ||
396 | /** | |
397 | * Setter for <code>pde</code>. | |
398 | * | |
399 | * @param pde The pde to set. | |
400 | */ | |
401 | public void setPde( boolean pde ) | |
402 | { | |
403 | 0 | this.pde = pde; |
404 | 0 | } |
405 | ||
406 | /** | |
407 | * Getter for <code>buildCommands</code>. | |
408 | * | |
409 | * @return Returns the buildCommands. | |
410 | */ | |
411 | public List getBuildCommands() | |
412 | { | |
413 | 12 | return buildCommands; |
414 | } | |
415 | ||
416 | /** | |
417 | * Setter for <code>buildCommands</code>. | |
418 | * | |
419 | * @param buildCommands The buildCommands to set. | |
420 | */ | |
421 | public void setBuildCommands( List buildCommands ) | |
422 | { | |
423 | 0 | this.buildCommands = buildCommands; |
424 | 0 | } |
425 | ||
426 | /** | |
427 | * Getter for <code>projectnatures</code>. | |
428 | * | |
429 | * @return Returns the projectnatures. | |
430 | */ | |
431 | public List getProjectnatures() | |
432 | { | |
433 | 6 | return projectnatures; |
434 | } | |
435 | ||
436 | /** | |
437 | * Setter for <code>projectnatures</code>. | |
438 | * | |
439 | * @param projectnatures The projectnatures to set. | |
440 | */ | |
441 | public void setProjectnatures( List projectnatures ) | |
442 | { | |
443 | 0 | this.projectnatures = projectnatures; |
444 | 0 | } |
445 | ||
446 | /** | |
447 | * Getter for <code>projectFacets</code>. | |
448 | * | |
449 | * @return Returns the projectFacets | |
450 | */ | |
451 | public Map getProjectFacets() | |
452 | { | |
453 | 0 | return projectFacets; |
454 | } | |
455 | ||
456 | /** | |
457 | * Setter for <code>projectFacets</code> | |
458 | * | |
459 | * @param projectFacets The projectFacets to set. | |
460 | */ | |
461 | public void setProjectFacets( Map projectFacets ) | |
462 | { | |
463 | 0 | this.projectFacets = projectFacets; |
464 | 0 | } |
465 | ||
466 | /** | |
467 | * Getter for <code>projectBaseDir</code>. | |
468 | * | |
469 | * @return Returns the projectBaseDir. | |
470 | */ | |
471 | public File getProjectBaseDir() | |
472 | { | |
473 | 18 | return projectBaseDir; |
474 | } | |
475 | ||
476 | /** | |
477 | * Setter for <code>projectBaseDir</code>. | |
478 | * | |
479 | * @param projectBaseDir The projectBaseDir to set. | |
480 | */ | |
481 | public void setProjectBaseDir( File projectBaseDir ) | |
482 | { | |
483 | 24 | this.projectBaseDir = projectBaseDir; |
484 | 24 | } |
485 | ||
486 | /** | |
487 | * Getter for <code>addVersionToProjectName</code>. | |
488 | * | |
489 | * @deprecated use {@link #getProjectNameTemplate()} | |
490 | */ | |
491 | public boolean isAddVersionToProjectName() | |
492 | { | |
493 | 0 | return addVersionToProjectName; |
494 | } | |
495 | ||
496 | /** | |
497 | * Setter for <code>addVersionToProjectName</code>. | |
498 | * | |
499 | * @deprecated use {@link #setProjectNameTemplate(String)} | |
500 | */ | |
501 | public void setAddVersionToProjectName( boolean addVersionToProjectName ) | |
502 | { | |
503 | 0 | this.addVersionToProjectName = addVersionToProjectName; |
504 | 0 | } |
505 | ||
506 | public void setProjectNameTemplate( String projectNameTemplate ) | |
507 | { | |
508 | 0 | this.projectNameTemplate = projectNameTemplate; |
509 | 0 | } |
510 | ||
511 | public String getProjectNameTemplate() | |
512 | { | |
513 | 0 | return projectNameTemplate; |
514 | } | |
515 | ||
516 | public String getContextName() | |
517 | { | |
518 | 0 | return contextName; |
519 | } | |
520 | ||
521 | public void setContextName( String deployName ) | |
522 | { | |
523 | 0 | contextName = deployName; |
524 | 0 | } |
525 | ||
526 | /** | |
527 | * @return the packaging | |
528 | */ | |
529 | public String getPackaging() | |
530 | { | |
531 | 12 | return packaging; |
532 | } | |
533 | ||
534 | /** | |
535 | * @param packaging the packaging to set | |
536 | */ | |
537 | public void setPackaging( String packaging ) | |
538 | { | |
539 | 6 | this.packaging = packaging; |
540 | 6 | } |
541 | ||
542 | /** | |
543 | * Getter for <code>wtpapplicationxml</code>. | |
544 | * | |
545 | * @return Returns the wtpapplicationxml. | |
546 | */ | |
547 | public boolean getWtpapplicationxml() | |
548 | { | |
549 | 6 | return wtpapplicationxml; |
550 | } | |
551 | ||
552 | /** | |
553 | * Setter for <code>buildCommands</code>. | |
554 | * | |
555 | * @param buildCommands The buildCommands to set. | |
556 | */ | |
557 | public void setWtpapplicationxml( boolean wtpapplicationxml ) | |
558 | { | |
559 | 0 | this.wtpapplicationxml = wtpapplicationxml; |
560 | 0 | } |
561 | ||
562 | /** | |
563 | * Getter for <code>wtpVersion</code>. | |
564 | * | |
565 | * @return Returns the wtpVersion. | |
566 | */ | |
567 | public float getWtpVersion() | |
568 | { | |
569 | 18 | return wtpVersion; |
570 | } | |
571 | ||
572 | /** | |
573 | * Setter for <code>wtpVersion</code>. | |
574 | * | |
575 | * @param wtpVersion The wtpVersion to set. | |
576 | */ | |
577 | public void setWtpVersion( float wtpVersion ) | |
578 | { | |
579 | 6 | this.wtpVersion = wtpVersion; |
580 | 6 | } |
581 | ||
582 | /** | |
583 | * @return an ordered list of dependencies | |
584 | */ | |
585 | public IdeDependency[] getDepsOrdered() | |
586 | { | |
587 | 48 | return orderedDeps; |
588 | } | |
589 | ||
590 | /** | |
591 | * Returns the ajdtVersion. | |
592 | * | |
593 | * @return the ajdtVersion. | |
594 | */ | |
595 | public float getAjdtVersion() | |
596 | { | |
597 | 6 | return ajdtVersion; |
598 | } | |
599 | ||
600 | /** | |
601 | * Sets the ajdtVersion. | |
602 | * | |
603 | * @param ajdtVersion the ajdtVersion. | |
604 | */ | |
605 | public void setAjdtVersion( float ajdtVersion ) | |
606 | { | |
607 | 0 | this.ajdtVersion = ajdtVersion; |
608 | 0 | } |
609 | ||
610 | /** | |
611 | * @return the linkedResources | |
612 | */ | |
613 | public List getLinkedResources() | |
614 | { | |
615 | 6 | return linkedResources; |
616 | } | |
617 | ||
618 | /** | |
619 | * @param linkedResources the linkedResources to set | |
620 | */ | |
621 | public void setLinkedResources( List linkedResources ) | |
622 | { | |
623 | 0 | this.linkedResources = linkedResources; |
624 | 0 | } |
625 | ||
626 | } |