1 package org.apache.maven.plugins.dependency.fromDependencies;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.HashSet;
25 import java.util.Set;
26
27 import org.apache.maven.artifact.Artifact;
28 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
29 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
30 import org.apache.maven.execution.MavenSession;
31 import org.apache.maven.plugin.LegacySupport;
32 import org.apache.maven.plugin.MojoExecutionException;
33 import org.apache.maven.plugin.MojoFailureException;
34 import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
35 import org.apache.maven.plugins.dependency.utils.DependencyUtil;
36 import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler;
37 import org.apache.maven.project.MavenProject;
38 import org.codehaus.plexus.util.StringUtils;
39
40 public class TestCopyDependenciesMojo
41 extends AbstractDependencyMojoTestCase
42 {
43
44 CopyDependenciesMojo mojo;
45
46 @Override
47 protected void setUp()
48 throws Exception
49 {
50
51 super.setUp( "copy-dependencies", true, false );
52
53 File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
54 mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
55 mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
56
57
58 assertNotNull( mojo );
59 assertNotNull( mojo.getProject() );
60 MavenProject project = mojo.getProject();
61
62 MavenSession session = newMavenSession( project );
63 setVariableValueToObject( mojo, "session", session );
64
65 LegacySupport legacySupport = lookup( LegacySupport.class );
66 legacySupport.setSession( session );
67 installLocalRepository( legacySupport );
68
69 Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
70 Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
71 artifacts.addAll( directArtifacts );
72
73 project.setArtifacts( artifacts );
74 project.setDependencyArtifacts( directArtifacts );
75 mojo.markersDirectory = new File( this.testDir, "markers" );
76
77 ArtifactHandlerManager manager = lookup( ArtifactHandlerManager.class );
78 setVariableValueToObject( mojo, "artifactHandlerManager", manager );
79 }
80
81 public void assertNoMarkerFile( Artifact artifact ) throws MojoExecutionException
82 {
83 DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
84 assertFalse( handle.isMarkerSet() );
85 }
86
87 public void testCopyFile()
88 throws MojoExecutionException, IOException
89 {
90 File src = File.createTempFile( "copy", null );
91
92 File dest = new File( mojo.outputDirectory, "toMe.jar" );
93
94 assertFalse( dest.exists() );
95
96 copyFile( mojo, src, dest );
97 assertTrue( dest.exists() );
98 }
99
100
101
102
103
104
105 public void testMojo()
106 throws Exception
107 {
108 mojo.execute();
109 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
110 for ( Artifact artifact : artifacts )
111 {
112 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
113 File file = new File( mojo.outputDirectory, fileName );
114 assertTrue( file.exists() );
115
116
117 assertNoMarkerFile( artifact );
118 }
119 }
120
121 public void testStripVersion()
122 throws Exception
123 {
124 mojo.stripVersion = true;
125 mojo.execute();
126
127 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
128 for ( Artifact artifact : artifacts )
129 {
130 String fileName = DependencyUtil.getFormattedFileName( artifact, true );
131 File file = new File( mojo.outputDirectory, fileName );
132 assertTrue( file.exists() );
133 }
134 }
135
136 public void testStripClassifier()
137 throws Exception
138 {
139 mojo.stripClassifier = true;
140 mojo.execute();
141
142 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
143 for ( Artifact artifact : artifacts )
144 {
145 String fileName = DependencyUtil.getFormattedFileName( artifact, false, false, false, true );
146 File file = new File( mojo.outputDirectory, fileName );
147 assertTrue( file.exists() );
148 }
149 }
150
151 public void testUseBaseVersion()
152 throws Exception
153 {
154 mojo.useBaseVersion = true;
155 mojo.execute();
156
157 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
158 for ( Artifact artifact : artifacts )
159 {
160 String fileName = DependencyUtil.getFormattedFileName( artifact, false, false, true );
161 File file = new File( mojo.outputDirectory, fileName );
162 assertTrue( file.exists() );
163 }
164 }
165
166 public void testNoTransitive()
167 throws Exception
168 {
169 mojo.excludeTransitive = true;
170 mojo.execute();
171
172 Set<Artifact> artifacts = mojo.getProject().getDependencyArtifacts();
173 for ( Artifact artifact : artifacts )
174 {
175 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
176 File file = new File( mojo.outputDirectory, fileName );
177 assertTrue( file.exists() );
178 }
179 }
180
181 public void testExcludeType()
182 throws Exception
183 {
184 mojo.getProject().setArtifacts( stubFactory.getTypedArtifacts() );
185 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
186 mojo.excludeTypes = "jar";
187 mojo.execute();
188
189 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
190 for ( Artifact artifact : artifacts )
191 {
192 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
193 File file = new File( mojo.outputDirectory, fileName );
194 assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), !file.exists() );
195 }
196 }
197
198 public void testIncludeType()
199 throws Exception
200 {
201 mojo.getProject().setArtifacts( stubFactory.getTypedArtifacts() );
202 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
203
204 mojo.includeTypes = "jar";
205 mojo.excludeTypes = "jar";
206
207
208 mojo.execute();
209
210 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
211 for ( Artifact artifact : artifacts )
212 {
213 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
214 File file = new File( mojo.outputDirectory, fileName );
215 assertFalse( file.exists() );
216 }
217
218 mojo.excludeTypes = "";
219 mojo.execute();
220
221 artifacts = mojo.getProject().getArtifacts();
222 for ( Artifact artifact : artifacts )
223 {
224 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
225 File file = new File( mojo.outputDirectory, fileName );
226 assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), file.exists() );
227 }
228 }
229
230 public void testExcludeArtifactId()
231 throws Exception
232 {
233 mojo.getProject().setArtifacts( stubFactory.getArtifactArtifacts() );
234 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
235 mojo.excludeArtifactIds = "one";
236 mojo.execute();
237
238 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
239 for ( Artifact artifact : artifacts )
240 {
241 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
242 File file = new File( mojo.outputDirectory, fileName );
243 assertEquals( artifact.getArtifactId().equals( "one" ), !file.exists() );
244 }
245 }
246
247 public void testIncludeArtifactId()
248 throws Exception
249 {
250 mojo.getProject().setArtifacts( stubFactory.getArtifactArtifacts() );
251 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
252
253 mojo.includeArtifactIds = "one";
254 mojo.excludeArtifactIds = "one";
255
256
257 mojo.execute();
258
259 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
260 for ( Artifact artifact : artifacts )
261 {
262 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
263 File file = new File( mojo.outputDirectory, fileName );
264 assertFalse( file.exists() );
265 }
266
267 mojo.excludeArtifactIds = "";
268 mojo.execute();
269
270 artifacts = mojo.getProject().getArtifacts();
271 for ( Artifact artifact : artifacts )
272 {
273 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
274 File file = new File( mojo.outputDirectory, fileName );
275 assertEquals( artifact.getArtifactId().equals( "one" ), file.exists() );
276 }
277 }
278
279 public void testIncludeGroupId()
280 throws Exception
281 {
282 mojo.getProject().setArtifacts( stubFactory.getGroupIdArtifacts() );
283 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
284 mojo.includeGroupIds = "one";
285 mojo.excludeGroupIds = "one";
286
287
288 mojo.execute();
289
290 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
291 for ( Artifact artifact : artifacts )
292 {
293 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
294 File file = new File( mojo.outputDirectory, fileName );
295 assertFalse( file.exists() );
296 }
297
298 mojo.excludeGroupIds = "";
299 mojo.execute();
300
301 artifacts = mojo.getProject().getArtifacts();
302 for ( Artifact artifact : artifacts )
303 {
304 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
305 File file = new File( mojo.outputDirectory, fileName );
306 assertEquals( artifact.getGroupId().equals( "one" ), file.exists() );
307 }
308
309 }
310
311 public void testExcludeGroupId()
312 throws Exception
313 {
314 mojo.getProject().setArtifacts( stubFactory.getGroupIdArtifacts() );
315 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
316 mojo.excludeGroupIds = "one";
317 mojo.execute();
318
319 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
320 for ( Artifact artifact : artifacts )
321 {
322 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
323 File file = new File( mojo.outputDirectory, fileName );
324
325 assertEquals( artifact.getGroupId().equals( "one" ), !file.exists() );
326 }
327 }
328
329 public void testExcludeMultipleGroupIds()
330 throws Exception
331 {
332 mojo.getProject().setArtifacts( stubFactory.getGroupIdArtifacts() );
333 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
334 mojo.excludeGroupIds = "one,two";
335 mojo.execute();
336
337 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
338 for ( Artifact artifact : artifacts )
339 {
340 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
341 File file = new File( mojo.outputDirectory, fileName );
342
343 assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ),
344 !file.exists() );
345 }
346 }
347
348 public void testExcludeClassifier()
349 throws Exception
350 {
351 mojo.getProject().setArtifacts( stubFactory.getClassifiedArtifacts() );
352 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
353 mojo.excludeClassifiers = "one";
354 mojo.execute();
355
356 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
357 for ( Artifact artifact : artifacts )
358 {
359 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
360 File file = new File( mojo.outputDirectory, fileName );
361 assertEquals( artifact.getClassifier().equals( "one" ), !file.exists() );
362 }
363 }
364
365 public void testIncludeClassifier()
366 throws Exception
367 {
368 mojo.getProject().setArtifacts( stubFactory.getClassifiedArtifacts() );
369 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
370
371 mojo.includeClassifiers = "one";
372 mojo.excludeClassifiers = "one";
373
374
375 mojo.execute();
376
377 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
378 for ( Artifact artifact : artifacts )
379 {
380 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
381 File file = new File( mojo.outputDirectory, fileName );
382 assertFalse( file.exists() );
383 }
384
385 mojo.excludeClassifiers = "";
386 mojo.execute();
387
388 artifacts = mojo.getProject().getArtifacts();
389 for ( Artifact artifact : artifacts )
390 {
391 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
392 File file = new File( mojo.outputDirectory, fileName );
393 assertEquals( artifact.getClassifier().equals( "one" ), file.exists() );
394 }
395
396 }
397
398 public void testSubPerType()
399 throws Exception
400 {
401 mojo.getProject().setArtifacts( stubFactory.getTypedArtifacts() );
402 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
403 mojo.useSubDirectoryPerType = true;
404 mojo.execute();
405
406 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
407 for ( Artifact artifact : artifacts )
408 {
409 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
410 File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false,
411 mojo.outputDirectory, artifact );
412 File file = new File( folder, fileName );
413 assertTrue( file.exists() );
414 }
415 }
416
417 public void testCDMClassifier()
418 throws Exception
419 {
420 dotestClassifierType( "jdk14", null );
421 }
422
423 public void testCDMType()
424 throws Exception
425 {
426 dotestClassifierType( null, "sources" );
427 }
428
429 public void testCDMClassifierType()
430 throws Exception
431 {
432 dotestClassifierType( "jdk14", "sources" );
433 }
434
435 public void dotestClassifierType( String testClassifier, String testType )
436 throws Exception
437 {
438 mojo.classifier = testClassifier;
439 mojo.type = testType;
440
441 for ( Artifact artifact : mojo.getProject().getArtifacts() )
442 {
443 String type = testType != null ? testType : artifact.getType();
444
445 stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
446 artifact.getScope(), type, testClassifier );
447
448 }
449
450 mojo.execute();
451
452 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
453 for ( Artifact artifact : artifacts )
454 {
455 String useClassifier = artifact.getClassifier();
456 String useType = artifact.getType();
457
458 if ( StringUtils.isNotEmpty( testClassifier ) )
459 {
460 useClassifier = "-" + testClassifier;
461
462 if ( StringUtils.isNotEmpty( testType ) )
463 {
464 useType = testType;
465 }
466 }
467 String fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + useClassifier + "." + useType;
468 File file = new File( mojo.outputDirectory, fileName );
469
470 if ( !file.exists() )
471 {
472 fail( "Can't find:" + file.getAbsolutePath() );
473 }
474
475
476 assertNoMarkerFile( artifact );
477 }
478 }
479
480 public void testArtifactResolutionException()
481 throws MojoFailureException
482 {
483 dotestArtifactExceptions();
484 }
485
486 public void dotestArtifactExceptions()
487 throws MojoFailureException
488 {
489 mojo.classifier = "jdk";
490 mojo.type = "java-sources";
491
492 try
493 {
494 mojo.execute();
495 fail( "ExpectedException" );
496 }
497 catch ( MojoExecutionException e )
498 {
499
500 }
501 }
502
503
504
505
506
507
508
509 public void testDontOverWriteRelease()
510 throws MojoExecutionException, InterruptedException, IOException, MojoFailureException
511 {
512
513 Set<Artifact> artifacts = new HashSet<>();
514 Artifact release = stubFactory.getReleaseArtifact();
515 assertTrue( release.getFile().setLastModified( System.currentTimeMillis() - 2000 ) );
516
517 artifacts.add( release );
518
519 mojo.getProject().setArtifacts( artifacts );
520 mojo.getProject().setDependencyArtifacts( artifacts );
521
522 mojo.overWriteIfNewer = false;
523
524 mojo.execute();
525
526 File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
527
528 Thread.sleep( 100 );
529
530 long time = System.currentTimeMillis() + 1000;
531 time = time - ( time % 1000 );
532 assertTrue( copiedFile.setLastModified( time ) );
533 Thread.sleep( 100 );
534
535 mojo.execute();
536
537 assertEquals( time, copiedFile.lastModified() );
538 }
539
540 public void testOverWriteRelease()
541 throws MojoExecutionException, IOException, MojoFailureException
542 {
543
544 Set<Artifact> artifacts = new HashSet<>();
545 Artifact release = stubFactory.getReleaseArtifact();
546
547 assertTrue( release.getFile().setLastModified( 1000L ) );
548 assertEquals( 1000L, release.getFile().lastModified() );
549
550 artifacts.add( release );
551
552 mojo.getProject().setArtifacts( artifacts );
553 mojo.getProject().setDependencyArtifacts( artifacts );
554
555 mojo.overWriteReleases = true;
556 mojo.overWriteIfNewer = false;
557
558 mojo.execute();
559
560 File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
561
562 assertTrue( copiedFile.setLastModified( 2000L ) );
563 assertEquals( 2000L, copiedFile.lastModified() );
564
565 mojo.execute();
566
567 long timeCopyNow = copiedFile.lastModified();
568 assertEquals( 1000L, timeCopyNow );
569
570 }
571
572 public void testDontOverWriteSnap()
573 throws MojoExecutionException, IOException, MojoFailureException
574 {
575
576 Set<Artifact> artifacts = new HashSet<>();
577 Artifact snap = stubFactory.getSnapshotArtifact();
578 assertTrue( snap.getFile().setLastModified( 1000L ) );
579 assertEquals( 1000L, snap.getFile().lastModified() );
580
581 artifacts.add( snap );
582
583 mojo.getProject().setArtifacts( artifacts );
584 mojo.getProject().setDependencyArtifacts( artifacts );
585
586 mojo.overWriteReleases = false;
587 mojo.overWriteSnapshots = false;
588 mojo.overWriteIfNewer = false;
589
590 mojo.execute();
591
592 File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
593
594 assertTrue( copiedFile.setLastModified( 2000L ) );
595 assertEquals( 2000L, copiedFile.lastModified() );
596
597 mojo.execute();
598
599 long timeCopyNow = copiedFile.lastModified();
600 assertEquals( 2000L, timeCopyNow );
601 }
602
603 public void testOverWriteSnap()
604 throws MojoExecutionException, IOException, MojoFailureException
605 {
606
607 Set<Artifact> artifacts = new HashSet<>();
608 Artifact snap = stubFactory.getSnapshotArtifact();
609 assertTrue( snap.getFile().setLastModified( 1000L ) );
610 assertEquals( 1000L, snap.getFile().lastModified() );
611
612 artifacts.add( snap );
613
614 mojo.getProject().setArtifacts( artifacts );
615 mojo.getProject().setDependencyArtifacts( artifacts );
616
617 mojo.overWriteReleases = false;
618 mojo.overWriteSnapshots = true;
619 mojo.overWriteIfNewer = false;
620
621 mojo.execute();
622
623 File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
624
625 assertTrue( copiedFile.setLastModified( 2000L ) );
626 assertEquals( 2000L, copiedFile.lastModified() );
627
628 mojo.execute();
629
630 long timeCopyNow = copiedFile.lastModified();
631 assertEquals( 1000L, timeCopyNow );
632 }
633
634 public void testGetDependencies()
635 throws MojoExecutionException
636 {
637 assertEquals( mojo.getResolvedDependencies( true ).toString(),
638 mojo.getDependencySets( true ).getResolvedDependencies().toString() );
639 }
640
641 public void testExcludeProvidedScope()
642 throws Exception
643 {
644 mojo.getProject().setArtifacts( stubFactory.getScopedArtifacts() );
645 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
646 mojo.excludeScope = "provided";
647
648
649 mojo.execute();
650
651 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
652 for ( Artifact artifact : artifacts )
653 {
654 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
655 File file = new File( mojo.outputDirectory, fileName );
656 assertEquals( artifact.getScope().equals( "provided" ), !file.exists() );
657 file.delete();
658 assertFalse( file.exists() );
659 }
660
661 }
662
663 public void testExcludeSystemScope()
664 throws Exception
665 {
666 mojo.getProject().setArtifacts( stubFactory.getScopedArtifacts() );
667 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
668 mojo.excludeScope = "system";
669
670
671 mojo.execute();
672
673 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
674 for ( Artifact artifact : artifacts )
675 {
676 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
677 File file = new File( mojo.outputDirectory, fileName );
678 assertEquals( artifact.getScope().equals( "system" ), !file.exists() );
679 file.delete();
680 assertFalse( file.exists() );
681 }
682
683 }
684
685 public void testExcludeCompileScope()
686 throws Exception
687 {
688 mojo.getProject().setArtifacts( stubFactory.getScopedArtifacts() );
689 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
690 mojo.excludeScope = "compile";
691 mojo.execute();
692 ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
693
694 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
695 for ( Artifact artifact : artifacts )
696 {
697 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
698 File file = new File( mojo.outputDirectory, fileName );
699
700 assertEquals( !saf.include( artifact ), file.exists() );
701 }
702 }
703
704 public void testExcludeTestScope()
705 throws IOException, MojoFailureException
706 {
707 mojo.getProject().setArtifacts( stubFactory.getScopedArtifacts() );
708 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
709 mojo.excludeScope = "test";
710
711 try
712 {
713 mojo.execute();
714 fail( "expected an exception" );
715 }
716 catch ( MojoExecutionException e )
717 {
718
719 }
720
721 }
722
723 public void testExcludeRuntimeScope()
724 throws Exception
725 {
726 mojo.getProject().setArtifacts( stubFactory.getScopedArtifacts() );
727 mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
728 mojo.excludeScope = "runtime";
729 mojo.execute();
730 ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
731
732 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
733 for ( Artifact artifact : artifacts )
734 {
735 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
736 File file = new File( mojo.outputDirectory, fileName );
737
738 assertEquals( !saf.include( artifact ), file.exists() );
739 }
740 }
741
742 public void testCopyPom()
743 throws Exception
744 {
745 mojo.setCopyPom( true );
746
747 Set<Artifact> set = new HashSet<>();
748 set.add( stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE ) );
749 stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE, "pom",
750 null );
751 mojo.getProject().setArtifacts( set );
752 mojo.execute();
753
754 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
755 for ( Artifact artifact : artifacts )
756 {
757 String fileName = DependencyUtil.getFormattedFileName( artifact, false );
758 File file = new File( mojo.outputDirectory, fileName.substring( 0, fileName.length() - 4 ) + ".pom" );
759 assertTrue( file + " doesn't exist", file.exists() );
760 }
761 }
762
763 public void testPrependGroupId()
764 throws Exception
765 {
766 mojo.prependGroupId = true;
767 mojo.execute();
768
769 Set<Artifact> artifacts = mojo.getProject().getArtifacts();
770 for ( Artifact artifact : artifacts )
771 {
772 String fileName = DependencyUtil.getFormattedFileName( artifact, false, true );
773 File file = new File( mojo.outputDirectory, fileName );
774 assertTrue( file.exists() );
775 }
776 }
777 }