1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.maven.plugin.eclipse; |
20 | |
|
21 | |
import java.io.File; |
22 | |
import java.io.FileOutputStream; |
23 | |
import java.io.IOException; |
24 | |
import java.io.InputStream; |
25 | |
import java.io.OutputStream; |
26 | |
import java.net.URL; |
27 | |
import java.util.ArrayList; |
28 | |
import java.util.Arrays; |
29 | |
import java.util.Iterator; |
30 | |
import java.util.LinkedHashSet; |
31 | |
import java.util.LinkedList; |
32 | |
import java.util.List; |
33 | |
import java.util.ListIterator; |
34 | |
import java.util.Map; |
35 | |
import java.util.Set; |
36 | |
|
37 | |
import org.apache.maven.artifact.Artifact; |
38 | |
import org.apache.maven.artifact.handler.ArtifactHandler; |
39 | |
import org.apache.maven.artifact.manager.WagonManager; |
40 | |
import org.apache.maven.model.Build; |
41 | |
import org.apache.maven.model.Plugin; |
42 | |
import org.apache.maven.model.Resource; |
43 | |
import org.apache.maven.plugin.MojoExecutionException; |
44 | |
import org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations; |
45 | |
import org.apache.maven.plugin.eclipse.writers.EclipseAjdtWriter; |
46 | |
import org.apache.maven.plugin.eclipse.writers.EclipseClasspathWriter; |
47 | |
import org.apache.maven.plugin.eclipse.writers.EclipseManifestWriter; |
48 | |
import org.apache.maven.plugin.eclipse.writers.EclipseOSGiManifestWriter; |
49 | |
import org.apache.maven.plugin.eclipse.writers.EclipseProjectWriter; |
50 | |
import org.apache.maven.plugin.eclipse.writers.EclipseWriterConfig; |
51 | |
import org.apache.maven.plugin.eclipse.writers.workspace.EclipseSettingsWriter; |
52 | |
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpApplicationXMLWriter; |
53 | |
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponent15Writer; |
54 | |
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponentWriter; |
55 | |
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpFacetsWriter; |
56 | |
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpmodulesWriter; |
57 | |
import org.apache.maven.plugin.ide.AbstractIdeSupportMojo; |
58 | |
import org.apache.maven.plugin.ide.IdeDependency; |
59 | |
import org.apache.maven.plugin.ide.IdeUtils; |
60 | |
import org.apache.maven.plugin.ide.JeeUtils; |
61 | |
import org.apache.maven.project.MavenProject; |
62 | |
import org.apache.maven.settings.MavenSettingsBuilder; |
63 | |
import org.apache.maven.settings.Proxy; |
64 | |
import org.apache.maven.settings.Settings; |
65 | |
import org.apache.maven.wagon.Wagon; |
66 | |
import org.apache.maven.wagon.WagonException; |
67 | |
import org.apache.maven.wagon.observers.Debug; |
68 | |
import org.apache.maven.wagon.proxy.ProxyInfo; |
69 | |
import org.apache.maven.wagon.repository.Repository; |
70 | |
import org.codehaus.plexus.resource.ResourceManager; |
71 | |
import org.codehaus.plexus.resource.loader.FileResourceLoader; |
72 | |
import org.codehaus.plexus.resource.loader.ResourceNotFoundException; |
73 | |
import org.codehaus.plexus.util.FileUtils; |
74 | |
import org.codehaus.plexus.util.IOUtil; |
75 | |
import org.codehaus.plexus.util.StringUtils; |
76 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
77 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | 10 | public class EclipsePlugin |
97 | |
extends AbstractIdeSupportMojo |
98 | |
{ |
99 | |
private static final String WEAVE_DEPENDENCY = "weaveDependency"; |
100 | |
|
101 | |
private static final String WEAVE_DEPENDENCIES = "weaveDependencies"; |
102 | |
|
103 | |
private static final String ASPECT_LIBRARY = "aspectLibrary"; |
104 | |
|
105 | |
private static final String ASPECT_LIBRARIES = "aspectLibraries"; |
106 | |
|
107 | |
private static final String ASPECT_DIRECTORY = "aspectDirectory"; |
108 | |
|
109 | |
private static final String TEST_ASPECT_DIRECTORY = "testAspectDirectory"; |
110 | |
|
111 | |
private static final String ASPECTJ_MAVEN_PLUGIN = "aspectj-maven-plugin"; |
112 | |
|
113 | |
private static final String ORG_CODEHAUS_MOJO = "org.codehaus.mojo"; |
114 | |
|
115 | |
private static final String DEFAULT_TEST_ASPECT_DIRECTORY = "src/test/aspect"; |
116 | |
|
117 | |
private static final String DEFAULT_ASPECT_DIRECTORY = "src/main/aspect"; |
118 | |
|
119 | |
private static final String NATURE_WST_FACET_CORE_NATURE = "org.eclipse.wst.common.project.facet.core.nature"; |
120 | |
|
121 | |
private static final String BUILDER_WST_COMPONENT_STRUCTURAL_DEPENDENCY_RESOLVER = |
122 | |
"org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver"; |
123 | |
|
124 | |
protected static final String BUILDER_WST_VALIDATION = "org.eclipse.wst.validation.validationbuilder"; |
125 | |
|
126 | |
private static final String BUILDER_JDT_CORE_JAVA = "org.eclipse.jdt.core.javabuilder"; |
127 | |
|
128 | |
private static final String BUILDER_WST_COMPONENT_STRUCTURAL = |
129 | |
"org.eclipse.wst.common.modulecore.ComponentStructuralBuilder"; |
130 | |
|
131 | |
private static final String BUILDER_WST_FACET = "org.eclipse.wst.common.project.facet.core.builder"; |
132 | |
|
133 | |
private static final String BUILDER_PDE_MANIFEST = "org.eclipse.pde.ManifestBuilder"; |
134 | |
|
135 | |
private static final String BUILDER_PDE_SCHEMA = "org.eclipse.pde.SchemaBuilder"; |
136 | |
|
137 | |
private static final String BUILDER_AJDT_CORE_JAVA = "org.eclipse.ajdt.core.ajbuilder"; |
138 | |
|
139 | |
private static final String NATURE_WST_MODULE_CORE_NATURE = "org.eclipse.wst.common.modulecore.ModuleCoreNature"; |
140 | |
|
141 | |
private static final String NATURE_JDT_CORE_JAVA = "org.eclipse.jdt.core.javanature"; |
142 | |
|
143 | |
private static final String NATURE_JEM_WORKBENCH_JAVA_EMF = "org.eclipse.jem.workbench.JavaEMFNature"; |
144 | |
|
145 | |
private static final String NATURE_PDE_PLUGIN = "org.eclipse.pde.PluginNature"; |
146 | |
|
147 | |
private static final String NATURE_AJDT_CORE_JAVA = "org.eclipse.ajdt.ui.ajnature"; |
148 | |
|
149 | |
protected static final String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER = "org.eclipse.jdt.launching.JRE_CONTAINER"; |
150 | |
|
151 | |
protected static final String ASPECTJ_RT_CONTAINER = "org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"; |
152 | |
|
153 | |
protected static final String REQUIRED_PLUGINS_CONTAINER = "org.eclipse.pde.core.requiredPlugins"; |
154 | |
|
155 | |
|
156 | 2 | public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "1.5", "2.0", "R7", "none" }; |
157 | |
|
158 | |
public static final String ASPECTJ_FILE_PATTERN = "**/*.aj"; |
159 | |
|
160 | |
public static final String JAVA_FILE_PATTERN = "**/*.java"; |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
private static final String POM_ELT_ARTIFACT_ID = "artifactId"; |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
private static final String POM_ELT_GROUP_ID = "groupId"; |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
private List projectnatures; |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
private List excludes; |
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
private List additionalProjectnatures; |
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
private Map additionalProjectFacets; |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
private List buildcommands; |
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
private List additionalBuildcommands; |
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
private List classpathContainers; |
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
private boolean eclipseDownloadSources; |
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
private File eclipseProjectDir; |
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
private boolean useProjectReferences; |
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
private File buildOutputDirectory; |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
private String wtpversion; |
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
private String wtpContextName; |
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
private boolean pde; |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
private boolean ajdt; |
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
private File manifest; |
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
private EclipseConfigFile[] additionalConfig; |
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
private boolean addVersionToProjectName; |
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
private boolean addGroupIdToProjectName; |
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
private String projectNameTemplate; |
455 | |
|
456 | |
|
457 | |
|
458 | |
|
459 | |
private float wtpVersionFloat; |
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
private boolean isJavaProject; |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
private boolean wtpmanifest; |
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
private boolean wtpapplicationxml; |
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
private String wtpdefaultserver; |
486 | |
|
487 | |
private WorkspaceConfiguration workspaceConfiguration; |
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
private ResourceManager locator; |
497 | |
|
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
private WagonManager wagonManager; |
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
private MavenSettingsBuilder mavenSettingsBuilder; |
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
|
525 | |
|
526 | |
protected File workspace; |
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
protected boolean limitProjectReferencesToWorkspace; |
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
private String ajdtVersion; |
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
private List sourceExcludes; |
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
|
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
private List sourceIncludes; |
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
|
580 | |
|
581 | |
|
582 | |
|
583 | |
|
584 | |
|
585 | |
|
586 | |
|
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
private List linkedResources; |
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
protected boolean classpathContainersLast; |
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
protected boolean testSourcesLast; |
623 | |
|
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
protected String jeeversion; |
645 | |
|
646 | |
protected final boolean isJavaProject() |
647 | |
{ |
648 | 0 | return isJavaProject; |
649 | |
} |
650 | |
|
651 | |
protected final boolean isPdeProject() |
652 | |
{ |
653 | 0 | return pde; |
654 | |
} |
655 | |
|
656 | |
|
657 | |
|
658 | |
|
659 | |
|
660 | |
|
661 | |
public final List getBuildcommands() |
662 | |
{ |
663 | 0 | return buildcommands; |
664 | |
} |
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
public final void setBuildcommands( List buildcommands ) |
672 | |
{ |
673 | 0 | this.buildcommands = buildcommands; |
674 | 0 | } |
675 | |
|
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
public final File getBuildOutputDirectory() |
682 | |
{ |
683 | 0 | return buildOutputDirectory; |
684 | |
} |
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
public final void setBuildOutputDirectory( File buildOutputDirectory ) |
692 | |
{ |
693 | 0 | this.buildOutputDirectory = buildOutputDirectory; |
694 | 0 | } |
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
public final List getClasspathContainers() |
702 | |
{ |
703 | 0 | return classpathContainers; |
704 | |
} |
705 | |
|
706 | |
|
707 | |
|
708 | |
|
709 | |
|
710 | |
|
711 | |
public final void setClasspathContainers( List classpathContainers ) |
712 | |
{ |
713 | 0 | this.classpathContainers = classpathContainers; |
714 | 0 | } |
715 | |
|
716 | |
|
717 | |
|
718 | |
|
719 | |
|
720 | |
|
721 | |
public final File getEclipseProjectDir() |
722 | |
{ |
723 | 0 | return eclipseProjectDir; |
724 | |
} |
725 | |
|
726 | |
|
727 | |
|
728 | |
|
729 | |
|
730 | |
|
731 | |
public final void setEclipseProjectDir( File eclipseProjectDir ) |
732 | |
{ |
733 | 0 | this.eclipseProjectDir = eclipseProjectDir; |
734 | 0 | } |
735 | |
|
736 | |
|
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
public final List getProjectnatures() |
742 | |
{ |
743 | 0 | return projectnatures; |
744 | |
} |
745 | |
|
746 | |
|
747 | |
|
748 | |
|
749 | |
|
750 | |
|
751 | |
public final void setProjectnatures( List projectnatures ) |
752 | |
{ |
753 | 0 | this.projectnatures = projectnatures; |
754 | 0 | } |
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
public final boolean getUseProjectReferences() |
762 | |
{ |
763 | 0 | return useProjectReferences; |
764 | |
} |
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
public final void setUseProjectReferences( boolean useProjectReferences ) |
772 | |
{ |
773 | 0 | this.useProjectReferences = useProjectReferences; |
774 | 0 | } |
775 | |
|
776 | |
|
777 | |
|
778 | |
|
779 | |
|
780 | |
|
781 | |
public final String getWtpversion() |
782 | |
{ |
783 | 0 | return wtpversion; |
784 | |
} |
785 | |
|
786 | |
|
787 | |
|
788 | |
|
789 | |
|
790 | |
|
791 | |
public final void setWtpversion( String wtpversion ) |
792 | |
{ |
793 | 0 | this.wtpversion = wtpversion; |
794 | 0 | } |
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
|
801 | |
public final List getAdditionalBuildcommands() |
802 | |
{ |
803 | 0 | return additionalBuildcommands; |
804 | |
} |
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
|
810 | |
|
811 | |
public final void setAdditionalBuildcommands( List additionalBuildcommands ) |
812 | |
{ |
813 | 0 | this.additionalBuildcommands = additionalBuildcommands; |
814 | 0 | } |
815 | |
|
816 | |
|
817 | |
|
818 | |
|
819 | |
|
820 | |
|
821 | |
public final List getAdditionalProjectnatures() |
822 | |
{ |
823 | 0 | return additionalProjectnatures; |
824 | |
} |
825 | |
|
826 | |
|
827 | |
|
828 | |
|
829 | |
|
830 | |
|
831 | |
public final void setAdditionalProjectnatures( List additionalProjectnatures ) |
832 | |
{ |
833 | 0 | this.additionalProjectnatures = additionalProjectnatures; |
834 | 0 | } |
835 | |
|
836 | |
|
837 | |
|
838 | |
|
839 | |
public final boolean isAddVersionToProjectName() |
840 | |
{ |
841 | 0 | return addVersionToProjectName; |
842 | |
} |
843 | |
|
844 | |
|
845 | |
|
846 | |
|
847 | |
public final void setAddVersionToProjectName( boolean addVersionToProjectName ) |
848 | |
{ |
849 | 0 | this.addVersionToProjectName = addVersionToProjectName; |
850 | 0 | } |
851 | |
|
852 | |
|
853 | |
|
854 | |
|
855 | |
public final boolean isAddGroupIdToProjectName() |
856 | |
{ |
857 | 0 | return addGroupIdToProjectName; |
858 | |
} |
859 | |
|
860 | |
|
861 | |
|
862 | |
|
863 | |
public final void setAddGroupIdToProjectName( boolean addGroupIdToProjectName ) |
864 | |
{ |
865 | 0 | this.addGroupIdToProjectName = addGroupIdToProjectName; |
866 | 0 | } |
867 | |
|
868 | |
|
869 | |
|
870 | |
|
871 | |
|
872 | |
|
873 | |
public final String getProjectNameTemplate() |
874 | |
{ |
875 | 0 | return projectNameTemplate; |
876 | |
} |
877 | |
|
878 | |
|
879 | |
|
880 | |
|
881 | |
|
882 | |
|
883 | |
public final void setProjectNameTemplate( String projectNameTemplate ) |
884 | |
{ |
885 | 0 | this.projectNameTemplate = projectNameTemplate; |
886 | 0 | } |
887 | |
|
888 | |
|
889 | |
|
890 | |
|
891 | |
public List getLinkedResources() |
892 | |
{ |
893 | 0 | return linkedResources; |
894 | |
} |
895 | |
|
896 | |
|
897 | |
|
898 | |
|
899 | |
public void setLinkedResources( List linkedResources ) |
900 | |
{ |
901 | 0 | this.linkedResources = linkedResources; |
902 | 0 | } |
903 | |
|
904 | |
|
905 | |
|
906 | |
|
907 | |
public final boolean setup() |
908 | |
throws MojoExecutionException |
909 | |
{ |
910 | 0 | boolean ready = true; |
911 | |
|
912 | 0 | checkDeprecations(); |
913 | 0 | setProjectNameTemplate( IdeUtils.calculateProjectNameTemplate( getProjectNameTemplate(), |
914 | |
isAddVersionToProjectName(), |
915 | |
isAddGroupIdToProjectName(), getLog() ) ); |
916 | 0 | ajdt = enableAjdt( executedProject ) && !ajdtVersion.equals( "none" ); |
917 | 0 | ready = validate(); |
918 | |
|
919 | |
|
920 | 0 | ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler(); |
921 | |
|
922 | |
|
923 | |
|
924 | 0 | isJavaProject = |
925 | |
pde |
926 | |
|| ( Constants.LANGUAGE_JAVA.equals( artifactHandler.getLanguage() ) && !Constants.PROJECT_PACKAGING_EAR.equals( packaging ) ); |
927 | |
|
928 | 0 | if ( sourceIncludes == null ) |
929 | |
{ |
930 | 0 | sourceIncludes = new ArrayList(); |
931 | |
} |
932 | 0 | if ( isJavaProject ) |
933 | |
{ |
934 | 0 | sourceIncludes.add( JAVA_FILE_PATTERN ); |
935 | |
} |
936 | 0 | if ( ajdt ) |
937 | |
{ |
938 | 0 | sourceIncludes.add( ASPECTJ_FILE_PATTERN ); |
939 | |
} |
940 | |
|
941 | 0 | if ( sourceExcludes == null ) |
942 | |
{ |
943 | 0 | sourceExcludes = new ArrayList(); |
944 | |
} |
945 | |
|
946 | 0 | setupExtras(); |
947 | |
|
948 | 0 | parseConfigurationOptions(); |
949 | |
|
950 | |
|
951 | 0 | if ( projectnatures == null ) |
952 | |
{ |
953 | 0 | fillDefaultNatures( packaging ); |
954 | |
} |
955 | |
|
956 | 0 | if ( additionalProjectnatures != null ) |
957 | |
{ |
958 | 0 | projectnatures.addAll( additionalProjectnatures ); |
959 | |
} |
960 | |
|
961 | 0 | if ( buildcommands == null ) |
962 | |
{ |
963 | 0 | fillDefaultBuilders( packaging ); |
964 | |
} |
965 | |
else |
966 | |
{ |
967 | 0 | convertBuildCommandList( buildcommands ); |
968 | |
} |
969 | |
|
970 | 0 | if ( additionalBuildcommands != null ) |
971 | |
{ |
972 | 0 | convertBuildCommandList( additionalBuildcommands ); |
973 | 0 | buildcommands.addAll( additionalBuildcommands ); |
974 | |
} |
975 | |
|
976 | 0 | if ( classpathContainers == null ) |
977 | |
{ |
978 | 0 | fillDefaultClasspathContainers( packaging ); |
979 | |
} |
980 | |
else |
981 | |
{ |
982 | 0 | verifyClasspathContainerListIsComplete(); |
983 | |
} |
984 | |
|
985 | 0 | if ( linkedResources == null ) |
986 | |
{ |
987 | 0 | linkedResources = new ArrayList(); |
988 | |
} |
989 | |
|
990 | 0 | locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() ); |
991 | 0 | locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) ); |
992 | |
|
993 | |
|
994 | 0 | return ready; |
995 | |
} |
996 | |
|
997 | |
|
998 | |
|
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
protected final void convertBuildCommandList( List commands ) |
1004 | |
{ |
1005 | 0 | if ( commands != null ) |
1006 | |
{ |
1007 | 0 | for ( ListIterator i = commands.listIterator(); i.hasNext(); ) |
1008 | |
{ |
1009 | 0 | Object command = i.next(); |
1010 | |
|
1011 | 0 | if ( command instanceof String ) |
1012 | |
{ |
1013 | 0 | command = new BuildCommand( (String) command ); |
1014 | 0 | i.set( command ); |
1015 | |
} |
1016 | 0 | } |
1017 | |
} |
1018 | 0 | } |
1019 | |
|
1020 | |
private void parseConfigurationOptions() |
1021 | |
{ |
1022 | 0 | if ( "R7".equalsIgnoreCase( wtpversion ) ) |
1023 | |
{ |
1024 | 0 | wtpVersionFloat = 0.7f; |
1025 | |
} |
1026 | 0 | else if ( "1.0".equalsIgnoreCase( wtpversion ) ) |
1027 | |
{ |
1028 | 0 | wtpVersionFloat = 1.0f; |
1029 | |
} |
1030 | 0 | else if ( "1.5".equalsIgnoreCase( wtpversion ) ) |
1031 | |
{ |
1032 | 0 | wtpVersionFloat = 1.5f; |
1033 | |
} |
1034 | 0 | else if ( "2.0".equalsIgnoreCase( wtpversion ) ) |
1035 | |
{ |
1036 | 0 | wtpVersionFloat = 2.0f; |
1037 | |
} |
1038 | 0 | if ( !"none".equalsIgnoreCase( wtpversion ) ) |
1039 | |
{ |
1040 | 0 | getLog().info( Messages.getString( "EclipsePlugin.wtpversion", wtpversion ) ); |
1041 | |
} |
1042 | 0 | } |
1043 | |
|
1044 | |
|
1045 | |
|
1046 | |
|
1047 | |
|
1048 | |
|
1049 | |
|
1050 | |
|
1051 | |
protected void setupExtras() |
1052 | |
throws MojoExecutionException |
1053 | |
{ |
1054 | |
|
1055 | 0 | } |
1056 | |
|
1057 | |
private void verifyClasspathContainerListIsComplete() |
1058 | |
{ |
1059 | 0 | boolean containsJREContainer = false; |
1060 | |
|
1061 | |
|
1062 | 0 | for ( Iterator iter = classpathContainers.iterator(); iter.hasNext(); ) |
1063 | |
{ |
1064 | 0 | Object classPathContainer = iter.next(); |
1065 | 0 | if ( classPathContainer != null |
1066 | |
&& classPathContainer.toString().startsWith( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER ) ) |
1067 | |
{ |
1068 | 0 | containsJREContainer = true; |
1069 | 0 | break; |
1070 | |
} |
1071 | 0 | } |
1072 | 0 | if ( !containsJREContainer ) |
1073 | |
{ |
1074 | 0 | getLog().warn( Messages.getString( "EclipsePlugin.missingjrecontainer" ) ); |
1075 | 0 | classpathContainers.add( 0, COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER ); |
1076 | |
} |
1077 | 0 | } |
1078 | |
|
1079 | |
private boolean validate() |
1080 | |
throws MojoExecutionException |
1081 | |
{ |
1082 | |
|
1083 | 0 | if ( Arrays.binarySearch( WTP_SUPPORTED_VERSIONS, wtpversion ) < 0 ) |
1084 | |
{ |
1085 | 0 | throw new MojoExecutionException( |
1086 | |
Messages.getString( "EclipsePlugin.unsupportedwtp", new Object[] { |
1087 | |
wtpversion, |
1088 | |
StringUtils.join( WTP_SUPPORTED_VERSIONS, " " ) } ) ); |
1089 | |
} |
1090 | |
|
1091 | 0 | assertNotEmpty( executedProject.getGroupId(), POM_ELT_GROUP_ID ); |
1092 | 0 | assertNotEmpty( executedProject.getArtifactId(), POM_ELT_ARTIFACT_ID ); |
1093 | |
|
1094 | 0 | if ( executedProject.getFile() == null || !executedProject.getFile().exists() ) |
1095 | |
{ |
1096 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.missingpom" ) ); |
1097 | |
} |
1098 | |
|
1099 | 0 | if ( "pom".equals( packaging ) && eclipseProjectDir == null ) |
1100 | |
{ |
1101 | 0 | getLog().info( Messages.getString( "EclipsePlugin.pompackaging" ) ); |
1102 | 0 | return false; |
1103 | |
} |
1104 | |
|
1105 | 0 | if ( "eclipse-plugin".equals( packaging ) ) |
1106 | |
{ |
1107 | 0 | pde = true; |
1108 | |
} |
1109 | |
|
1110 | 0 | if ( eclipseProjectDir == null ) |
1111 | |
{ |
1112 | 0 | eclipseProjectDir = executedProject.getFile().getParentFile(); |
1113 | |
} |
1114 | |
|
1115 | 0 | if ( !eclipseProjectDir.exists() && !eclipseProjectDir.mkdirs() ) |
1116 | |
{ |
1117 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantcreatedir", eclipseProjectDir ) ); |
1118 | |
} |
1119 | |
|
1120 | 0 | if ( !eclipseProjectDir.equals( executedProject.getFile().getParentFile() ) ) |
1121 | |
{ |
1122 | 0 | if ( !eclipseProjectDir.isDirectory() ) |
1123 | |
{ |
1124 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.notadir", eclipseProjectDir ) ); |
1125 | |
} |
1126 | 0 | eclipseProjectDir = new File( eclipseProjectDir, executedProject.getArtifactId() ); |
1127 | 0 | if ( !eclipseProjectDir.isDirectory() && !eclipseProjectDir.mkdirs() ) |
1128 | |
{ |
1129 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantcreatedir", eclipseProjectDir ) ); |
1130 | |
} |
1131 | |
} |
1132 | |
|
1133 | 0 | validateExtras(); |
1134 | |
|
1135 | 0 | return true; |
1136 | |
} |
1137 | |
|
1138 | |
|
1139 | |
|
1140 | |
|
1141 | |
|
1142 | |
|
1143 | |
|
1144 | |
|
1145 | |
protected void validateExtras() |
1146 | |
throws MojoExecutionException |
1147 | |
{ |
1148 | |
|
1149 | 0 | } |
1150 | |
|
1151 | |
private void checkDeprecations() |
1152 | |
{ |
1153 | 0 | if ( eclipseDownloadSources ) |
1154 | |
{ |
1155 | |
|
1156 | 0 | getLog().warn( Messages.getString( "EclipsePlugin.deprecatedpar", new Object[] { |
1157 | |
"eclipse.downloadSources", |
1158 | |
"downloadSources" } ) ); |
1159 | 0 | downloadSources = true; |
1160 | |
} |
1161 | |
|
1162 | 0 | checkDeprecationsExtras(); |
1163 | 0 | } |
1164 | |
|
1165 | |
|
1166 | |
|
1167 | |
|
1168 | |
|
1169 | |
|
1170 | |
protected void checkDeprecationsExtras() |
1171 | |
{ |
1172 | |
|
1173 | 0 | } |
1174 | |
|
1175 | |
public final void writeConfiguration( IdeDependency[] deps ) |
1176 | |
throws MojoExecutionException |
1177 | |
{ |
1178 | 0 | EclipseWriterConfig config = createEclipseWriterConfig( deps ); |
1179 | |
|
1180 | 0 | if ( wtpmanifest && isJavaProject() ) |
1181 | |
{ |
1182 | |
|
1183 | 0 | EclipseManifestWriter.addManifestResource( getLog(), config ); |
1184 | |
} |
1185 | |
|
1186 | 0 | writeConfigurationExtras( config ); |
1187 | |
|
1188 | 0 | if ( wtpVersionFloat == 0.7f ) |
1189 | |
{ |
1190 | 0 | new EclipseWtpmodulesWriter().init( getLog(), config ).write(); |
1191 | |
} |
1192 | |
|
1193 | 0 | if ( wtpVersionFloat >= 1.0f ) |
1194 | |
{ |
1195 | 0 | new EclipseWtpFacetsWriter().init( getLog(), config ).write(); |
1196 | |
} |
1197 | 0 | if ( wtpVersionFloat == 1.0f ) |
1198 | |
{ |
1199 | 0 | new EclipseWtpComponentWriter().init( getLog(), config ).write(); |
1200 | |
} |
1201 | 0 | if ( wtpVersionFloat >= 1.5 ) |
1202 | |
{ |
1203 | 0 | new EclipseWtpComponent15Writer().init( getLog(), config ).write(); |
1204 | |
} |
1205 | |
|
1206 | 0 | new EclipseSettingsWriter().init( getLog(), config ).write(); |
1207 | |
|
1208 | 0 | if ( isJavaProject ) |
1209 | |
{ |
1210 | 0 | new EclipseClasspathWriter().init( getLog(), config ).write(); |
1211 | 0 | if ( ajdt && ajdtVersion.equals( "1.4" ) ) |
1212 | |
{ |
1213 | 0 | new EclipseAjdtWriter().init( getLog(), config ).write(); |
1214 | |
} |
1215 | |
} |
1216 | |
|
1217 | 0 | if ( wtpapplicationxml ) |
1218 | |
{ |
1219 | 0 | new EclipseWtpApplicationXMLWriter().init( getLog(), config ).write(); |
1220 | |
} |
1221 | |
|
1222 | 0 | if ( pde ) |
1223 | |
{ |
1224 | 0 | this.getLog().info( "The Maven Eclipse plugin runs in 'pde'-mode." ); |
1225 | 0 | new EclipseOSGiManifestWriter().init( getLog(), config ).write(); |
1226 | |
} |
1227 | |
|
1228 | |
|
1229 | |
|
1230 | |
|
1231 | |
|
1232 | 0 | new EclipseProjectWriter().init( getLog(), config ).write(); |
1233 | |
|
1234 | 0 | writeAdditionalConfig(); |
1235 | |
|
1236 | 0 | getLog().info( Messages.getString( "EclipsePlugin.wrote", new Object[] { |
1237 | |
config.getEclipseProjectName(), eclipseProjectDir.getAbsolutePath() } ) ); |
1238 | 0 | } |
1239 | |
|
1240 | |
private void writeAdditionalConfig() |
1241 | |
throws MojoExecutionException |
1242 | |
{ |
1243 | 0 | if ( additionalConfig != null ) |
1244 | |
{ |
1245 | 0 | for ( int j = 0; j < additionalConfig.length; j++ ) |
1246 | |
{ |
1247 | 0 | EclipseConfigFile file = additionalConfig[j]; |
1248 | 0 | File projectRelativeFile = new File( eclipseProjectDir, file.getName() ); |
1249 | 0 | if ( projectRelativeFile.isDirectory() ) |
1250 | |
{ |
1251 | |
|
1252 | 0 | getLog().warn( Messages.getString( "EclipsePlugin.foundadir", |
1253 | |
projectRelativeFile.getAbsolutePath() ) ); |
1254 | |
} |
1255 | |
|
1256 | |
try |
1257 | |
{ |
1258 | 0 | projectRelativeFile.getParentFile().mkdirs(); |
1259 | 0 | if ( file.getContent() == null ) |
1260 | |
{ |
1261 | 0 | if ( file.getLocation() != null ) |
1262 | |
{ |
1263 | 0 | InputStream inStream = locator.getResourceAsInputStream( file.getLocation() ); |
1264 | 0 | OutputStream outStream = new FileOutputStream( projectRelativeFile ); |
1265 | |
try |
1266 | |
{ |
1267 | 0 | IOUtil.copy( inStream, outStream ); |
1268 | |
} |
1269 | |
finally |
1270 | |
{ |
1271 | 0 | IOUtil.close(inStream); |
1272 | 0 | IOUtil.close(outStream); |
1273 | 0 | } |
1274 | 0 | } |
1275 | |
else |
1276 | |
{ |
1277 | 0 | URL url = file.getURL(); |
1278 | 0 | String endPointUrl = url.getProtocol() + "://" + url.getAuthority(); |
1279 | |
|
1280 | 0 | Repository repository = new Repository( "additonal-configs", endPointUrl ); |
1281 | 0 | Wagon wagon = wagonManager.getWagon( repository );; |
1282 | 0 | if ( logger.isDebugEnabled() ) |
1283 | |
{ |
1284 | 0 | Debug debug = new Debug(); |
1285 | 0 | wagon.addSessionListener( debug ); |
1286 | 0 | wagon.addTransferListener( debug ); |
1287 | |
} |
1288 | 0 | wagon.setTimeout( 1000 ); |
1289 | 0 | Settings settings = mavenSettingsBuilder.buildSettings(); |
1290 | 0 | ProxyInfo proxyInfo = null; |
1291 | 0 | if ( settings != null && settings.getActiveProxy() != null ) |
1292 | |
{ |
1293 | 0 | Proxy settingsProxy = settings.getActiveProxy(); |
1294 | |
|
1295 | 0 | proxyInfo = new ProxyInfo(); |
1296 | 0 | proxyInfo.setHost( settingsProxy.getHost() ); |
1297 | 0 | proxyInfo.setType( settingsProxy.getProtocol() ); |
1298 | 0 | proxyInfo.setPort( settingsProxy.getPort() ); |
1299 | 0 | proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() ); |
1300 | 0 | proxyInfo.setUserName( settingsProxy.getUsername() ); |
1301 | 0 | proxyInfo.setPassword( settingsProxy.getPassword() ); |
1302 | |
} |
1303 | |
|
1304 | 0 | if ( proxyInfo != null ) |
1305 | |
{ |
1306 | 0 | wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo ); |
1307 | |
} |
1308 | |
else |
1309 | |
{ |
1310 | 0 | wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) ); |
1311 | |
} |
1312 | |
|
1313 | 0 | wagon.get( url.getPath(), projectRelativeFile ); |
1314 | 0 | } |
1315 | |
} |
1316 | |
else |
1317 | |
{ |
1318 | 0 | FileUtils.fileWrite( projectRelativeFile.getAbsolutePath(), file.getContent() ); |
1319 | |
} |
1320 | |
} |
1321 | 0 | catch ( WagonException e ) { |
1322 | 0 | throw new MojoExecutionException(Messages.getString("EclipsePlugin.remoteexception", |
1323 | |
new Object[] { file.getURL(), |
1324 | |
e.getMessage() })); |
1325 | |
} |
1326 | 0 | catch ( IOException e ) |
1327 | |
{ |
1328 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantwritetofile", |
1329 | |
projectRelativeFile.getAbsolutePath() ) ); |
1330 | |
} |
1331 | 0 | catch ( ResourceNotFoundException e ) |
1332 | |
{ |
1333 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantfindresource", |
1334 | |
file.getLocation() ) ); |
1335 | |
} |
1336 | 0 | catch ( XmlPullParserException e ) |
1337 | |
{ |
1338 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.settingsxmlfailure", |
1339 | |
e.getMessage() ) ); |
1340 | 0 | } |
1341 | |
} |
1342 | |
} |
1343 | 0 | } |
1344 | |
|
1345 | |
|
1346 | |
|
1347 | |
|
1348 | |
|
1349 | |
|
1350 | |
|
1351 | |
|
1352 | |
protected final EclipseWriterConfig createEclipseWriterConfig( IdeDependency[] deps ) |
1353 | |
throws MojoExecutionException |
1354 | |
{ |
1355 | 0 | File projectBaseDir = executedProject.getFile().getParentFile(); |
1356 | |
|
1357 | |
|
1358 | |
|
1359 | 0 | EclipseSourceDir[] sourceDirs = buildDirectoryList( executedProject, eclipseProjectDir, buildOutputDirectory ); |
1360 | |
|
1361 | 0 | EclipseWriterConfig config = new EclipseWriterConfig(); |
1362 | |
|
1363 | 0 | config.setWorkspaceConfiguration( getWorkspaceConfiguration() ); |
1364 | |
|
1365 | 0 | config.setProjectNameTemplate( getProjectNameTemplate() ); |
1366 | |
|
1367 | 0 | String projectName = IdeUtils.getProjectName( config.getProjectNameTemplate(), project ); |
1368 | |
|
1369 | 0 | config.setEclipseProjectName( projectName ); |
1370 | |
|
1371 | 0 | config.setWtpapplicationxml( wtpapplicationxml ); |
1372 | |
|
1373 | 0 | config.setWtpVersion( wtpVersionFloat ); |
1374 | |
|
1375 | |
float ajdtVersionFloat; |
1376 | |
try |
1377 | |
{ |
1378 | 0 | ajdtVersionFloat = Float.parseFloat( ajdtVersion ); |
1379 | |
} |
1380 | 0 | catch ( NumberFormatException e ) |
1381 | |
{ |
1382 | 0 | ajdtVersionFloat = 0.0f; |
1383 | 0 | } |
1384 | |
|
1385 | 0 | config.setAjdtVersion( ajdtVersionFloat ); |
1386 | |
|
1387 | 0 | Set convertedBuildCommands = new LinkedHashSet(); |
1388 | |
|
1389 | 0 | if ( buildcommands != null ) |
1390 | |
{ |
1391 | 0 | for ( Iterator it = buildcommands.iterator(); it.hasNext(); ) |
1392 | |
{ |
1393 | 0 | Object cmd = it.next(); |
1394 | |
|
1395 | 0 | if ( cmd instanceof BuildCommand ) |
1396 | |
{ |
1397 | 0 | convertedBuildCommands.add( cmd ); |
1398 | |
} |
1399 | |
else |
1400 | |
{ |
1401 | 0 | convertedBuildCommands.add( new BuildCommand( (String) cmd ) ); |
1402 | |
} |
1403 | 0 | } |
1404 | |
} |
1405 | |
|
1406 | 0 | if ( ajdt ) |
1407 | |
{ |
1408 | 0 | buildAjdtWeaveDeps( deps ); |
1409 | 0 | buildAspectjDeps( deps ); |
1410 | |
} |
1411 | |
|
1412 | 0 | config.setBuildCommands( new LinkedList( convertedBuildCommands ) ); |
1413 | |
|
1414 | 0 | config.setBuildOutputDirectory( buildOutputDirectory ); |
1415 | 0 | config.setClasspathContainers( classpathContainers ); |
1416 | 0 | config.setDeps( deps ); |
1417 | 0 | config.setEclipseProjectDirectory( eclipseProjectDir ); |
1418 | 0 | config.setLocalRepository( localRepository ); |
1419 | 0 | config.setOSGIManifestFile( manifest ); |
1420 | 0 | config.setPde( pde ); |
1421 | 0 | config.setProject( project ); |
1422 | 0 | config.setProjectBaseDir( projectBaseDir ); |
1423 | 0 | config.setProjectnatures( projectnatures ); |
1424 | 0 | config.setProjectFacets( additionalProjectFacets ); |
1425 | 0 | config.setSourceDirs( sourceDirs ); |
1426 | 0 | config.setPackaging( packaging ); |
1427 | 0 | config.setLinkedResources( linkedResources ); |
1428 | 0 | config.setClasspathContainersLast( classpathContainersLast ); |
1429 | 0 | config.setJeeVersion( jeeversion ); |
1430 | |
|
1431 | 0 | collectWarContextRootsFromReactorEarConfiguration( config ); |
1432 | |
|
1433 | 0 | return config; |
1434 | |
} |
1435 | |
|
1436 | |
|
1437 | |
|
1438 | |
|
1439 | |
|
1440 | |
|
1441 | |
|
1442 | |
private void collectWarContextRootsFromReactorEarConfiguration( EclipseWriterConfig config ) |
1443 | |
{ |
1444 | 0 | if ( reactorProjects != null && wtpContextName == null |
1445 | |
&& Constants.PROJECT_PACKAGING_WAR.equals( project.getPackaging() ) ) |
1446 | |
{ |
1447 | 0 | for ( Iterator iter = reactorProjects.iterator(); iter.hasNext(); ) |
1448 | |
{ |
1449 | 0 | MavenProject reactorProject = (MavenProject) iter.next(); |
1450 | |
|
1451 | 0 | if ( Constants.PROJECT_PACKAGING_EAR.equals( reactorProject.getPackaging() ) ) |
1452 | |
{ |
1453 | 0 | Xpp3Dom[] warDefinitions = |
1454 | |
IdeUtils.getPluginConfigurationDom( reactorProject, JeeUtils.ARTIFACT_MAVEN_EAR_PLUGIN, |
1455 | |
new String[] { "modules", "webModule" } ); |
1456 | 0 | for ( int index = 0; index < warDefinitions.length; index++ ) |
1457 | |
{ |
1458 | 0 | Xpp3Dom groupId = warDefinitions[index].getChild( "groupId" ); |
1459 | 0 | Xpp3Dom artifactId = warDefinitions[index].getChild( "artifactId" ); |
1460 | 0 | Xpp3Dom contextRoot = warDefinitions[index].getChild( "contextRoot" ); |
1461 | 0 | if ( groupId != null && artifactId != null && contextRoot != null && groupId.getValue() != null |
1462 | |
&& artifactId.getValue() != null && contextRoot.getValue() != null ) |
1463 | |
{ |
1464 | 0 | getLog().info( |
1465 | |
"Found context root definition for " + groupId.getValue() + ":" |
1466 | |
+ artifactId.getValue() + " " + contextRoot.getValue() ); |
1467 | 0 | if ( project.getArtifactId().equals( artifactId.getValue() ) |
1468 | |
&& project.getGroupId().equals( groupId.getValue() ) ) |
1469 | |
{ |
1470 | 0 | config.setContextName( contextRoot.getValue() ); |
1471 | |
} |
1472 | |
} |
1473 | |
else |
1474 | |
{ |
1475 | 0 | getLog().info( |
1476 | |
"Found incomplete ear configuration in " + reactorProject.getGroupId() + ":" |
1477 | |
+ reactorProject.getGroupId() + " found " |
1478 | |
+ warDefinitions[index].toString() ); |
1479 | |
} |
1480 | |
} |
1481 | |
} |
1482 | 0 | } |
1483 | |
} |
1484 | 0 | if ( config.getContextName() == null && Constants.PROJECT_PACKAGING_WAR.equals( project.getPackaging() ) ) |
1485 | |
{ |
1486 | 0 | if ( wtpContextName == null ) |
1487 | |
{ |
1488 | 0 | config.setContextName( project.getArtifactId() ); |
1489 | |
} |
1490 | 0 | else if ( "ROOT".equals(wtpContextName) ) |
1491 | |
{ |
1492 | 0 | config.setContextName( "" ); |
1493 | |
} |
1494 | |
else |
1495 | |
{ |
1496 | 0 | config.setContextName( wtpContextName ); |
1497 | |
} |
1498 | |
} |
1499 | 0 | } |
1500 | |
|
1501 | |
|
1502 | |
|
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
protected void writeConfigurationExtras( EclipseWriterConfig config ) |
1510 | |
throws MojoExecutionException |
1511 | |
{ |
1512 | |
|
1513 | 0 | } |
1514 | |
|
1515 | |
private void assertNotEmpty( String string, String elementName ) |
1516 | |
throws MojoExecutionException |
1517 | |
{ |
1518 | 0 | if ( string == null ) |
1519 | |
{ |
1520 | 0 | throw new MojoExecutionException( Messages.getString( "EclipsePlugin.missingelement", elementName ) ); |
1521 | |
} |
1522 | 0 | } |
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
|
1528 | |
|
1529 | |
|
1530 | |
|
1531 | |
|
1532 | |
protected void fillDefaultNatures( String packaging ) |
1533 | |
{ |
1534 | 0 | projectnatures = new ArrayList(); |
1535 | |
|
1536 | 0 | if ( wtpVersionFloat >= 1.0f ) |
1537 | |
{ |
1538 | 0 | projectnatures.add( NATURE_WST_FACET_CORE_NATURE ); |
1539 | |
} |
1540 | |
|
1541 | 0 | if ( isJavaProject ) |
1542 | |
{ |
1543 | 0 | if ( ajdt ) |
1544 | |
{ |
1545 | 0 | projectnatures.add( NATURE_AJDT_CORE_JAVA ); |
1546 | |
} |
1547 | |
|
1548 | 0 | projectnatures.add( NATURE_JDT_CORE_JAVA ); |
1549 | |
} |
1550 | |
|
1551 | 0 | if ( wtpVersionFloat >= 0.7f ) |
1552 | |
{ |
1553 | 0 | projectnatures.add( NATURE_WST_MODULE_CORE_NATURE ); |
1554 | |
|
1555 | 0 | if ( isJavaProject ) |
1556 | |
{ |
1557 | 0 | projectnatures.add( NATURE_JEM_WORKBENCH_JAVA_EMF ); |
1558 | |
} |
1559 | |
} |
1560 | |
|
1561 | 0 | if ( pde ) |
1562 | |
{ |
1563 | 0 | projectnatures.add( NATURE_PDE_PLUGIN ); |
1564 | |
} |
1565 | |
|
1566 | 0 | } |
1567 | |
|
1568 | |
|
1569 | |
|
1570 | |
|
1571 | |
|
1572 | |
|
1573 | |
|
1574 | |
|
1575 | |
|
1576 | |
protected void fillDefaultClasspathContainers( String packaging ) |
1577 | |
{ |
1578 | 0 | classpathContainers = new ArrayList(); |
1579 | |
|
1580 | 0 | if ( getWorkspaceConfiguration().getDefaultClasspathContainer() != null ) |
1581 | |
{ |
1582 | 0 | getLog().info( |
1583 | |
"Adding default classpath container: " |
1584 | |
+ getWorkspaceConfiguration().getDefaultClasspathContainer() ); |
1585 | 0 | classpathContainers.add( getWorkspaceConfiguration().getDefaultClasspathContainer() ); |
1586 | |
} |
1587 | 0 | if ( pde ) |
1588 | |
{ |
1589 | 0 | classpathContainers.add( REQUIRED_PLUGINS_CONTAINER ); |
1590 | |
} |
1591 | |
|
1592 | 0 | if ( ajdt ) |
1593 | |
{ |
1594 | 0 | classpathContainers.add( ASPECTJ_RT_CONTAINER ); |
1595 | |
} |
1596 | 0 | } |
1597 | |
|
1598 | |
|
1599 | |
|
1600 | |
|
1601 | |
|
1602 | |
|
1603 | |
|
1604 | |
|
1605 | |
|
1606 | |
protected void fillDefaultBuilders( String packaging ) |
1607 | |
{ |
1608 | 0 | buildcommands = new ArrayList(); |
1609 | |
|
1610 | 0 | if ( wtpVersionFloat == 0.7f ) |
1611 | |
{ |
1612 | 0 | buildcommands.add( new BuildCommand( BUILDER_WST_COMPONENT_STRUCTURAL ) ); |
1613 | |
} |
1614 | |
|
1615 | 0 | if ( isJavaProject ) |
1616 | |
{ |
1617 | 0 | if ( ajdt ) |
1618 | |
{ |
1619 | 0 | buildcommands.add( new BuildCommand( BUILDER_AJDT_CORE_JAVA ) ); |
1620 | |
} |
1621 | |
else |
1622 | |
{ |
1623 | 0 | buildcommands.add( new BuildCommand( BUILDER_JDT_CORE_JAVA ) ); |
1624 | |
} |
1625 | |
} |
1626 | |
|
1627 | 0 | if ( wtpVersionFloat >= 1.5f ) |
1628 | |
{ |
1629 | 0 | buildcommands.add( new BuildCommand( BUILDER_WST_FACET ) ); |
1630 | |
} |
1631 | |
|
1632 | 0 | if ( wtpVersionFloat >= 0.7f ) |
1633 | |
{ |
1634 | 0 | buildcommands.add( new BuildCommand( BUILDER_WST_VALIDATION ) ); |
1635 | |
} |
1636 | |
|
1637 | 0 | if ( wtpVersionFloat == 0.7f ) |
1638 | |
{ |
1639 | |
|
1640 | 0 | buildcommands.add( new BuildCommand( BUILDER_WST_COMPONENT_STRUCTURAL_DEPENDENCY_RESOLVER ) ); |
1641 | |
} |
1642 | |
|
1643 | 0 | if ( pde ) |
1644 | |
{ |
1645 | 0 | buildcommands.add( new BuildCommand( BUILDER_PDE_MANIFEST ) ); |
1646 | 0 | buildcommands.add( new BuildCommand( BUILDER_PDE_SCHEMA ) ); |
1647 | |
} |
1648 | 0 | } |
1649 | |
|
1650 | |
public final EclipseSourceDir[] buildDirectoryList( MavenProject project, File basedir, File buildOutputDirectory ) |
1651 | |
throws MojoExecutionException |
1652 | |
{ |
1653 | 2 | File projectBaseDir = project.getFile().getParentFile(); |
1654 | |
|
1655 | 2 | String mainOutput = IdeUtils.toRelativeAndFixSeparator( projectBaseDir, buildOutputDirectory, false ); |
1656 | |
|
1657 | |
|
1658 | 2 | String testOutput = null; |
1659 | 2 | boolean useStandardOutputDir = |
1660 | |
buildOutputDirectory.equals( new File( project.getBuild().getOutputDirectory() ) ); |
1661 | 2 | if ( useStandardOutputDir ) |
1662 | |
{ |
1663 | 2 | getLog().debug( |
1664 | |
"testOutput toRelativeAndFixSeparator " + projectBaseDir + " , " |
1665 | |
+ project.getBuild().getTestOutputDirectory() ); |
1666 | 2 | testOutput = |
1667 | |
IdeUtils.toRelativeAndFixSeparator( projectBaseDir, |
1668 | |
new File( project.getBuild().getTestOutputDirectory() ), false ); |
1669 | 2 | getLog().debug( "testOutput after toRelative : " + testOutput ); |
1670 | |
} |
1671 | |
|
1672 | 2 | Set mainDirectories = new LinkedHashSet(); |
1673 | |
|
1674 | 2 | extractSourceDirs( mainDirectories, project.getCompileSourceRoots(), basedir, projectBaseDir, false, null ); |
1675 | |
|
1676 | 2 | extractResourceDirs( mainDirectories, project.getBuild().getResources(), basedir, projectBaseDir, false, |
1677 | |
mainOutput ); |
1678 | |
|
1679 | 2 | Set testDirectories = new LinkedHashSet(); |
1680 | |
|
1681 | 2 | extractSourceDirs( testDirectories, project.getTestCompileSourceRoots(), basedir, projectBaseDir, true, |
1682 | |
testOutput ); |
1683 | |
|
1684 | 2 | extractResourceDirs( testDirectories, project.getBuild().getTestResources(), basedir, projectBaseDir, true, |
1685 | |
testOutput ); |
1686 | |
|
1687 | |
|
1688 | 2 | Set directories = new LinkedHashSet(); |
1689 | |
|
1690 | |
|
1691 | 2 | boolean testBeforeMain = isMavenVersion( "[2.0.8,)" ); |
1692 | |
|
1693 | |
|
1694 | 2 | if (testSourcesLast) |
1695 | |
{ |
1696 | 0 | testBeforeMain = false; |
1697 | |
} |
1698 | |
|
1699 | 2 | if ( testBeforeMain ) |
1700 | |
{ |
1701 | 2 | directories.addAll( testDirectories ); |
1702 | 2 | directories.removeAll( mainDirectories ); |
1703 | 2 | directories.addAll( mainDirectories ); |
1704 | |
} |
1705 | |
else |
1706 | |
{ |
1707 | 0 | directories.addAll( mainDirectories ); |
1708 | 0 | directories.addAll( testDirectories ); |
1709 | |
} |
1710 | 2 | if ( ajdt ) |
1711 | 0 | extractAspectDirs( directories, project, basedir, projectBaseDir, testOutput ); |
1712 | 2 | return (EclipseSourceDir[]) directories.toArray( new EclipseSourceDir[directories.size()] ); |
1713 | |
} |
1714 | |
|
1715 | |
private void extractSourceDirs( Set directories, List sourceRoots, File basedir, File projectBaseDir, boolean test, |
1716 | |
String output ) |
1717 | |
throws MojoExecutionException |
1718 | |
{ |
1719 | 4 | for ( Iterator it = sourceRoots.iterator(); it.hasNext(); ) |
1720 | |
{ |
1721 | |
|
1722 | 0 | File sourceRootFile = new File( (String) it.next() ); |
1723 | |
|
1724 | 0 | if ( sourceRootFile.isDirectory() ) |
1725 | |
{ |
1726 | 0 | String sourceRoot = |
1727 | |
IdeUtils.toRelativeAndFixSeparator( projectBaseDir, sourceRootFile, |
1728 | |
!projectBaseDir.equals( basedir ) ); |
1729 | |
|
1730 | 0 | directories.add( new EclipseSourceDir( sourceRoot, output, false, test, sourceIncludes, sourceExcludes, |
1731 | |
false ) ); |
1732 | |
} |
1733 | 0 | } |
1734 | 4 | } |
1735 | |
|
1736 | |
final void extractResourceDirs( Set directories, List resources, File basedir, File workspaceProjectBaseDir, |
1737 | |
boolean test, final String output ) |
1738 | |
throws MojoExecutionException |
1739 | |
{ |
1740 | 16 | for ( Iterator it = resources.iterator(); it.hasNext(); ) |
1741 | |
{ |
1742 | 14 | Resource resource = (Resource) it.next(); |
1743 | |
|
1744 | 14 | getLog().debug( "Processing resource dir: " + resource.getDirectory() ); |
1745 | |
|
1746 | 14 | List excludes = new ArrayList( resource.getExcludes() ); |
1747 | |
|
1748 | |
|
1749 | 14 | excludes.add( JAVA_FILE_PATTERN ); |
1750 | |
|
1751 | |
|
1752 | |
|
1753 | |
|
1754 | 14 | File resourceDirectory = new File( resource.getDirectory() ); |
1755 | |
|
1756 | 14 | if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() ) |
1757 | |
{ |
1758 | 0 | getLog().debug( "Resource dir: " + resourceDirectory + " either missing or not a directory." ); |
1759 | 0 | continue; |
1760 | |
} |
1761 | |
|
1762 | 14 | String resourcePath = |
1763 | |
IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, resourceDirectory, |
1764 | |
!workspaceProjectBaseDir.equals( basedir ) ); |
1765 | 14 | String thisOutput = output; |
1766 | 14 | if ( thisOutput != null ) |
1767 | |
{ |
1768 | |
|
1769 | 14 | File outputFile = new File( thisOutput ); |
1770 | 14 | if ( !outputFile.isAbsolute() ) |
1771 | |
{ |
1772 | 14 | outputFile = new File( workspaceProjectBaseDir, thisOutput ); |
1773 | |
} |
1774 | |
|
1775 | 14 | outputFile.mkdirs(); |
1776 | |
|
1777 | 14 | if ( !StringUtils.isEmpty( resource.getTargetPath() ) ) |
1778 | |
{ |
1779 | 2 | outputFile = new File( outputFile, resource.getTargetPath() ); |
1780 | |
|
1781 | 2 | outputFile.mkdirs(); |
1782 | |
} |
1783 | |
|
1784 | 14 | getLog().debug( |
1785 | |
"Making relative and fixing separator: { " + workspaceProjectBaseDir + ", " |
1786 | |
+ outputFile + ", false }." ); |
1787 | 14 | thisOutput = IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, outputFile, false ); |
1788 | |
} |
1789 | |
|
1790 | 14 | EclipseSourceDir resourceDir = |
1791 | |
new EclipseSourceDir( resourcePath, thisOutput, true, test, resource.getIncludes(), excludes, |
1792 | |
resource.isFiltering() ); |
1793 | |
|
1794 | 14 | if ( !directories.add( resourceDir ) ) |
1795 | |
{ |
1796 | 0 | EclipseSourceDir originalDir = (EclipseSourceDir) get( directories, resourceDir ); |
1797 | |
|
1798 | 0 | boolean merged = originalDir.merge(resourceDir); |
1799 | 0 | if (merged) |
1800 | |
{ |
1801 | 0 | getLog().info( |
1802 | |
"Resource directory's path matches an existing source directory. Resources have been merged with the source directory " |
1803 | |
+ originalDir.getPath()); |
1804 | |
} |
1805 | |
else |
1806 | |
{ |
1807 | 0 | getLog() |
1808 | |
.info( |
1809 | |
"Resource directory's path matches an existing source directory but \"test\", \"filtering\" or \"output\" were different." |
1810 | |
+ "The resulting eclipse configuration may not accurately reflect the project configuration for " |
1811 | |
+ originalDir.getPath()); |
1812 | |
} |
1813 | |
|
1814 | |
} |
1815 | 14 | } |
1816 | 16 | } |
1817 | |
|
1818 | |
|
1819 | |
|
1820 | |
|
1821 | |
|
1822 | |
|
1823 | |
|
1824 | |
|
1825 | |
|
1826 | |
private Object get( Set set, Object o ) |
1827 | |
{ |
1828 | 0 | Iterator iter = set.iterator(); |
1829 | 0 | while ( iter.hasNext() ) |
1830 | |
{ |
1831 | 0 | Object item = iter.next(); |
1832 | 0 | if ( o.equals( item ) ) |
1833 | |
{ |
1834 | 0 | return item; |
1835 | |
} |
1836 | 0 | } |
1837 | 0 | return null; |
1838 | |
} |
1839 | |
|
1840 | |
private void extractAspectDirs( Set directories, MavenProject project, File basedir, File projectBaseDir, |
1841 | |
String testOutput ) |
1842 | |
throws MojoExecutionException |
1843 | |
{ |
1844 | 0 | Xpp3Dom configuration = getAspectjConfiguration( project ); |
1845 | 0 | if ( configuration != null ) |
1846 | |
{ |
1847 | 0 | String aspectDirectory = DEFAULT_ASPECT_DIRECTORY; |
1848 | 0 | Xpp3Dom aspectDirectoryElement = configuration.getChild( ASPECT_DIRECTORY ); |
1849 | 0 | if ( aspectDirectoryElement != null ) |
1850 | |
{ |
1851 | 0 | aspectDirectory = aspectDirectoryElement.getValue(); |
1852 | |
} |
1853 | |
|
1854 | 0 | File aspectDirectoryFile = new File( basedir, aspectDirectory ); |
1855 | 0 | if ( aspectDirectoryFile.exists() && aspectDirectoryFile.isDirectory() ) |
1856 | |
{ |
1857 | 0 | String sourceRoot = |
1858 | |
IdeUtils.toRelativeAndFixSeparator( projectBaseDir, aspectDirectoryFile, |
1859 | |
!projectBaseDir.equals( basedir ) ); |
1860 | |
|
1861 | 0 | directories.add( new EclipseSourceDir( sourceRoot, null, false, false, sourceIncludes, sourceExcludes, |
1862 | |
false ) ); |
1863 | |
} |
1864 | |
|
1865 | 0 | String testAspectDirectory = DEFAULT_TEST_ASPECT_DIRECTORY; |
1866 | 0 | Xpp3Dom testAspectDirectoryElement = configuration.getChild( TEST_ASPECT_DIRECTORY ); |
1867 | 0 | if ( testAspectDirectoryElement != null ) |
1868 | |
{ |
1869 | 0 | testAspectDirectory = testAspectDirectoryElement.getValue(); |
1870 | |
} |
1871 | |
|
1872 | 0 | File testAspectDirectoryFile = new File( basedir, testAspectDirectory ); |
1873 | 0 | if ( testAspectDirectoryFile.exists() && testAspectDirectoryFile.isDirectory() ) |
1874 | |
{ |
1875 | 0 | String sourceRoot = |
1876 | |
IdeUtils.toRelativeAndFixSeparator( projectBaseDir, testAspectDirectoryFile, |
1877 | |
!projectBaseDir.equals( basedir ) ); |
1878 | |
|
1879 | 0 | directories.add( new EclipseSourceDir( sourceRoot, testOutput, false, true, sourceIncludes, |
1880 | |
sourceExcludes, false ) ); |
1881 | |
} |
1882 | |
} |
1883 | 0 | } |
1884 | |
|
1885 | |
private boolean enableAjdt( MavenProject project ) |
1886 | |
{ |
1887 | 0 | boolean enable = false; |
1888 | 0 | List buildPlugins = project.getBuildPlugins(); |
1889 | 0 | for ( Iterator it = buildPlugins.iterator(); it.hasNext(); ) |
1890 | |
{ |
1891 | 0 | Plugin plugin = (Plugin) it.next(); |
1892 | 0 | if ( plugin.getGroupId().equals( ORG_CODEHAUS_MOJO ) |
1893 | |
&& plugin.getArtifactId().equals( ASPECTJ_MAVEN_PLUGIN ) ) |
1894 | |
{ |
1895 | 0 | enable = true; |
1896 | 0 | break; |
1897 | |
} |
1898 | 0 | } |
1899 | |
|
1900 | 0 | return enable; |
1901 | |
} |
1902 | |
|
1903 | |
private Xpp3Dom getAspectjConfiguration( MavenProject project ) |
1904 | |
{ |
1905 | 0 | Xpp3Dom configuration = null; |
1906 | 0 | List buildPlugins = project.getBuildPlugins(); |
1907 | 0 | for ( Iterator it = buildPlugins.iterator(); it.hasNext(); ) |
1908 | |
{ |
1909 | 0 | Plugin plugin = (Plugin) it.next(); |
1910 | 0 | if ( plugin.getGroupId().equals( ORG_CODEHAUS_MOJO ) |
1911 | |
&& plugin.getArtifactId().equals( ASPECTJ_MAVEN_PLUGIN ) ) |
1912 | |
{ |
1913 | 0 | configuration = (Xpp3Dom) plugin.getConfiguration(); |
1914 | 0 | break; |
1915 | |
} |
1916 | 0 | } |
1917 | |
|
1918 | 0 | return configuration; |
1919 | |
} |
1920 | |
|
1921 | |
private void buildAspectjDeps( IdeDependency[] deps ) |
1922 | |
throws MojoExecutionException |
1923 | |
{ |
1924 | 0 | Xpp3Dom configuration = getAspectjConfiguration( executedProject ); |
1925 | 0 | if ( configuration != null ) |
1926 | |
{ |
1927 | 0 | Xpp3Dom aspectLibrariesParent = configuration.getChild( ASPECT_LIBRARIES ); |
1928 | 0 | if ( aspectLibrariesParent != null ) |
1929 | |
{ |
1930 | 0 | Xpp3Dom[] aspectLibraries = aspectLibrariesParent.getChildren( ASPECT_LIBRARY ); |
1931 | 0 | outerLoop: for ( int i = 0; i < aspectLibraries.length; i++ ) |
1932 | |
{ |
1933 | 0 | String artifactId = aspectLibraries[i].getChild( POM_ELT_ARTIFACT_ID ).getValue(); |
1934 | 0 | String groupId = aspectLibraries[i].getChild( POM_ELT_GROUP_ID ).getValue(); |
1935 | 0 | for ( int j = 0; j < deps.length; j++ ) |
1936 | |
{ |
1937 | 0 | if ( deps[j].getArtifactId().equals( artifactId ) && deps[j].getGroupId().equals( groupId ) ) |
1938 | |
{ |
1939 | 0 | deps[j].setAjdtDependency( true ); |
1940 | 0 | continue outerLoop; |
1941 | |
} |
1942 | |
} |
1943 | |
|
1944 | 0 | throw new MojoExecutionException( "AspectLibrary is not a dependency of project" ); |
1945 | |
} |
1946 | |
} |
1947 | |
} |
1948 | 0 | } |
1949 | |
|
1950 | |
private void buildAjdtWeaveDeps( IdeDependency[] deps ) |
1951 | |
throws MojoExecutionException |
1952 | |
{ |
1953 | 0 | Xpp3Dom configuration = getAspectjConfiguration( executedProject ); |
1954 | 0 | if ( configuration != null ) |
1955 | |
{ |
1956 | 0 | Xpp3Dom weaveDependenciesParent = configuration.getChild( WEAVE_DEPENDENCIES ); |
1957 | 0 | if ( weaveDependenciesParent != null ) |
1958 | |
{ |
1959 | 0 | Xpp3Dom[] weaveDependencies = weaveDependenciesParent.getChildren( WEAVE_DEPENDENCY ); |
1960 | 0 | outerLoop: for ( int i = 0; i < weaveDependencies.length; i++ ) |
1961 | |
{ |
1962 | 0 | String artifactId = weaveDependencies[i].getChild( POM_ELT_ARTIFACT_ID ).getValue(); |
1963 | 0 | String groupId = weaveDependencies[i].getChild( POM_ELT_GROUP_ID ).getValue(); |
1964 | 0 | for ( int j = 0; j < deps.length; j++ ) |
1965 | |
{ |
1966 | 0 | if ( deps[j].getArtifactId().equals( artifactId ) && deps[j].getGroupId().equals( groupId ) ) |
1967 | |
{ |
1968 | 0 | deps[j].setAjdtWeaveDependency( true ); |
1969 | 0 | continue outerLoop; |
1970 | |
} |
1971 | |
} |
1972 | |
|
1973 | 0 | throw new MojoExecutionException( "WeaveDependency is not a dependency of project" ); |
1974 | |
} |
1975 | |
} |
1976 | |
} |
1977 | 0 | } |
1978 | |
|
1979 | |
|
1980 | |
|
1981 | |
|
1982 | |
public String getProjectNameForArifact( Artifact artifact ) |
1983 | |
{ |
1984 | 0 | IdeDependency[] workspaceArtefacts = getWorkspaceArtefacts(); |
1985 | 0 | for ( int index = 0; workspaceArtefacts != null && index < workspaceArtefacts.length; index++ ) |
1986 | |
{ |
1987 | 0 | IdeDependency workspaceArtefact = workspaceArtefacts[index]; |
1988 | 0 | if ( workspaceArtefact.isAddedToClasspath() |
1989 | |
&& workspaceArtefact.getGroupId().equals( artifact.getGroupId() ) |
1990 | |
&& workspaceArtefact.getArtifactId().equals( artifact.getArtifactId() ) ) |
1991 | |
{ |
1992 | 0 | if ( workspaceArtefact.getVersion().equals( artifact.getBaseVersion() ) ) |
1993 | |
{ |
1994 | 0 | return workspaceArtefact.getEclipseProjectName(); |
1995 | |
} |
1996 | |
} |
1997 | |
} |
1998 | 0 | MavenProject reactorProject = getReactorProject( artifact ); |
1999 | 0 | if ( reactorProject != null ) |
2000 | |
{ |
2001 | 0 | return IdeUtils.getProjectName( getProjectNameTemplateForMavenProject( reactorProject ), artifact ); |
2002 | |
} |
2003 | 0 | return IdeUtils.getProjectName( getProjectNameTemplate(), artifact ); |
2004 | |
} |
2005 | |
|
2006 | |
|
2007 | |
|
2008 | |
|
2009 | |
|
2010 | |
private String getProjectNameTemplateForMavenProject( MavenProject mavenProject ) |
2011 | |
{ |
2012 | 0 | String projectNameTemplate = null; |
2013 | 0 | boolean addVersionToProjectName = false; |
2014 | 0 | boolean addGroupIdToProjectName = false; |
2015 | |
|
2016 | 0 | Build build = mavenProject.getBuild(); |
2017 | 0 | if ( build != null ) |
2018 | |
{ |
2019 | 0 | String eclipsePlugin = "org.apache.maven.plugins:maven-eclipse-plugin"; |
2020 | 0 | Plugin plugin = (Plugin) build.getPluginsAsMap().get( eclipsePlugin ); |
2021 | 0 | if ( plugin == null && build.getPluginManagement() != null ) |
2022 | |
{ |
2023 | 0 | plugin = (Plugin) build.getPluginManagement().getPluginsAsMap().get( eclipsePlugin ); |
2024 | |
} |
2025 | 0 | if ( plugin != null ) |
2026 | |
{ |
2027 | 0 | Xpp3Dom config = (Xpp3Dom) plugin.getConfiguration(); |
2028 | 0 | if ( config != null ) |
2029 | |
{ |
2030 | 0 | Xpp3Dom projectNameTemplateNode = config.getChild( "projectNameTemplate" ); |
2031 | 0 | if ( projectNameTemplateNode != null ) |
2032 | |
{ |
2033 | 0 | projectNameTemplate = projectNameTemplateNode.getValue(); |
2034 | |
} |
2035 | 0 | Xpp3Dom addVersionToProjectNameNode = config.getChild( "addVersionToProjectName" ); |
2036 | 0 | addVersionToProjectName = addVersionToProjectNameNode != null; |
2037 | 0 | Xpp3Dom addGroupIdToProjectNameNode = config.getChild( "addGroupIdToProjectName" ); |
2038 | 0 | addGroupIdToProjectName = addGroupIdToProjectNameNode != null; |
2039 | |
} |
2040 | |
} |
2041 | |
} |
2042 | 0 | return IdeUtils.calculateProjectNameTemplate( projectNameTemplate, addVersionToProjectName, |
2043 | |
addGroupIdToProjectName, getLog() ); |
2044 | |
} |
2045 | |
|
2046 | |
|
2047 | |
|
2048 | |
|
2049 | |
protected final IdeDependency[] getWorkspaceArtefacts() |
2050 | |
{ |
2051 | 0 | return getWorkspaceConfiguration().getWorkspaceArtefacts(); |
2052 | |
} |
2053 | |
|
2054 | |
public final WorkspaceConfiguration getWorkspaceConfiguration() |
2055 | |
{ |
2056 | 0 | if ( workspaceConfiguration == null ) |
2057 | |
{ |
2058 | 0 | workspaceConfiguration = new WorkspaceConfiguration(); |
2059 | 0 | locateWorkspace(); |
2060 | 0 | getLog().info( Messages.getString( "EclipsePlugin.workspace", workspace ) ); |
2061 | 0 | workspaceConfiguration.setWorkspaceDirectory( workspace ); |
2062 | |
|
2063 | 0 | new ReadWorkspaceLocations().init( getLog(), workspaceConfiguration, project, wtpdefaultserver ); |
2064 | |
} |
2065 | 0 | return workspaceConfiguration; |
2066 | |
} |
2067 | |
|
2068 | |
|
2069 | |
|
2070 | |
|
2071 | |
private void locateWorkspace() |
2072 | |
{ |
2073 | 0 | if ( workspace == null ) |
2074 | |
{ |
2075 | 0 | File currentWorkingDirectory = new File( "." ).getAbsoluteFile(); |
2076 | 0 | while ( currentWorkingDirectory != null ) |
2077 | |
{ |
2078 | 0 | File metadataDirectory = new File( currentWorkingDirectory, ".metadata" ); |
2079 | 0 | logger.debug( "Checking for eclipse workspace at " + currentWorkingDirectory ); |
2080 | 0 | if ( metadataDirectory.exists() && metadataDirectory.isDirectory() ) |
2081 | |
{ |
2082 | 0 | logger.debug( " Found workspace at " + currentWorkingDirectory ); |
2083 | 0 | workspace = currentWorkingDirectory; |
2084 | 0 | return; |
2085 | |
} |
2086 | 0 | currentWorkingDirectory = currentWorkingDirectory.getParentFile(); |
2087 | 0 | } |
2088 | |
} |
2089 | 0 | } |
2090 | |
|
2091 | |
public final List getExcludes() |
2092 | |
{ |
2093 | 0 | return excludes; |
2094 | |
} |
2095 | |
|
2096 | |
|
2097 | |
|
2098 | |
|
2099 | |
|
2100 | |
|
2101 | |
|
2102 | |
|
2103 | |
protected boolean isAvailableAsAReactorProject( Artifact artifact ) |
2104 | |
{ |
2105 | 0 | MavenProject project = getReactorProject( artifact ); |
2106 | 0 | return ( project != null && new File( project.getBasedir(), ".project" ).exists() ) ; |
2107 | |
} |
2108 | |
|
2109 | |
|
2110 | |
|
2111 | |
|
2112 | |
|
2113 | |
|
2114 | |
|
2115 | |
private boolean isAvailableAsAWorkspaceProject( Artifact artifact ) |
2116 | |
{ |
2117 | 0 | IdeDependency[] workspaceArtefacts = getWorkspaceArtefacts(); |
2118 | 0 | for ( int index = 0; workspaceArtefacts != null && index < workspaceArtefacts.length; index++ ) |
2119 | |
{ |
2120 | 0 | IdeDependency workspaceArtefact = workspaceArtefacts[index]; |
2121 | 0 | if ( workspaceArtefact.getGroupId().equals( artifact.getGroupId() ) |
2122 | |
&& workspaceArtefact.getArtifactId().equals( artifact.getArtifactId() ) ) |
2123 | |
{ |
2124 | 0 | if ( workspaceArtefact.getVersion().equals( artifact.getBaseVersion() ) ) |
2125 | |
{ |
2126 | 0 | workspaceArtefact.setAddedToClasspath( true ); |
2127 | 0 | getLog().debug( "Using workspace project: " + workspaceArtefact.getEclipseProjectName() ); |
2128 | 0 | return true; |
2129 | |
} |
2130 | |
else |
2131 | |
{ |
2132 | 0 | getLog().info( |
2133 | |
"Artifact " |
2134 | |
+ artifact.getId() |
2135 | |
+ " already available as a workspace project, but with different version. Expected: " |
2136 | |
+ artifact.getBaseVersion() + ", found: " + workspaceArtefact.getVersion() ); |
2137 | |
} |
2138 | |
} |
2139 | |
} |
2140 | 0 | return false; |
2141 | |
} |
2142 | |
|
2143 | |
|
2144 | |
|
2145 | |
|
2146 | |
|
2147 | |
|
2148 | |
|
2149 | |
protected final boolean hasToResolveJar( Artifact art ) |
2150 | |
{ |
2151 | 0 | return !( getUseProjectReferences() && isAvailableAsAReactorProject( art ) ) |
2152 | |
|| ( limitProjectReferencesToWorkspace && !( getUseProjectReferences() && isAvailableAsAWorkspaceProject( art ) ) ); |
2153 | |
} |
2154 | |
|
2155 | |
|
2156 | |
|
2157 | |
|
2158 | |
|
2159 | |
|
2160 | |
|
2161 | |
protected final boolean useProjectReference( Artifact art ) |
2162 | |
{ |
2163 | 0 | boolean isReactorProject = getUseProjectReferences() && isAvailableAsAReactorProject( art ); |
2164 | 0 | boolean isWorkspaceProject = getUseProjectReferences() && isAvailableAsAWorkspaceProject( art ); |
2165 | 0 | return ( isReactorProject && !limitProjectReferencesToWorkspace ) || |
2166 | |
( limitProjectReferencesToWorkspace && isWorkspaceProject ) || |
2167 | |
( !isReactorProject && isWorkspaceProject ); |
2168 | |
} |
2169 | |
} |