1 package org.apache.maven.model.converter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.model.Build;
23 import org.apache.maven.model.CiManagement;
24 import org.apache.maven.model.Contributor;
25 import org.apache.maven.model.Dependency;
26 import org.apache.maven.model.DeploymentRepository;
27 import org.apache.maven.model.Developer;
28 import org.apache.maven.model.DistributionManagement;
29 import org.apache.maven.model.IssueManagement;
30 import org.apache.maven.model.License;
31 import org.apache.maven.model.MailingList;
32 import org.apache.maven.model.Model;
33 import org.apache.maven.model.Notifier;
34 import org.apache.maven.model.Organization;
35 import org.apache.maven.model.Plugin;
36 import org.apache.maven.model.ReportPlugin;
37 import org.apache.maven.model.Reporting;
38 import org.apache.maven.model.Resource;
39 import org.apache.maven.model.Scm;
40 import org.apache.maven.model.Site;
41 import org.apache.maven.model.v3_0_0.UnitTest;
42 import org.apache.maven.shared.utils.StringUtils;
43 import org.codehaus.plexus.util.xml.Xpp3Dom;
44
45 import java.util.ArrayList;
46 import java.util.HashMap;
47 import java.util.Iterator;
48 import java.util.List;
49 import java.util.Map;
50 import java.util.Properties;
51 import java.util.regex.Matcher;
52 import java.util.regex.Pattern;
53
54
55
56
57
58 public class PomV3ToV4Translator
59 implements ModelConverter
60 {
61 private transient List discoveredPlugins = new ArrayList();
62
63 private List warnings;
64
65
66
67
68
69
70 private Map model3ReportPlugins = new HashMap();
71
72 public PomV3ToV4Translator()
73 {
74
75
76 model3ReportPlugins.put( "maven-cobertura-plugin", "maven-plugins" );
77 model3ReportPlugins.put( "maven-findbugs-plugin", "maven-plugins" );
78 model3ReportPlugins.put( "maven-javancss-plugin", "maven-plugins" );
79 }
80
81 public Model translate( org.apache.maven.model.v3_0_0.Model v3Model )
82 throws PomTranslationException
83 {
84 warnings = new ArrayList();
85
86 try
87 {
88 String groupId = format( v3Model.getGroupId() );
89 String artifactId = format( v3Model.getArtifactId() );
90
91 String id = v3Model.getId();
92
93 if ( StringUtils.isNotEmpty( id ) )
94 {
95 if ( StringUtils.isEmpty( groupId ) )
96 {
97 int plusIdx = id.indexOf( "+" );
98 if ( plusIdx > -1 )
99 {
100 groupId = id.substring( 0, plusIdx );
101 }
102 else
103 {
104 groupId = id;
105 }
106 }
107
108 if ( StringUtils.isEmpty( artifactId ) )
109 {
110 artifactId = format( id );
111 }
112 }
113
114 String version = format( v3Model.getCurrentVersion() );
115
116 if ( version == null )
117 {
118 version = format( v3Model.getVersion() );
119 }
120
121 PomKey pomKey = new PomKey( groupId, artifactId, version );
122
123 Properties properties = v3Model.getProperties();
124
125 warnOfUnsupportedMainModelElements( v3Model );
126
127 Model model = new Model();
128 model.setArtifactId( artifactId );
129
130
131
132
133 model.setDependencies( translateDependencies( v3Model.getDependencies() ) );
134
135 model.setBuild( translateBuild( v3Model.getBuild() ) );
136 model.setCiManagement( translateCiManagementInfo( v3Model.getBuild() ) );
137 model.setContributors( translateContributors( v3Model.getContributors() ) );
138
139 model.setDescription( v3Model.getDescription() );
140 model.setDevelopers( translateDevelopers( v3Model.getDevelopers() ) );
141
142 model.setDistributionManagement( translateDistributionManagement( pomKey, v3Model ) );
143
144 model.setGroupId( groupId );
145 model.setInceptionYear( v3Model.getInceptionYear() );
146 model.setIssueManagement( translateIssueManagement( v3Model ) );
147
148 model.setLicenses( translateLicenses( v3Model.getLicenses() ) );
149 model.setMailingLists( translateMailingLists( v3Model.getMailingLists() ) );
150 model.setModelVersion( "4.0.0" );
151 model.setName( v3Model.getName() );
152 model.setOrganization( translateOrganization( v3Model.getOrganization() ) );
153 model.setPackaging( "jar" );
154
155 model.setReporting( translateReports( v3Model.getReports() ) );
156 model.setScm( translateScm( v3Model ) );
157 model.setUrl( v3Model.getUrl() );
158
159 model.setProperties( properties );
160
161 model.setVersion( version );
162
163 return model;
164 }
165 finally
166 {
167 this.discoveredPlugins.clear();
168 }
169 }
170
171 private String format( String source )
172 {
173 return source == null ? null : source.replace( '+', '-' );
174 }
175
176 private CiManagement translateCiManagementInfo( org.apache.maven.model.v3_0_0.Build v3Build )
177 {
178 CiManagement ciMgmt = null;
179
180 if ( v3Build != null )
181 {
182 String nagEmailAddress = v3Build.getNagEmailAddress();
183
184 if ( StringUtils.isNotEmpty( nagEmailAddress ) )
185 {
186 Notifier notifier = new Notifier();
187
188 notifier.setType( "mail" );
189 notifier.addConfiguration( "address", nagEmailAddress );
190
191 ciMgmt = new CiManagement();
192 ciMgmt.addNotifier( notifier );
193 }
194 }
195
196 return ciMgmt;
197 }
198
199 private void warnOfUnsupportedMainModelElements( org.apache.maven.model.v3_0_0.Model v3Model )
200 {
201 if ( StringUtils.isNotEmpty( v3Model.getExtend() ) )
202 {
203 warnings.add( "Ignoring non-portable parent declaration: " + v3Model.getExtend() );
204 }
205
206 if ( StringUtils.isNotEmpty( v3Model.getGumpRepositoryId() ) )
207 {
208 warnings.add( "Ignoring gump repository id: \'" + v3Model.getGumpRepositoryId()
209 + "\'. This is not supported in v4 POMs." );
210 }
211
212 if ( notEmpty( v3Model.getVersions() ) )
213 {
214 warnings.add( "Ignoring <versions/> section. This is not supported in v4 POMs." );
215 }
216
217 if ( notEmpty( v3Model.getBranches() ) )
218 {
219 warnings.add( "Ignoring <branches/> section. This is not supported in v4 POMs." );
220 }
221
222 Properties v3ModelProperties = v3Model.getProperties();
223
224 if ( StringUtils.isNotEmpty( v3Model.getPackage() ) )
225 {
226 warnings.add( "Ignoring <package/>. It is not supported in v4 POMs." );
227 }
228
229 if ( notEmpty( v3Model.getPackageGroups() ) )
230 {
231 warnings.add( "Ignoring <packageGroups/> section. It is not supported in v4 POMs." );
232 }
233
234 if ( StringUtils.isNotEmpty( v3Model.getLogo() ) )
235 {
236 warnings.add( "Ignoring <logo/> for project. It is not supported in v4 POMs." );
237 }
238
239 if ( StringUtils.isNotEmpty( v3Model.getShortDescription() ) )
240 {
241 warnings.add( "Ignoring <shortDescription/>. It is not supported in v4 POMs." );
242 }
243 }
244
245 private Scm translateScm( org.apache.maven.model.v3_0_0.Model v3Model )
246 {
247 Scm scm = null;
248
249 org.apache.maven.model.v3_0_0.Repository repo = v3Model.getRepository();
250 if ( repo != null )
251 {
252 scm = new Scm();
253 scm.setConnection( repo.getConnection() );
254 scm.setDeveloperConnection( repo.getDeveloperConnection() );
255 scm.setUrl( repo.getUrl() );
256 }
257
258 return scm;
259 }
260
261 private Reporting translateReports( List v3Reports )
262 {
263 Reporting reports = null;
264 if ( v3Reports != null && !v3Reports.isEmpty() )
265 {
266 reports = new Reporting();
267 for ( Iterator it = v3Reports.iterator(); it.hasNext(); )
268 {
269 String reportName = (String) it.next();
270
271 Pattern pluginNamePattern = Pattern.compile( "maven-(.+)-plugin" );
272 Matcher matcher = pluginNamePattern.matcher( reportName );
273
274 if ( !matcher.matches() )
275 {
276 warnings.add(
277 "Non-standard report: \'" + reportName + "\'. Skipping this one." );
278 }
279 else
280 {
281 ReportPlugin reportPlugin = new ReportPlugin();
282
283 reportPlugin.setGroupId( findReportPluginGroupId( reportName ) );
284
285 reportPlugin.setArtifactId( reportName );
286
287 StringBuffer info = new StringBuffer();
288
289 info.append( "Using some derived information for report: \'" ).append( reportName )
290 .append( "\'.\n" )
291 .append( "\to groupId: \'" ).append( reportPlugin.getGroupId() ).append( "\'\n" )
292 .append( "\to artifactId: \'" ).append( reportName ).append( "\'\n" )
293 .append( "\to goal: \'report\'\n" )
294 .append( "\n" )
295 .append( "These values were extracted using the v3 report naming convention," )
296 .append( " but may be wrong." );
297
298 warnings.add( info.toString() );
299
300 reports.addPlugin( reportPlugin );
301 }
302 }
303 }
304
305 return reports;
306 }
307
308
309
310
311
312
313
314 private String findReportPluginGroupId( String artifactId )
315 {
316 String groupId = (String) model3ReportPlugins.get( artifactId );
317 if ( groupId == null )
318 {
319 groupId = "org.apache.maven.plugins";
320 }
321 return groupId;
322 }
323
324 private Organization translateOrganization( org.apache.maven.model.v3_0_0.Organization v3Organization )
325 {
326 Organization organization = null;
327
328 if ( v3Organization != null )
329 {
330 organization = new Organization();
331
332 organization.setName( v3Organization.getName() );
333 organization.setUrl( v3Organization.getUrl() );
334
335 if ( StringUtils.isNotEmpty( v3Organization.getLogo() ) )
336 {
337 warnings.add( "Ignoring <organization><logo/></organization>. It is not supported in v4 POMs." );
338 }
339 }
340
341 return organization;
342 }
343
344 private List translateMailingLists( List v3MailingLists )
345 {
346 List mailingLists = new ArrayList();
347
348 if ( notEmpty( v3MailingLists ) )
349 {
350 for ( Iterator it = v3MailingLists.iterator(); it.hasNext(); )
351 {
352 org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it
353 .next();
354 MailingList list = new MailingList();
355 list.setArchive( v3List.getArchive() );
356 list.setName( v3List.getName() );
357 list.setSubscribe( v3List.getSubscribe() );
358 list.setUnsubscribe( v3List.getUnsubscribe() );
359
360 mailingLists.add( list );
361 }
362 }
363
364 return mailingLists;
365 }
366
367 private List translateLicenses( List v3Licenses )
368 {
369 List licenses = new ArrayList();
370
371 if ( notEmpty( v3Licenses ) )
372 {
373 for ( Iterator it = v3Licenses.iterator(); it.hasNext(); )
374 {
375 org.apache.maven.model.v3_0_0.License v3License = (org.apache.maven.model.v3_0_0.License) it.next();
376 License license = new License();
377 license.setComments( v3License.getComments() );
378 license.setDistribution( v3License.getDistribution() );
379 license.setName( v3License.getName() );
380 license.setUrl( v3License.getUrl() );
381
382 licenses.add( license );
383 }
384 }
385
386 return licenses;
387 }
388
389 private IssueManagement translateIssueManagement( org.apache.maven.model.v3_0_0.Model v3Model )
390 {
391 IssueManagement issueMgmt = null;
392
393 String issueTrackingUrl = v3Model.getIssueTrackingUrl();
394 if ( StringUtils.isNotEmpty( issueTrackingUrl ) )
395 {
396 issueMgmt = new IssueManagement();
397 issueMgmt.setUrl( issueTrackingUrl );
398 }
399
400 return issueMgmt;
401 }
402
403 private DistributionManagement translateDistributionManagement( PomKey pomKey,
404 org.apache.maven.model.v3_0_0.Model v3Model )
405 throws PomTranslationException
406 {
407 DistributionManagement distributionManagement = new DistributionManagement();
408
409 Site site = null;
410
411 String siteAddress = v3Model.getSiteAddress();
412
413 String siteDirectory = v3Model.getSiteDirectory();
414
415 if ( StringUtils.isEmpty( siteAddress ) )
416 {
417 if ( !StringUtils.isEmpty( siteDirectory ) )
418 {
419 site = new Site();
420
421 site.setId( "default" );
422
423 site.setName( "Default Site" );
424
425 site.setUrl( "file://" + siteDirectory );
426 }
427 }
428 else
429 {
430 if ( StringUtils.isEmpty( siteDirectory ) )
431 {
432 throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
433 "Missing 'siteDirectory': Both siteAddress and siteDirectory must be"
434 + " set at the same time." );
435 }
436
437 site = new Site();
438
439 site.setId( "default" );
440
441 site.setName( "Default Site" );
442
443 StringBuffer url = new StringBuffer( "scp://" );
444 url.append( siteAddress );
445 if ( !siteAddress.endsWith( "/" ) && !siteDirectory.startsWith( "/" ) )
446 {
447 url.append( "/" );
448 }
449 url.append( siteDirectory );
450 site.setUrl( url.toString() );
451 }
452
453 distributionManagement.setSite( site );
454
455 String distributionSite = v3Model.getDistributionSite();
456
457 String distributionDirectory = v3Model.getDistributionDirectory();
458
459 DeploymentRepository repository = null;
460
461 if ( StringUtils.isEmpty( distributionSite ) )
462 {
463 if ( !StringUtils.isEmpty( distributionDirectory ) )
464 {
465 repository = new DeploymentRepository();
466
467 repository.setId( "default" );
468
469 repository.setName( "Default Repository" );
470
471 repository.setUrl( "file://" + distributionDirectory );
472
473
474 }
475 }
476 else
477 {
478 if ( StringUtils.isEmpty( distributionDirectory ) )
479 {
480 throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
481 "Missing 'distributionDirectory': must be set if 'distributionSite'"
482 + "is set." );
483 }
484
485 repository = new DeploymentRepository();
486
487 repository.setId( "default" );
488
489 repository.setName( "Default Repository" );
490
491 repository.setUrl( distributionSite + "/" + distributionDirectory );
492 }
493
494 distributionManagement.setRepository( repository );
495
496 distributionManagement.setStatus( "converted" );
497
498 if ( site == null && repository == null )
499 {
500 return null;
501 }
502
503 return distributionManagement;
504 }
505
506 private List translateDevelopers( List v3Developers )
507 {
508 List developers = new ArrayList();
509
510 if ( notEmpty( v3Developers ) )
511 {
512 for ( Iterator it = v3Developers.iterator(); it.hasNext(); )
513 {
514 org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it
515 .next();
516
517 Developer developer = new Developer();
518
519 developer.setEmail( v3Developer.getEmail() );
520 developer.setId( v3Developer.getId() );
521 developer.setName( v3Developer.getName() );
522 developer.setOrganization( v3Developer.getOrganization() );
523 developer.setRoles( v3Developer.getRoles() );
524 developer.setTimezone( v3Developer.getTimezone() );
525 developer.setUrl( v3Developer.getUrl() );
526
527 developers.add( developer );
528 }
529 }
530
531 return developers;
532 }
533
534 private List translateDependencies( List v3Deps )
535 {
536 List deps = new ArrayList();
537
538 if ( notEmpty( v3Deps ) )
539 {
540 boolean isJunitPresent = false;
541
542 for ( Iterator it = v3Deps.iterator(); it.hasNext(); )
543 {
544 org.apache.maven.model.v3_0_0.Dependency v3Dep = (org.apache.maven.model.v3_0_0.Dependency) it.next();
545
546 String groupId = format( v3Dep.getGroupId() );
547 String artifactId = format( v3Dep.getArtifactId() );
548
549 String id = v3Dep.getId();
550
551 if ( StringUtils.isNotEmpty( id ) )
552 {
553 if ( StringUtils.isEmpty( groupId ) )
554 {
555 int plusIdx = id.indexOf( "+" );
556
557 if ( plusIdx > -1 )
558 {
559 groupId = id.substring( 0, plusIdx );
560 }
561 else
562 {
563 groupId = id;
564 }
565 }
566
567 if ( StringUtils.isEmpty( artifactId ) )
568 {
569 artifactId = format( id );
570 }
571 }
572
573 if ( "junit".equals( groupId ) && "junit".equals( artifactId ) )
574 {
575 isJunitPresent = true;
576 }
577
578 String type = v3Dep.getType();
579 if ( "plugin".equals( type ) )
580 {
581 if ( "maven".equals( groupId ) )
582 {
583 groupId = "org.apache.maven.plugins";
584 }
585
586 Plugin plugin = new Plugin();
587 plugin.setGroupId( groupId );
588 plugin.setArtifactId( artifactId );
589 plugin.setVersion( format( v3Dep.getVersion() ) );
590
591 Xpp3Dom config = new Xpp3Dom( "configuration" );
592
593 Properties props = v3Dep.getProperties();
594
595 if ( !props.isEmpty() )
596 {
597 for ( Iterator propertyIterator = props.keySet().iterator(); propertyIterator.hasNext(); )
598 {
599 String key = (String) propertyIterator.next();
600 String value = props.getProperty( key );
601
602 Xpp3Dom child = new Xpp3Dom( key );
603 child.setValue( value );
604
605 config.addChild( child );
606 }
607
608 plugin.setConfiguration( config );
609 }
610
611 this.discoveredPlugins.add( plugin );
612 }
613 else
614 {
615 Dependency dep = new Dependency();
616
617 dep.setGroupId( groupId );
618 dep.setArtifactId( artifactId );
619 dep.setVersion( v3Dep.getVersion() );
620 dep.setType( v3Dep.getType() );
621
622 String scope = v3Dep.getProperty( "scope" );
623 if ( StringUtils.isNotEmpty( scope ) )
624 {
625 dep.setScope( scope );
626 }
627
628 String optional = v3Dep.getProperty( "optional" );
629 if ( StringUtils.isNotEmpty( optional ) )
630 {
631 dep.setOptional( Boolean.valueOf( optional ).booleanValue() );
632 }
633
634 deps.add( dep );
635 }
636 }
637
638 if ( !isJunitPresent )
639 {
640 Dependency junitDep = new Dependency();
641 junitDep.setGroupId( "junit" );
642 junitDep.setArtifactId( "junit" );
643 junitDep.setVersion( "3.8.2" );
644 junitDep.setScope( "test" );
645 deps.add( junitDep );
646 }
647 }
648
649 return deps;
650 }
651
652 private List translateContributors( List v3Contributors )
653 {
654 List contributors = new ArrayList();
655
656 if ( notEmpty( v3Contributors ) )
657 {
658 for ( Iterator it = v3Contributors.iterator(); it.hasNext(); )
659 {
660 org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it
661 .next();
662
663 Contributor contributor = new Contributor();
664
665 contributor.setEmail( v3Contributor.getEmail() );
666 contributor.setName( v3Contributor.getName() );
667 contributor.setOrganization( v3Contributor.getOrganization() );
668 contributor.setRoles( v3Contributor.getRoles() );
669 contributor.setTimezone( v3Contributor.getTimezone() );
670 contributor.setUrl( v3Contributor.getUrl() );
671
672 contributors.add( contributor );
673 }
674 }
675
676 return contributors;
677 }
678
679 private Build translateBuild( org.apache.maven.model.v3_0_0.Build v3Build )
680 {
681 Build build = null;
682 if ( v3Build != null )
683 {
684 build = new Build();
685
686 warnOfUnsupportedBuildElements( v3Build );
687
688 build.setSourceDirectory( v3Build.getSourceDirectory() );
689 build.setTestSourceDirectory( v3Build.getUnitTestSourceDirectory() );
690
691 build.setResources( translateResources( v3Build.getResources() ) );
692
693 UnitTest unitTest = v3Build.getUnitTest();
694 if ( unitTest != null )
695 {
696 build.setTestResources( translateResources( unitTest.getResources() ) );
697
698 List testIncludes = unitTest.getIncludes();
699
700 List testExcludes = new ArrayList( unitTest.getExcludes() );
701
702 if ( notEmpty( testIncludes ) || notEmpty( testExcludes ) )
703 {
704 Plugin plugin = new Plugin();
705 plugin.setGroupId( "org.apache.maven.plugins" );
706 plugin.setArtifactId( "maven-surefire-plugin" );
707
708 Xpp3Dom config = new Xpp3Dom( "configuration" );
709
710 if ( notEmpty( testIncludes ) )
711 {
712 Xpp3Dom includes = new Xpp3Dom( "includes" );
713 for ( Iterator it = testIncludes.iterator(); it.hasNext(); )
714 {
715 String includePattern = (String) it.next();
716 Xpp3Dom include = new Xpp3Dom( "include" );
717 include.setValue( includePattern );
718
719 includes.addChild( include );
720 }
721
722 config.addChild( includes );
723 }
724
725 if ( notEmpty( testExcludes ) )
726 {
727 Xpp3Dom excludes = new Xpp3Dom( "excludes" );
728 for ( Iterator it = testExcludes.iterator(); it.hasNext(); )
729 {
730 String excludePattern = (String) it.next();
731 Xpp3Dom exclude = new Xpp3Dom( "exclude" );
732 exclude.setValue( excludePattern );
733
734 excludes.addChild( exclude );
735 }
736
737 config.addChild( excludes );
738 }
739
740 if ( config.getChildCount() > 0 )
741 {
742 plugin.setConfiguration( config );
743 }
744
745 build.addPlugin( plugin );
746 }
747 }
748 }
749
750 if ( !this.discoveredPlugins.isEmpty() )
751 {
752 if ( build == null )
753 {
754 build = new Build();
755 }
756
757 for ( Iterator it = this.discoveredPlugins.iterator(); it.hasNext(); )
758 {
759 Plugin plugin = (Plugin) it.next();
760
761 build.addPlugin( plugin );
762 }
763 }
764
765 return build;
766 }
767
768 private void warnOfUnsupportedBuildElements( org.apache.maven.model.v3_0_0.Build v3Build )
769 {
770 if ( notEmpty( v3Build.getSourceModifications() ) )
771 {
772 warnings.add( "Ignoring <sourceModifications/> section. It is not supported in v4 POMs." );
773 }
774
775 if ( StringUtils.isNotEmpty( v3Build.getAspectSourceDirectory() ) )
776 {
777 warnings.add( "Ignoring <aspectSourceDirectory/>. It is not supported in v4 POMs." );
778 }
779
780 if ( StringUtils.isNotEmpty( v3Build.getIntegrationUnitTestSourceDirectory() ) )
781 {
782 warnings.add( "Ignoring <integrationUnitTestSourceDirectory/>. It is not supported in v4 POMs." );
783 }
784 }
785
786 private List translateResources( List v3Resources )
787 {
788 List resources = new ArrayList();
789
790 if ( notEmpty( v3Resources ) )
791 {
792 for ( Iterator it = v3Resources.iterator(); it.hasNext(); )
793 {
794 org.apache.maven.model.v3_0_0.Resource v3Resource = (org.apache.maven.model.v3_0_0.Resource) it.next();
795 Resource resource = new Resource();
796
797 if ( v3Resource.getDirectory() == null )
798 {
799 resource.setDirectory( "." );
800 }
801 else
802 {
803 resource.setDirectory( v3Resource.getDirectory() );
804 }
805
806 List excludes = new ArrayList( v3Resource.getExcludes() );
807
808 resource.setExcludes( excludes );
809
810 resource.setIncludes( v3Resource.getIncludes() );
811 resource.setTargetPath( v3Resource.getTargetPath() );
812
813 resources.add( resource );
814 }
815 }
816
817 return resources;
818 }
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839 private boolean notEmpty( List test )
840 {
841 return test != null && !test.isEmpty();
842 }
843
844 public void validateV4Basics( Model model, String groupId, String artifactId, String version, String packaging )
845 {
846 if ( StringUtils.isEmpty( model.getModelVersion() ) )
847 {
848 model.setModelVersion( "4.0.0" );
849 }
850
851 if ( StringUtils.isEmpty( model.getGroupId() ) )
852 {
853 warnings.add( "Setting groupId on model using artifact information." );
854 model.setGroupId( groupId );
855 }
856
857 if ( StringUtils.isEmpty( model.getArtifactId() ) )
858 {
859 warnings.add( "Setting artifactId on model using artifact information." );
860 model.setArtifactId( artifactId );
861 }
862
863 if ( StringUtils.isEmpty( model.getVersion() ) )
864 {
865 warnings.add( "Setting version on model using artifact information." );
866 model.setVersion( version );
867 }
868
869 if ( StringUtils.isEmpty( model.getPackaging() ) )
870 {
871 warnings.add( "Setting packaging on model using artifact type information." );
872 model.setPackaging( packaging );
873 }
874 }
875
876 public List getWarnings()
877 {
878 return warnings;
879 }
880
881 private static class PomKey
882 {
883 private final String groupId;
884
885 private final String artifactId;
886
887 private final String version;
888
889 PomKey( String groupId, String artifactId, String version )
890 {
891 this.groupId = groupId;
892 this.artifactId = artifactId;
893 this.version = version;
894 }
895
896 public String groupId()
897 {
898 return groupId;
899 }
900
901 public String artifactId()
902 {
903 return artifactId;
904 }
905
906 public String version()
907 {
908 return version;
909 }
910 }
911
912 }