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.codehaus.plexus.util.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 ).append( "\'.\n" )
290 .append( "\to groupId: \'" ).append( reportPlugin.getGroupId() ).append( "\'\n" )
291 .append( "\to artifactId: \'" ).append( reportName ).append( "\'\n" )
292 .append( "\to goal: \'report\'\n" )
293 .append( "\n" )
294 .append( "These values were extracted using the v3 report naming convention, but may be wrong." );
295
296 warnings.add( info.toString() );
297
298 reports.addPlugin( reportPlugin );
299 }
300 }
301 }
302
303 return reports;
304 }
305
306
307
308
309
310
311
312 private String findReportPluginGroupId( String artifactId )
313 {
314 String groupId = (String) model3ReportPlugins.get( artifactId );
315 if ( groupId == null )
316 {
317 groupId = "org.apache.maven.plugins";
318 }
319 return groupId;
320 }
321
322 private Organization translateOrganization( org.apache.maven.model.v3_0_0.Organization v3Organization )
323 {
324 Organization organization = null;
325
326 if ( v3Organization != null )
327 {
328 organization = new Organization();
329
330 organization.setName( v3Organization.getName() );
331 organization.setUrl( v3Organization.getUrl() );
332
333 if ( StringUtils.isNotEmpty( v3Organization.getLogo() ) )
334 {
335 warnings.add( "Ignoring <organization><logo/></organization>. It is not supported in v4 POMs." );
336 }
337 }
338
339 return organization;
340 }
341
342 private List translateMailingLists( List v3MailingLists )
343 {
344 List mailingLists = new ArrayList();
345
346 if ( notEmpty( v3MailingLists ) )
347 {
348 for ( Iterator it = v3MailingLists.iterator(); it.hasNext(); )
349 {
350 org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it
351 .next();
352 MailingList list = new MailingList();
353 list.setArchive( v3List.getArchive() );
354 list.setName( v3List.getName() );
355 list.setSubscribe( v3List.getSubscribe() );
356 list.setUnsubscribe( v3List.getUnsubscribe() );
357
358 mailingLists.add( list );
359 }
360 }
361
362 return mailingLists;
363 }
364
365 private List translateLicenses( List v3Licenses )
366 {
367 List licenses = new ArrayList();
368
369 if ( notEmpty( v3Licenses ) )
370 {
371 for ( Iterator it = v3Licenses.iterator(); it.hasNext(); )
372 {
373 org.apache.maven.model.v3_0_0.License v3License = (org.apache.maven.model.v3_0_0.License) it.next();
374 License license = new License();
375 license.setComments( v3License.getComments() );
376 license.setDistribution( v3License.getDistribution() );
377 license.setName( v3License.getName() );
378 license.setUrl( v3License.getUrl() );
379
380 licenses.add( license );
381 }
382 }
383
384 return licenses;
385 }
386
387 private IssueManagement translateIssueManagement( org.apache.maven.model.v3_0_0.Model v3Model )
388 {
389 IssueManagement issueMgmt = null;
390
391 String issueTrackingUrl = v3Model.getIssueTrackingUrl();
392 if ( StringUtils.isNotEmpty( issueTrackingUrl ) )
393 {
394 issueMgmt = new IssueManagement();
395 issueMgmt.setUrl( issueTrackingUrl );
396 }
397
398 return issueMgmt;
399 }
400
401 private DistributionManagement translateDistributionManagement( PomKey pomKey,
402 org.apache.maven.model.v3_0_0.Model v3Model )
403 throws PomTranslationException
404 {
405 DistributionManagement distributionManagement = new DistributionManagement();
406
407 Site site = null;
408
409 String siteAddress = v3Model.getSiteAddress();
410
411 String siteDirectory = v3Model.getSiteDirectory();
412
413 if ( StringUtils.isEmpty( siteAddress ) )
414 {
415 if ( !StringUtils.isEmpty( siteDirectory ) )
416 {
417 site = new Site();
418
419 site.setId( "default" );
420
421 site.setName( "Default Site" );
422
423 site.setUrl( "file://" + siteDirectory );
424 }
425 }
426 else
427 {
428 if ( StringUtils.isEmpty( siteDirectory ) )
429 {
430 throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
431 "Missing 'siteDirectory': Both siteAddress and siteDirectory must be set at the same time." );
432 }
433
434 site = new Site();
435
436 site.setId( "default" );
437
438 site.setName( "Default Site" );
439
440 StringBuffer url = new StringBuffer( "scp://" );
441 url.append( siteAddress );
442 if ( !siteAddress.endsWith( "/" ) && !siteDirectory.startsWith( "/" ) )
443 {
444 url.append( "/" );
445 }
446 url.append( siteDirectory );
447 site.setUrl( url.toString() );
448 }
449
450 distributionManagement.setSite( site );
451
452 String distributionSite = v3Model.getDistributionSite();
453
454 String distributionDirectory = v3Model.getDistributionDirectory();
455
456 DeploymentRepository repository = null;
457
458 if ( StringUtils.isEmpty( distributionSite ) )
459 {
460 if ( !StringUtils.isEmpty( distributionDirectory ) )
461 {
462 repository = new DeploymentRepository();
463
464 repository.setId( "default" );
465
466 repository.setName( "Default Repository" );
467
468 repository.setUrl( "file://" + distributionDirectory );
469
470
471 }
472 }
473 else
474 {
475 if ( StringUtils.isEmpty( distributionDirectory ) )
476 {
477 throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
478 "Missing 'distributionDirectory': must be set is 'distributionSite' is set." );
479 }
480
481 repository = new DeploymentRepository();
482
483 repository.setId( "default" );
484
485 repository.setName( "Default Repository" );
486
487 repository.setUrl( distributionSite + "/" + distributionDirectory );
488 }
489
490 distributionManagement.setRepository( repository );
491
492 distributionManagement.setStatus( "converted" );
493
494 if ( site == null && repository == null )
495 {
496 return null;
497 }
498
499 return distributionManagement;
500 }
501
502 private List translateDevelopers( List v3Developers )
503 {
504 List developers = new ArrayList();
505
506 if ( notEmpty( v3Developers ) )
507 {
508 for ( Iterator it = v3Developers.iterator(); it.hasNext(); )
509 {
510 org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it
511 .next();
512
513 Developer developer = new Developer();
514
515 developer.setEmail( v3Developer.getEmail() );
516 developer.setId( v3Developer.getId() );
517 developer.setName( v3Developer.getName() );
518 developer.setOrganization( v3Developer.getOrganization() );
519 developer.setRoles( v3Developer.getRoles() );
520 developer.setTimezone( v3Developer.getTimezone() );
521 developer.setUrl( v3Developer.getUrl() );
522
523 developers.add( developer );
524 }
525 }
526
527 return developers;
528 }
529
530 private List translateDependencies( List v3Deps )
531 {
532 List deps = new ArrayList();
533
534 if ( notEmpty( v3Deps ) )
535 {
536 boolean isJunitPresent = false;
537
538 for ( Iterator it = v3Deps.iterator(); it.hasNext(); )
539 {
540 org.apache.maven.model.v3_0_0.Dependency v3Dep = (org.apache.maven.model.v3_0_0.Dependency) it.next();
541
542 String groupId = format( v3Dep.getGroupId() );
543 String artifactId = format( v3Dep.getArtifactId() );
544
545 String id = v3Dep.getId();
546
547 if ( StringUtils.isNotEmpty( id ) )
548 {
549 if ( StringUtils.isEmpty( groupId ) )
550 {
551 int plusIdx = id.indexOf( "+" );
552
553 if ( plusIdx > -1 )
554 {
555 groupId = id.substring( 0, plusIdx );
556 }
557 else
558 {
559 groupId = id;
560 }
561 }
562
563 if ( StringUtils.isEmpty( artifactId ) )
564 {
565 artifactId = format( id );
566 }
567 }
568
569 if ( "junit".equals( groupId ) && "junit".equals( artifactId ) )
570 {
571 isJunitPresent = true;
572 }
573
574 String type = v3Dep.getType();
575 if ( "plugin".equals( type ) )
576 {
577 if ( "maven".equals( groupId ) )
578 {
579 groupId = "org.apache.maven.plugins";
580 }
581
582 Plugin plugin = new Plugin();
583 plugin.setGroupId( groupId );
584 plugin.setArtifactId( artifactId );
585 plugin.setVersion( format( v3Dep.getVersion() ) );
586
587 Xpp3Dom config = new Xpp3Dom( "configuration" );
588
589 Properties props = v3Dep.getProperties();
590
591 if ( !props.isEmpty() )
592 {
593 for ( Iterator propertyIterator = props.keySet().iterator(); propertyIterator.hasNext(); )
594 {
595 String key = (String) propertyIterator.next();
596 String value = props.getProperty( key );
597
598 Xpp3Dom child = new Xpp3Dom( key );
599 child.setValue( value );
600
601 config.addChild( child );
602 }
603
604 plugin.setConfiguration( config );
605 }
606
607 this.discoveredPlugins.add( plugin );
608 }
609 else
610 {
611 Dependency dep = new Dependency();
612
613 dep.setGroupId( groupId );
614 dep.setArtifactId( artifactId );
615 dep.setVersion( v3Dep.getVersion() );
616 dep.setType( v3Dep.getType() );
617
618 String scope = v3Dep.getProperty( "scope" );
619 if ( StringUtils.isNotEmpty( scope ) )
620 {
621 dep.setScope( scope );
622 }
623
624 String optional = v3Dep.getProperty( "optional" );
625 if ( StringUtils.isNotEmpty( optional ) )
626 {
627 dep.setOptional( Boolean.valueOf( optional ).booleanValue() );
628 }
629
630 deps.add( dep );
631 }
632 }
633
634 if ( !isJunitPresent )
635 {
636 Dependency junitDep = new Dependency();
637 junitDep.setGroupId( "junit" );
638 junitDep.setArtifactId( "junit" );
639 junitDep.setVersion( "3.8.2" );
640 junitDep.setScope( "test" );
641 deps.add( junitDep );
642 }
643 }
644
645 return deps;
646 }
647
648 private List translateContributors( List v3Contributors )
649 {
650 List contributors = new ArrayList();
651
652 if ( notEmpty( v3Contributors ) )
653 {
654 for ( Iterator it = v3Contributors.iterator(); it.hasNext(); )
655 {
656 org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it
657 .next();
658
659 Contributor contributor = new Contributor();
660
661 contributor.setEmail( v3Contributor.getEmail() );
662 contributor.setName( v3Contributor.getName() );
663 contributor.setOrganization( v3Contributor.getOrganization() );
664 contributor.setRoles( v3Contributor.getRoles() );
665 contributor.setTimezone( v3Contributor.getTimezone() );
666 contributor.setUrl( v3Contributor.getUrl() );
667
668 contributors.add( contributor );
669 }
670 }
671
672 return contributors;
673 }
674
675 private Build translateBuild( org.apache.maven.model.v3_0_0.Build v3Build )
676 {
677 Build build = null;
678 if ( v3Build != null )
679 {
680 build = new Build();
681
682 warnOfUnsupportedBuildElements( v3Build );
683
684 build.setSourceDirectory( v3Build.getSourceDirectory() );
685 build.setTestSourceDirectory( v3Build.getUnitTestSourceDirectory() );
686
687 build.setResources( translateResources( v3Build.getResources() ) );
688
689 UnitTest unitTest = v3Build.getUnitTest();
690 if ( unitTest != null )
691 {
692 build.setTestResources( translateResources( unitTest.getResources() ) );
693
694 List testIncludes = unitTest.getIncludes();
695
696 List testExcludes = new ArrayList( unitTest.getExcludes() );
697
698 if ( notEmpty( testIncludes ) || notEmpty( testExcludes ) )
699 {
700 Plugin plugin = new Plugin();
701 plugin.setGroupId( "org.apache.maven.plugins" );
702 plugin.setArtifactId( "maven-surefire-plugin" );
703
704 Xpp3Dom config = new Xpp3Dom( "configuration" );
705
706 if ( notEmpty( testIncludes ) )
707 {
708 Xpp3Dom includes = new Xpp3Dom( "includes" );
709 for ( Iterator it = testIncludes.iterator(); it.hasNext(); )
710 {
711 String includePattern = (String) it.next();
712 Xpp3Dom include = new Xpp3Dom( "include" );
713 include.setValue( includePattern );
714
715 includes.addChild( include );
716 }
717
718 config.addChild( includes );
719 }
720
721 if ( notEmpty( testExcludes ) )
722 {
723 Xpp3Dom excludes = new Xpp3Dom( "excludes" );
724 for ( Iterator it = testExcludes.iterator(); it.hasNext(); )
725 {
726 String excludePattern = (String) it.next();
727 Xpp3Dom exclude = new Xpp3Dom( "exclude" );
728 exclude.setValue( excludePattern );
729
730 excludes.addChild( exclude );
731 }
732
733 config.addChild( excludes );
734 }
735
736 if ( config.getChildCount() > 0 )
737 {
738 plugin.setConfiguration( config );
739 }
740
741 build.addPlugin( plugin );
742 }
743 }
744 }
745
746 if ( !this.discoveredPlugins.isEmpty() )
747 {
748 if ( build == null )
749 {
750 build = new Build();
751 }
752
753 for ( Iterator it = this.discoveredPlugins.iterator(); it.hasNext(); )
754 {
755 Plugin plugin = (Plugin) it.next();
756
757 build.addPlugin( plugin );
758 }
759 }
760
761 return build;
762 }
763
764 private void warnOfUnsupportedBuildElements( org.apache.maven.model.v3_0_0.Build v3Build )
765 {
766 if ( notEmpty( v3Build.getSourceModifications() ) )
767 {
768 warnings.add( "Ignoring <sourceModifications/> section. It is not supported in v4 POMs." );
769 }
770
771 if ( StringUtils.isNotEmpty( v3Build.getAspectSourceDirectory() ) )
772 {
773 warnings.add( "Ignoring <aspectSourceDirectory/>. It is not supported in v4 POMs." );
774 }
775
776 if ( StringUtils.isNotEmpty( v3Build.getIntegrationUnitTestSourceDirectory() ) )
777 {
778 warnings.add( "Ignoring <integrationUnitTestSourceDirectory/>. It is not supported in v4 POMs." );
779 }
780 }
781
782 private List translateResources( List v3Resources )
783 {
784 List resources = new ArrayList();
785
786 if ( notEmpty( v3Resources ) )
787 {
788 for ( Iterator it = v3Resources.iterator(); it.hasNext(); )
789 {
790 org.apache.maven.model.v3_0_0.Resource v3Resource = (org.apache.maven.model.v3_0_0.Resource) it.next();
791 Resource resource = new Resource();
792
793 if ( v3Resource.getDirectory() == null )
794 {
795 resource.setDirectory( "." );
796 }
797 else
798 {
799 resource.setDirectory( v3Resource.getDirectory() );
800 }
801
802 List excludes = new ArrayList( v3Resource.getExcludes() );
803
804 resource.setExcludes( excludes );
805
806 resource.setIncludes( v3Resource.getIncludes() );
807 resource.setTargetPath( v3Resource.getTargetPath() );
808
809 resources.add( resource );
810 }
811 }
812
813 return resources;
814 }
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835 private boolean notEmpty( List test )
836 {
837 return test != null && !test.isEmpty();
838 }
839
840 public void validateV4Basics( Model model, String groupId, String artifactId, String version, String packaging )
841 {
842 if ( StringUtils.isEmpty( model.getModelVersion() ) )
843 {
844 model.setModelVersion( "4.0.0" );
845 }
846
847 if ( StringUtils.isEmpty( model.getGroupId() ) )
848 {
849 warnings.add( "Setting groupId on model using artifact information." );
850 model.setGroupId( groupId );
851 }
852
853 if ( StringUtils.isEmpty( model.getArtifactId() ) )
854 {
855 warnings.add( "Setting artifactId on model using artifact information." );
856 model.setArtifactId( artifactId );
857 }
858
859 if ( StringUtils.isEmpty( model.getVersion() ) )
860 {
861 warnings.add( "Setting version on model using artifact information." );
862 model.setVersion( version );
863 }
864
865 if ( StringUtils.isEmpty( model.getPackaging() ) )
866 {
867 warnings.add( "Setting packaging on model using artifact type information." );
868 model.setPackaging( packaging );
869 }
870 }
871
872 public List getWarnings()
873 {
874 return warnings;
875 }
876
877 private static class PomKey
878 {
879 private final String groupId;
880
881 private final String artifactId;
882
883 private final String version;
884
885 PomKey( String groupId, String artifactId, String version )
886 {
887 this.groupId = groupId;
888 this.artifactId = artifactId;
889 this.version = version;
890 }
891
892 public String groupId()
893 {
894 return groupId;
895 }
896
897 public String artifactId()
898 {
899 return artifactId;
900 }
901
902 public String version()
903 {
904 return version;
905 }
906 }
907
908 }