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