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