1   package org.apache.maven.plugin.assembly.artifact;
2   
3   import org.apache.maven.artifact.Artifact;
4   import org.apache.maven.artifact.factory.ArtifactFactory;
5   import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
6   import org.apache.maven.artifact.repository.ArtifactRepository;
7   import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
8   import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
9   import org.apache.maven.artifact.resolver.ArtifactCollector;
10  import org.apache.maven.artifact.resolver.ArtifactResolver;
11  import org.apache.maven.model.Model;
12  import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
13  import org.apache.maven.plugin.assembly.model.Assembly;
14  import org.apache.maven.plugin.assembly.model.DependencySet;
15  import org.apache.maven.plugin.assembly.model.ModuleBinaries;
16  import org.apache.maven.plugin.assembly.model.ModuleSet;
17  import org.apache.maven.plugin.assembly.model.Repository;
18  import org.apache.maven.plugin.assembly.testutils.MockManager;
19  import org.apache.maven.project.MavenProject;
20  import org.codehaus.plexus.PlexusTestCase;
21  import org.codehaus.plexus.logging.Logger;
22  import org.codehaus.plexus.logging.console.ConsoleLogger;
23  import org.easymock.MockControl;
24  
25  import edu.emory.mathcs.backport.java.util.Collections;
26  
27  import java.io.File;
28  import java.util.ArrayList;
29  import java.util.Iterator;
30  import java.util.List;
31  import java.util.Set;
32  
33  public class DefaultDependencyResolverTest
34      extends PlexusTestCase
35  {
36  
37      private ArtifactFactory factory;
38  
39      private ArtifactRepositoryFactory repoFactory;
40  
41      private ArtifactRepositoryLayout layout;
42  
43      private ArtifactResolver resolver;
44  
45      private ArtifactMetadataSource metadataSource;
46  
47      private ArtifactCollector collector;
48  
49      private ConsoleLogger logger;
50  
51      @Override
52      public void setUp()
53          throws Exception
54      {
55          super.setUp();
56  
57          resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
58          metadataSource = (ArtifactMetadataSource) lookup( ArtifactMetadataSource.ROLE );
59          factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
60          repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
61          layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
62          collector = (ArtifactCollector) lookup( ArtifactCollector.class.getName() );
63          logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
64      }
65  
66      public void test_getDependencySetResolutionRequirements()
67          throws DependencyResolutionException
68      {
69          final List<DependencySet> depSets = new ArrayList<DependencySet>();
70  
71          final DependencySet ds1 = new DependencySet();
72          ds1.setScope( Artifact.SCOPE_COMPILE );
73          ds1.setUseTransitiveDependencies( false );
74  
75          depSets.add( ds1 );
76  
77          final DependencySet ds2 = new DependencySet();
78          ds2.setScope( Artifact.SCOPE_SYSTEM );
79          ds2.setUseTransitiveDependencies( false );
80  
81          depSets.add( ds2 );
82  
83          final MavenProject project = createMavenProject( "main-group", "main-artifact", "1", null );
84  
85          final ResolutionManagementInfo info = new ResolutionManagementInfo( project );
86  
87          new DefaultDependencyResolver( resolver, metadataSource, factory, collector, logger ).getDependencySetResolutionRequirements( new Assembly(),
88                                                                                                                                        depSets,
89                                                                                                                                        info,
90                                                                                                                                        project );
91  
92          assertTrue( info.isResolutionRequired() );
93          assertFalse( info.isResolvedTransitively() );
94  
95          assertTrue( info.getScopeFilter()
96                          .isIncludeCompileScope() );
97          assertTrue( info.getScopeFilter()
98                          .isIncludeSystemScope() );
99  
100         assertTrue( info.getScopeFilter()
101                         .isIncludeProvidedScope() );
102 
103         assertFalse( info.getScopeFilter()
104                          .isIncludeRuntimeScope() );
105         assertFalse( info.getScopeFilter()
106                          .isIncludeTestScope() );
107     }
108 
109     public void test_getModuleSetResolutionRequirements()
110         throws DependencyResolutionException
111     {
112         final MockManager mm = new MockManager();
113 
114         final MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
115         mm.add( csControl );
116 
117         final AssemblerConfigurationSource cs = (AssemblerConfigurationSource) csControl.getMock();
118 
119         final File rootDir = new File( "root" );
120         final MavenProject project = createMavenProject( "main-group", "main-artifact", "1", rootDir );
121 
122         final File module1Dir = new File( rootDir, "module-1" );
123         final MavenProject module1 = createMavenProject( "main-group", "module-1", "1", module1Dir );
124         final MavenProject module1a =
125             createMavenProject( "group1", "module-1a", "1", new File( module1Dir, "module-1a" ) );
126         final MavenProject module1b =
127             createMavenProject( "group1.b", "module-1b", "1", new File( module1Dir, "module-1b" ) );
128 
129         module1.getModel()
130                .addModule( module1a.getArtifactId() );
131         module1.getModel()
132                .addModule( module1b.getArtifactId() );
133 
134         final File module2Dir = new File( rootDir, "module-2" );
135         final MavenProject module2 = createMavenProject( "main-group", "module-2", "1", module2Dir );
136         final MavenProject module2a =
137             createMavenProject( "main-group", "module-2a", "1", new File( module2Dir, "module-2a" ) );
138 
139         module2.getModel()
140                .addModule( module2a.getArtifactId() );
141 
142         project.getModel()
143                .addModule( module1.getArtifactId() );
144         project.getModel()
145                .addModule( module2.getArtifactId() );
146 
147         final List<MavenProject> allProjects = new ArrayList<MavenProject>();
148         allProjects.add( project );
149         allProjects.add( module1 );
150         allProjects.add( module1a );
151         allProjects.add( module1b );
152         allProjects.add( module2 );
153         allProjects.add( module2a );
154 
155         cs.getReactorProjects();
156         csControl.setReturnValue( allProjects, MockControl.ZERO_OR_MORE );
157 
158         cs.getProject();
159         csControl.setReturnValue( project, MockControl.ZERO_OR_MORE );
160 
161         final ResolutionManagementInfo info = new ResolutionManagementInfo( project );
162 
163         final List<ModuleSet> moduleSets = new ArrayList<ModuleSet>();
164 
165         {
166             final ModuleSet ms = new ModuleSet();
167             ms.addInclude( "*module1*" );
168             ms.setIncludeSubModules( false );
169 
170             final ModuleBinaries mb = new ModuleBinaries();
171 
172             final DependencySet ds = new DependencySet();
173             ds.setScope( Artifact.SCOPE_COMPILE );
174 
175             mb.addDependencySet( ds );
176             ms.setBinaries( mb );
177             moduleSets.add( ms );
178         }
179 
180         {
181             final ModuleSet ms = new ModuleSet();
182             ms.addInclude( "main-group:*" );
183             ms.setIncludeSubModules( true );
184 
185             final ModuleBinaries mb = new ModuleBinaries();
186 
187             final DependencySet ds = new DependencySet();
188             ds.setScope( Artifact.SCOPE_TEST );
189 
190             mb.addDependencySet( ds );
191             ms.setBinaries( mb );
192             moduleSets.add( ms );
193         }
194 
195         mm.replayAll();
196 
197         final DefaultDependencyResolver resolver =
198             new DefaultDependencyResolver( this.resolver, metadataSource, factory, collector, logger );
199         resolver.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
200 
201         final Assembly assembly = new Assembly();
202         assembly.setModuleSets( moduleSets );
203 
204         resolver.getModuleSetResolutionRequirements( assembly, info, cs );
205 
206         assertTrue( info.isResolutionRequired() );
207 
208         final Set<MavenProject> enabledProjects = info.getEnabledProjects();
209         assertTrue( enabledProjects.contains( project ) );
210 
211         assertTrue( enabledProjects.contains( module1 ) );
212 
213         // these should be excluded since sub-modules are not traversable
214         assertFalse( enabledProjects.contains( module1a ) );
215         assertFalse( enabledProjects.contains( module1b ) );
216 
217         assertTrue( enabledProjects.contains( module2 ) );
218         assertTrue( enabledProjects.contains( module2a ) );
219 
220         // these are the two we directly set above.
221         assertTrue( info.getScopeFilter()
222                         .isIncludeTestScope() );
223         assertTrue( info.getScopeFilter()
224                         .isIncludeCompileScope() );
225 
226         // this combination should be implied by the two direct scopes set above.
227         assertTrue( info.getScopeFilter()
228                         .isIncludeRuntimeScope() );
229         assertTrue( info.getScopeFilter()
230                         .isIncludeProvidedScope() );
231         assertTrue( info.getScopeFilter()
232                         .isIncludeSystemScope() );
233 
234         mm.verifyAll();
235     }
236 
237     public void test_getRepositoryResolutionRequirements()
238     {
239         final List<Repository> repositories = new ArrayList<Repository>();
240 
241         {
242             final Repository r = new Repository();
243             r.setScope( Artifact.SCOPE_COMPILE );
244             repositories.add( r );
245         }
246 
247         {
248             final Repository r = new Repository();
249             r.setScope( Artifact.SCOPE_SYSTEM );
250             repositories.add( r );
251         }
252 
253         final MavenProject project = createMavenProject( "group", "artifact", "1.0", null );
254         final Assembly assembly = new Assembly();
255         assembly.setRepositories( repositories );
256 
257         final ResolutionManagementInfo info = new ResolutionManagementInfo( project );
258         new DefaultDependencyResolver( resolver, metadataSource, factory, collector, logger ).getRepositoryResolutionRequirements( assembly,
259                                                                                                                                    info,
260                                                                                                                                    project );
261 
262         assertTrue( info.isResolutionRequired() );
263 
264         assertTrue( info.getScopeFilter()
265                         .isIncludeCompileScope() );
266         assertTrue( info.getScopeFilter()
267                         .isIncludeSystemScope() );
268 
269         assertTrue( info.getScopeFilter()
270                         .isIncludeProvidedScope() );
271 
272         assertFalse( info.getScopeFilter()
273                          .isIncludeRuntimeScope() );
274         assertFalse( info.getScopeFilter()
275                          .isIncludeTestScope() );
276     }
277 
278     public void test_aggregateRemoteArtifactRepositories()
279     {
280         final List<ArtifactRepository> externalRepos = new ArrayList<ArtifactRepository>();
281 
282         final ArtifactRepository er1 =
283             repoFactory.createArtifactRepository( "test.1", "http://test.com/path", layout, null, null );
284         externalRepos.add( er1 );
285 
286         final ArtifactRepository er2 =
287             repoFactory.createArtifactRepository( "test.2", "http://test2.com/path", layout, null, null );
288         externalRepos.add( er2 );
289 
290         final List<ArtifactRepository> projectRepos = new ArrayList<ArtifactRepository>();
291 
292         final ArtifactRepository pr1 =
293             repoFactory.createArtifactRepository( "project.1", "http://test.com/project", layout, null, null );
294         projectRepos.add( pr1 );
295 
296         final ArtifactRepository pr2 =
297             repoFactory.createArtifactRepository( "project.2", "http://test2.com/path", layout, null, null );
298         projectRepos.add( pr2 );
299 
300         final MavenProject project = createMavenProject( "group", "artifact", "1", new File( "base" ) );
301         project.setRemoteArtifactRepositories( projectRepos );
302 
303         @SuppressWarnings( "unchecked" )
304         final List<ArtifactRepository> aggregated =
305             new DefaultDependencyResolver( resolver, metadataSource, factory, collector, logger ).aggregateRemoteArtifactRepositories( externalRepos,
306                                                                                                                                        Collections.singleton( project ) );
307 
308         assertRepositoryWithId( er1.getId(), aggregated, true );
309         assertRepositoryWithId( er2.getId(), aggregated, true );
310         assertRepositoryWithId( pr1.getId(), aggregated, true );
311         assertRepositoryWithId( pr2.getId(), aggregated, false );
312     }
313 
314     // public void test_manageArtifact()
315     // {
316     // Artifact managed = factory.createArtifact( "group", "artifact", "1", Artifact.SCOPE_PROVIDED, "jar" );
317     //
318     // Artifact target =
319     // factory.createArtifact( managed.getGroupId(), managed.getArtifactId(), "2", Artifact.SCOPE_COMPILE,
320     // managed.getType() );
321     //
322     // Artifact target2 =
323     // factory.createArtifact( "other-group", managed.getArtifactId(), "2", Artifact.SCOPE_COMPILE,
324     // managed.getType() );
325     //
326     // Map managedVersions = Collections.singletonMap( managed.getDependencyConflictId(), managed );
327     //
328     // DefaultDependencyResolver resolver =
329     // new DefaultDependencyResolver().setLogger( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
330     //
331     // resolver.manageArtifact( target, managedVersions );
332     // resolver.manageArtifact( target2, managedVersions );
333     //
334     // assertEquals( managed.getVersion(), target.getVersion() );
335     // assertEquals( managed.getScope(), target.getScope() );
336     //
337     // assertEquals( "2", target2.getVersion() );
338     // assertEquals( Artifact.SCOPE_COMPILE, target2.getScope() );
339     // }
340 
341     // public void test_buildManagedVersionMap_NonTransitiveResolution()
342     // throws ArtifactResolutionException, ArchiveCreationException, InvalidVersionSpecificationException,
343     // InvalidDependencyVersionException
344     // {
345     // Assembly assembly = new Assembly();
346     //
347     // DependencySet ds = new DependencySet();
348     // ds.setScope( Artifact.SCOPE_PROVIDED );
349     // ds.setUseTransitiveDependencies( false );
350     //
351     // assembly.addDependencySet( ds );
352     //
353     // ModuleSet ms = new ModuleSet();
354     // ModuleBinaries mb = new ModuleBinaries();
355     // ms.setBinaries( mb );
356     //
357     // DependencySet mds = new DependencySet();
358     // mds.setScope( Artifact.SCOPE_PROVIDED );
359     // mds.setUseTransitiveDependencies( false );
360     //
361     // mb.addDependencySet( mds );
362     //
363     // assembly.addModuleSet( ms );
364     //
365     // MavenProject project = createMavenProject( "group", "artifact", "1", new File( "base" ) );
366     //
367     // Dependency d1 = new Dependency();
368     // d1.setGroupId( "group.dep" );
369     // d1.setArtifactId( "dep1" );
370     // d1.setVersion( "1" );
371     // d1.setScope( Artifact.SCOPE_COMPILE );
372     //
373     // project.getModel().addDependency( d1 );
374     //
375     // Dependency d2 = new Dependency();
376     // d2.setGroupId( "group.dep" );
377     // d2.setArtifactId( "dep2" );
378     // d2.setVersion( "1" );
379     // d2.setScope( Artifact.SCOPE_PROVIDED );
380     //
381     // project.getModel().addDependency( d2 );
382     //
383     // Dependency d3 = new Dependency();
384     // d3.setGroupId( "group.dep" );
385     // d3.setArtifactId( "dep3" );
386     // d3.setVersion( "1" );
387     // d3.setScope( Artifact.SCOPE_PROVIDED );
388     //
389     // project.getModel().addDependency( d3 );
390     //
391     // MavenProject module = createMavenProject( "group", "module", "1", new File( "base/module" ) );
392     //
393     // project.getModel().addModule( module.getArtifactId() );
394     //
395     // Dependency md = new Dependency();
396     // md.setGroupId( "group.dep" );
397     // md.setArtifactId( "dep3" );
398     // md.setVersion( "2" );
399     // md.setScope( Artifact.SCOPE_PROVIDED );
400     //
401     // module.getModel().addDependency( md );
402     //
403     // List allProjects = new ArrayList();
404     // allProjects.add( project );
405     // allProjects.add( module );
406     //
407     // MockManager mm = new MockManager();
408     //
409     // MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
410     // mm.add( csControl );
411     //
412     // AssemblerConfigurationSource cs = (AssemblerConfigurationSource) csControl.getMock();
413     //
414     // cs.getProject();
415     // csControl.setReturnValue( project, MockControl.ZERO_OR_MORE );
416     //
417     // cs.getReactorProjects();
418     // csControl.setReturnValue( allProjects, MockControl.ZERO_OR_MORE );
419     //
420     // cs.getRemoteRepositories();
421     // csControl.setReturnValue( Collections.EMPTY_LIST, MockControl.ZERO_OR_MORE );
422     //
423     // mm.replayAll();
424     //
425     // DefaultDependencyResolver resolver = new DefaultDependencyResolver();
426     // resolver.setArtifactFactory( factory );
427     // resolver.setLogger( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
428     //
429     // Map managedVersionMap = resolver.buildManagedVersionMap( assembly, cs );
430     //
431     // {
432     // Dependency d = d1;
433     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
434     // assertNull( a );
435     // }
436     //
437     // {
438     // Dependency d = d2;
439     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
440     // assertNotNull( a );
441     // assertEquals( d.getVersion(), a.getVersion() );
442     // assertEquals( d.getScope(), a.getScope() );
443     // }
444     //
445     // {
446     // Dependency d = d3;
447     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
448     // assertNotNull( a );
449     // assertEquals( d.getVersion(), a.getVersion() );
450     // assertEquals( d.getScope(), a.getScope() );
451     // }
452     //
453     // mm.verifyAll();
454     // }
455     //
456     // public void test_buildManagedVersionMap_TransitiveResolution()
457     // throws ArtifactResolutionException, ArchiveCreationException, InvalidVersionSpecificationException,
458     // InvalidDependencyVersionException
459     // {
460     // Assembly assembly = new Assembly();
461     //
462     // DependencySet ds = new DependencySet();
463     // ds.setScope( Artifact.SCOPE_COMPILE );
464     // ds.setUseTransitiveDependencies( true );
465     //
466     // assembly.addDependencySet( ds );
467     //
468     // MavenProject project = createMavenProject( "group", "artifact", "1", new File( "base" ) );
469     //
470     // Dependency d1 = new Dependency();
471     // d1.setGroupId( "group.dep" );
472     // d1.setArtifactId( "dep1" );
473     // d1.setVersion( "1" );
474     // d1.setScope( Artifact.SCOPE_COMPILE );
475     //
476     // project.getModel().addDependency( d1 );
477     //
478     // Dependency d2 = new Dependency();
479     // d2.setGroupId( "group.dep" );
480     // d2.setArtifactId( "dep2" );
481     // d2.setVersion( "1" );
482     // d2.setScope( Artifact.SCOPE_COMPILE );
483     // final Artifact a2 = factory.createArtifact( d2.getGroupId(), d2.getArtifactId(), d2.getVersion(), d2.getScope(),
484     // "jar" );
485     //
486     // project.getModel().addDependency( d2 );
487     //
488     // Dependency d3 = new Dependency();
489     // d3.setGroupId( "group.dep" );
490     // d3.setArtifactId( "dep3" );
491     // d3.setVersion( "1" );
492     // d3.setScope( Artifact.SCOPE_COMPILE );
493     //
494     // project.getModel().addDependency( d3 );
495     //
496     // final Artifact a2a = factory.createArtifact( d3.getGroupId(), d3.getArtifactId(), "2", Artifact.SCOPE_RUNTIME,
497     // "jar" );
498     //
499     // MockManager mm = new MockManager();
500     //
501     // MockControl msControl = MockControl.createControl( ArtifactMetadataSource.class );
502     // mm.add( msControl );
503     //
504     // ArtifactMetadataSource ms = (ArtifactMetadataSource) msControl.getMock();
505     //
506     // try
507     // {
508     // ms.retrieve( null, null, null );
509     // }
510     // catch ( ArtifactMetadataRetrievalException e )
511     // {
512     // }
513     //
514     // msControl.setDefaultReturnValue( new ResolutionGroup( null, Collections.EMPTY_SET, Collections.EMPTY_LIST ) );
515     // msControl.setMatcher( new ArgumentsMatcher()
516     // {
517     // public boolean matches( Object[] expected, Object[] actual )
518     // {
519     // Artifact a = (Artifact) actual[0];
520     //
521     // return a2.getArtifactId().equals( a.getArtifactId() );
522     // }
523     //
524     // public String toString( Object[] args )
525     // {
526     // return "with artifact: " + args[0] ;
527     // }
528     //
529     // } );
530     // msControl.setReturnValue( new ResolutionGroup( a2, Collections.singleton( a2a ), Collections.EMPTY_LIST ) );
531     //
532     //
533     // MockControl csControl = MockControl.createControl( AssemblerConfigurationSource.class );
534     // mm.add( csControl );
535     //
536     // AssemblerConfigurationSource cs = (AssemblerConfigurationSource) csControl.getMock();
537     //
538     // cs.getProject();
539     // csControl.setReturnValue( project, MockControl.ZERO_OR_MORE );
540     //
541     // String tmpDir = System.getProperty( "java.io.tmpdir" );
542     // ArtifactRepository lr = repoFactory.createArtifactRepository( "local", "file://" + tmpDir, layout, null, null );
543     //
544     // cs.getLocalRepository();
545     // csControl.setReturnValue( lr, MockControl.ZERO_OR_MORE );
546     //
547     // cs.getRemoteRepositories();
548     // csControl.setReturnValue( Collections.EMPTY_LIST, MockControl.ZERO_OR_MORE );
549     //
550     // mm.replayAll();
551     //
552     // DefaultDependencyResolver resolver = new DefaultDependencyResolver();
553     // resolver.setArtifactMetadataSource( ms );
554     // resolver.setArtifactCollector( collector );
555     // resolver.setArtifactFactory( factory );
556     // resolver.setLogger( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
557     //
558     // Map managedVersionMap = resolver.buildManagedVersionMap( assembly, cs );
559     //
560     // {
561     // Dependency d = d1;
562     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
563     // assertNotNull( a );
564     // assertEquals( d.getVersion(), a.getVersion() );
565     // assertEquals( d.getScope(), a.getScope() );
566     // }
567     //
568     // {
569     // Dependency d = d2;
570     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
571     // assertNotNull( a );
572     // assertEquals( d.getVersion(), a.getVersion() );
573     // assertEquals( d.getScope(), a.getScope() );
574     // }
575     //
576     // {
577     // Dependency d = d3;
578     // Artifact a = (Artifact) managedVersionMap.get( d.getManagementKey() );
579     // assertNotNull( a );
580     // assertEquals( d.getVersion(), a.getVersion() );
581     // assertEquals( d.getScope(), a.getScope() );
582     // }
583     //
584     // mm.verifyAll();
585     // }
586 
587     private void assertRepositoryWithId( final String repoId, final List<ArtifactRepository> repos,
588                                          final boolean shouldExist )
589     {
590         if ( ( repos == null || repos.isEmpty() ) )
591         {
592             if ( shouldExist )
593             {
594                 fail( "Repository with id: " + repoId + " should be present, but repository list is null or empty." );
595             }
596         }
597         else
598         {
599             boolean found = false;
600             for ( final Iterator<ArtifactRepository> it = repos.iterator(); it.hasNext(); )
601             {
602                 final ArtifactRepository repo = it.next();
603                 if ( repoId.equals( repo.getId() ) )
604                 {
605                     found = true;
606                     break;
607                 }
608             }
609 
610             if ( shouldExist )
611             {
612                 assertTrue( "Repository with id: " + repoId + " should be present in repository list.", found );
613             }
614             else
615             {
616                 assertFalse( "Repository with id: " + repoId + " should NOT be present in repository list.", found );
617             }
618         }
619     }
620 
621     private MavenProject createMavenProject( final String groupId, final String artifactId, final String version,
622                                              final File basedir )
623     {
624         final Model model = new Model();
625 
626         model.setGroupId( groupId );
627         model.setArtifactId( artifactId );
628         model.setVersion( version );
629         model.setPackaging( "pom" );
630 
631         final MavenProject project = new MavenProject( model );
632 
633         final Artifact pomArtifact = factory.createProjectArtifact( groupId, artifactId, version );
634         project.setArtifact( pomArtifact );
635 
636         project.setFile( new File( basedir, "pom.xml" ) );
637 
638         return project;
639     }
640 
641 }