1 package org.apache.maven.plugins.dependency.fromConfiguration;
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.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27
28 import org.apache.maven.artifact.Artifact;
29 import org.apache.maven.artifact.versioning.VersionRange;
30 import org.apache.maven.execution.MavenSession;
31 import org.apache.maven.model.Dependency;
32 import org.apache.maven.plugin.LegacySupport;
33 import org.apache.maven.plugin.MojoExecutionException;
34 import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
35 import org.apache.maven.plugins.dependency.utils.DependencyUtil;
36 import org.apache.maven.project.MavenProject;
37
38 public class TestCopyMojo
39 extends AbstractDependencyMojoTestCase
40 {
41 private CopyMojo mojo;
42
43 protected void setUp()
44 throws Exception
45 {
46 super.setUp( "copy", false, false );
47
48 File testPom = new File( getBasedir(), "target/test-classes/unit/copy-test/plugin-config.xml" );
49 mojo = (CopyMojo) lookupMojo( "copy", testPom );
50 mojo.setOutputDirectory( new File( this.testDir, "outputDirectory" ) );
51 mojo.setSilent( true );
52
53 assertNotNull( mojo );
54 assertNotNull( mojo.getProject() );
55
56 MavenSession session = newMavenSession( mojo.getProject() );
57 setVariableValueToObject( mojo, "session", session );
58
59 LegacySupport legacySupport = lookup( LegacySupport.class );
60 legacySupport.setSession( session );
61 installLocalRepository( legacySupport );
62 }
63
64 private ArtifactItem getSingleArtifactItem( boolean removeVersion, boolean useBaseVersion )
65 throws MojoExecutionException
66 {
67 List<ArtifactItem> list =
68 mojo.getProcessedArtifactItems( new ProcessArtifactItemsRequest( removeVersion, false, useBaseVersion,
69 false ) );
70 return list.get( 0 );
71 }
72
73 public void testSetArtifactWithoutPackaging()
74 throws Exception
75 {
76 mojo.setArtifact( "a:b:c" );
77 ArtifactItem item = mojo.getArtifactItems().get( 0 );
78 assertEquals( "a", item.getGroupId() );
79 assertEquals( "b", item.getArtifactId() );
80 assertEquals( "c", item.getVersion() );
81 assertEquals( "jar", item.getType() );
82 assertNull( item.getClassifier() );
83 }
84
85 public void testSetArtifactWithoutClassifier()
86 throws Exception
87 {
88 mojo.setArtifact( "a:b:c:d" );
89 ArtifactItem item = mojo.getArtifactItems().get( 0 );
90 assertEquals( "a", item.getGroupId() );
91 assertEquals( "b", item.getArtifactId() );
92 assertEquals( "c", item.getVersion() );
93 assertEquals( "d", item.getType() );
94 assertNull( item.getClassifier() );
95 }
96
97 public void testSetArtifact()
98 throws Exception
99 {
100 mojo.setArtifact( "a:b:c:d:e" );
101 ArtifactItem item = mojo.getArtifactItems().get( 0 );
102 assertEquals( "a", item.getGroupId() );
103 assertEquals( "b", item.getArtifactId() );
104 assertEquals( "c", item.getVersion() );
105 assertEquals( "d", item.getType() );
106 assertEquals( "e", item.getClassifier() );
107 }
108
109 public void testGetArtifactItems()
110 throws Exception
111 {
112
113 ArtifactItem item = new ArtifactItem();
114
115 item.setArtifactId( "artifact" );
116 item.setGroupId( "groupId" );
117 item.setVersion( "1.0" );
118
119 List<ArtifactItem> list = new ArrayList<>( 1 );
120 list.add( createArtifact( item ) );
121
122 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
123
124 ArtifactItem result = getSingleArtifactItem( false, false );
125 assertEquals( mojo.getOutputDirectory(), result.getOutputDirectory() );
126
127 File output = new File( mojo.getOutputDirectory(), "override" );
128 item.setOutputDirectory( output );
129 result = getSingleArtifactItem( false, false );
130 assertEquals( output, result.getOutputDirectory() );
131 }
132
133 public void assertFilesExist( Collection<ArtifactItem> items, boolean exist )
134 {
135 for ( ArtifactItem item : items )
136 {
137 assertFileExists( item, exist );
138 }
139 }
140
141 public void assertFileExists( ArtifactItem item, boolean exist )
142 {
143 File file = new File( item.getOutputDirectory(), item.getDestFileName() );
144 assertEquals( exist, file.exists() );
145 }
146
147 public void testMojoDefaults()
148 {
149 CopyMojo themojo = new CopyMojo();
150
151 assertFalse( themojo.isStripVersion() );
152 assertFalse( themojo.isSkip() );
153 assertFalse( themojo.isStripClassifier() );
154 }
155
156 public void testCopyFile()
157 throws Exception
158 {
159 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
160
161 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
162
163 mojo.execute();
164
165 assertFilesExist( list, true );
166 }
167
168 public void testCopyFileWithBaseVersion()
169 throws Exception
170 {
171 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
172 ArtifactItem item = new ArtifactItem();
173
174 item.setArtifactId( "artifact" );
175 item.setGroupId( "groupId" );
176 item.setVersion( "1.0-20130210.213424-191" );
177 list.add( item );
178
179 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
180 mojo.setUseBaseVersion( true );
181
182 mojo.execute();
183
184 assertFilesExist( list, true );
185 }
186
187 public void testSkip()
188 throws Exception
189 {
190 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
191
192 mojo.setSkip( true );
193 mojo.setArtifactItems( list );
194
195 mojo.execute();
196 for ( ArtifactItem item : list )
197 {
198
199 assertNull( item.getOutputDirectory() );
200 assertNull( item.getDestFileName() );
201 }
202
203 }
204
205 public void testCopyFileNoOverwrite()
206 throws Exception
207 {
208 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
209
210 for ( ArtifactItem item : list )
211 {
212
213 item.setOverWrite( "false" );
214 }
215
216 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
217 mojo.execute();
218
219 assertFilesExist( list, true );
220 }
221
222 public void testCopyToLocation()
223 throws Exception
224 {
225 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
226 ArtifactItem item = list.get( 0 );
227 item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) );
228
229 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
230
231 mojo.execute();
232
233 assertFilesExist( list, true );
234 }
235
236 public void testCopyStripVersionSetInMojo()
237 throws Exception
238 {
239 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
240
241 ArtifactItem item = list.get( 0 );
242 item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) );
243 mojo.setStripVersion( true );
244
245 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
246
247 mojo.execute();
248 assertEquals( DependencyUtil.getFormattedFileName( item.getArtifact(), true ), item.getDestFileName() );
249
250 assertFilesExist( list, true );
251 }
252
253 public void testCopyStripClassifierSetInMojo()
254 throws Exception
255 {
256 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
257
258 ArtifactItem item = list.get( 0 );
259 item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) );
260 mojo.setStripClassifier( true );
261
262 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
263
264 mojo.execute();
265 assertEquals( DependencyUtil.getFormattedFileName( item.getArtifact(), false, false, false, true ),
266 item.getDestFileName() );
267
268 assertFilesExist( list, true );
269 }
270
271 public void testNonClassifierStrip()
272 throws Exception
273 {
274 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() );
275 mojo.setStripVersion( true );
276 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
277
278 mojo.execute();
279
280 assertFilesExist( list, true );
281 }
282
283 public void testNonClassifierNoStrip()
284 throws Exception
285 {
286 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() );
287
288 mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
289
290 mojo.execute();
291
292 assertFilesExist( list, true );
293 }
294
295 public void testMissingVersionNotFound()
296 throws Exception
297 {
298 ArtifactItem item = new ArtifactItem();
299
300 item.setArtifactId( "artifactId" );
301 item.setClassifier( "" );
302 item.setGroupId( "groupId" );
303 item.setType( "type" );
304
305 List<ArtifactItem> list = new ArrayList<>();
306 list.add( item );
307 mojo.setArtifactItems( list );
308
309 try
310 {
311 mojo.execute();
312 fail( "Expected Exception Here." );
313 }
314 catch ( MojoExecutionException e )
315 {
316
317 }
318 }
319
320 public List<Dependency> getDependencyList( ArtifactItem item )
321 {
322 Dependency dep = new Dependency();
323 dep.setArtifactId( item.getArtifactId() );
324 dep.setClassifier( item.getClassifier() );
325 dep.setGroupId( item.getGroupId() );
326 dep.setType( item.getType() );
327 dep.setVersion( "2.0-SNAPSHOT" );
328
329 Dependency dep2 = new Dependency();
330 dep2.setArtifactId( item.getArtifactId() );
331 dep2.setClassifier( "classifier" );
332 dep2.setGroupId( item.getGroupId() );
333 dep2.setType( item.getType() );
334 dep2.setVersion( "2.1" );
335
336 List<Dependency> list = new ArrayList<>( 2 );
337 list.add( dep2 );
338 list.add( dep );
339
340 return list;
341 }
342
343 public void testMissingVersionFromDependencies()
344 throws Exception
345 {
346 ArtifactItem item = new ArtifactItem();
347
348 item.setArtifactId( "artifactId" );
349 item.setClassifier( "" );
350 item.setGroupId( "groupId" );
351 item.setType( "type" );
352
353 List<ArtifactItem> list = new ArrayList<>();
354 list.add( item );
355 mojo.setArtifactItems( list );
356
357 MavenProject project = mojo.getProject();
358 project.setDependencies( createDependencyArtifacts( getDependencyList( item ) ) );
359
360 mojo.execute();
361 this.assertFileExists( item, true );
362 assertEquals( "2.0-SNAPSHOT", item.getVersion() );
363 }
364
365 public void testMissingVersionFromDependenciesLooseMatch()
366 throws Exception
367 {
368 ArtifactItem item = new ArtifactItem();
369
370 item.setArtifactId( "artifactId" );
371 item.setClassifier( "" );
372 item.setGroupId( "groupId" );
373 item.setType( "type" );
374
375 MavenProject project = mojo.getProject();
376 project.setDependencies( createDependencyArtifacts( getDependencyList( item ) ) );
377
378
379 item.setClassifier( "sources" );
380 item.setType( "jar" );
381
382
383 item.setVersion( "2.1" );
384 createArtifact( item );
385 item.setVersion( null );
386
387 List<ArtifactItem> list = new ArrayList<>();
388 list.add( item );
389 mojo.setArtifactItems( list );
390
391 mojo.execute();
392 this.assertFileExists( item, true );
393 assertEquals( "2.1", item.getVersion() );
394 }
395
396 public void testMissingVersionFromDependenciesWithClassifier()
397 throws Exception
398 {
399 ArtifactItem item = new ArtifactItem();
400
401 item.setArtifactId( "artifactId" );
402 item.setClassifier( "classifier" );
403 item.setGroupId( "groupId" );
404 item.setType( "type" );
405
406 List<ArtifactItem> list = new ArrayList<>();
407 list.add( item );
408 mojo.setArtifactItems( list );
409
410 MavenProject project = mojo.getProject();
411 project.setDependencies( createDependencyArtifacts( getDependencyList( item ) ) );
412
413 mojo.execute();
414 this.assertFileExists( item, true );
415 assertEquals( "2.1", item.getVersion() );
416 }
417
418 public List<Dependency> getDependencyMgtList( ArtifactItem item )
419 {
420 Dependency dep = new Dependency();
421 dep.setArtifactId( item.getArtifactId() );
422 dep.setClassifier( item.getClassifier() );
423 dep.setGroupId( item.getGroupId() );
424 dep.setType( item.getType() );
425 dep.setVersion( "3.0-SNAPSHOT" );
426
427 Dependency dep2 = new Dependency();
428 dep2.setArtifactId( item.getArtifactId() );
429 dep2.setClassifier( "classifier" );
430 dep2.setGroupId( item.getGroupId() );
431 dep2.setType( item.getType() );
432 dep2.setVersion( "3.1" );
433
434 List<Dependency> list = new ArrayList<>( 2 );
435 list.add( dep2 );
436 list.add( dep );
437
438 return list;
439 }
440
441 public void testMissingVersionFromDependencyMgt()
442 throws Exception
443 {
444 ArtifactItem item = new ArtifactItem();
445
446 item.setArtifactId( "artifactId" );
447 item.setClassifier( "" );
448 item.setGroupId( "groupId" );
449 item.setType( "type" );
450
451 MavenProject project = mojo.getProject();
452 project.setDependencies( getDependencyList( item ) );
453
454 item = new ArtifactItem();
455
456 item.setArtifactId( "artifactId-2" );
457 item.setClassifier( "" );
458 item.setGroupId( "groupId" );
459 item.setType( "type" );
460
461 List<ArtifactItem> list = new ArrayList<>();
462 list.add( item );
463
464 mojo.setArtifactItems( list );
465
466 project.getDependencyManagement().setDependencies( createDependencyArtifacts( getDependencyMgtList( item ) ) );
467
468 mojo.execute();
469
470 this.assertFileExists( item, true );
471 assertEquals( "3.0-SNAPSHOT", item.getVersion() );
472 }
473
474 public void testMissingVersionFromDependencyMgtLooseMatch()
475 throws Exception
476 {
477 ArtifactItem item = new ArtifactItem();
478
479 item.setArtifactId( "artifactId" );
480 item.setClassifier( "" );
481 item.setGroupId( "groupId" );
482 item.setType( "type" );
483
484 MavenProject project = mojo.getProject();
485 project.setDependencies( getDependencyList( item ) );
486
487 item = new ArtifactItem();
488
489 item.setArtifactId( "artifactId-2" );
490 item.setClassifier( "" );
491 item.setGroupId( "groupId" );
492 item.setType( "type" );
493
494 List<ArtifactItem> list = new ArrayList<>();
495 list.add( item );
496
497 mojo.setArtifactItems( list );
498
499 project.getDependencyManagement().setDependencies( createDependencyArtifacts( getDependencyMgtList( item ) ) );
500
501 item.setType( "jar" );
502
503
504 item.setVersion( "3.1" );
505 createArtifact( item );
506 item.setVersion( null );
507
508 mojo.execute();
509
510 this.assertFileExists( item, true );
511 assertEquals( "3.1", item.getVersion() );
512 }
513
514 public void testMissingVersionFromDependencyMgtWithClassifier()
515 throws Exception
516 {
517 ArtifactItem item = new ArtifactItem();
518
519 item.setArtifactId( "artifactId" );
520 item.setClassifier( "classifier" );
521 item.setGroupId( "groupId" );
522 item.setType( "type" );
523
524 MavenProject project = mojo.getProject();
525 project.setDependencies( getDependencyList( item ) );
526
527 item = new ArtifactItem();
528
529 item.setArtifactId( "artifactId-2" );
530 item.setClassifier( "classifier" );
531 item.setGroupId( "groupId" );
532 item.setType( "type" );
533
534 List<ArtifactItem> list = new ArrayList<>();
535 list.add( item );
536
537 mojo.setArtifactItems( list );
538
539 project.getDependencyManagement().setDependencies( createDependencyArtifacts( getDependencyMgtList( item ) ) );
540
541 mojo.execute();
542
543 this.assertFileExists( item, true );
544 assertEquals( "3.1", item.getVersion() );
545 }
546
547 public void testArtifactNotFound()
548 throws Exception
549 {
550 dotestArtifactExceptions( false, true );
551 }
552
553 public void testArtifactResolutionException()
554 throws Exception
555 {
556 dotestArtifactExceptions( true, false );
557 }
558
559 public void dotestArtifactExceptions( boolean are, boolean anfe )
560 throws Exception
561 {
562 ArtifactItem item = new ArtifactItem();
563
564 item.setArtifactId( "artifactId" );
565 item.setClassifier( "" );
566 item.setGroupId( "groupId" );
567 item.setType( "type" );
568 item.setVersion( "1.0" );
569
570 List<ArtifactItem> list = new ArrayList<>();
571 list.add( item );
572 mojo.setArtifactItems( list );
573
574 try
575 {
576 mojo.execute();
577 fail( "ExpectedException" );
578 }
579 catch ( MojoExecutionException e )
580 {
581 assertEquals( "Unable to find/resolve artifact.", e.getMessage() );
582 }
583 }
584
585 public void testNoArtifactItems()
586 {
587 try
588 {
589 mojo.getProcessedArtifactItems( new ProcessArtifactItemsRequest( false, false, false, false ) );
590 fail( "Expected Exception" );
591 }
592 catch ( MojoExecutionException e )
593 {
594 assertEquals( "There are no artifactItems configured.", e.getMessage() );
595 }
596
597 }
598
599 public void testCopyDontOverWriteReleases()
600 throws Exception
601 {
602 stubFactory.setCreateFiles( true );
603 Artifact release = stubFactory.getReleaseArtifact();
604 assertTrue( release.getFile().setLastModified( System.currentTimeMillis() - 2000 ) );
605
606 ArtifactItem item = new ArtifactItem( release );
607
608 List<ArtifactItem> list = new ArrayList<>( 1 );
609 list.add( item );
610 mojo.setArtifactItems( list );
611
612 mojo.setOverWriteIfNewer( false );
613
614 mojo.execute();
615
616 File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
617
618 Thread.sleep( 100 );
619
620 long time = System.currentTimeMillis() + 1000;
621 time = time - ( time % 1000 );
622 copiedFile.setLastModified( time );
623 Thread.sleep( 100 );
624
625 mojo.execute();
626
627 assertEquals( time, copiedFile.lastModified() );
628 }
629
630 public void testCopyDontOverWriteSnapshots()
631 throws Exception
632 {
633 stubFactory.setCreateFiles( true );
634 Artifact artifact = stubFactory.getSnapshotArtifact();
635 assertTrue( artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 ) );
636
637 ArtifactItem item = new ArtifactItem( artifact );
638
639 List<ArtifactItem> list = new ArrayList<>( 1 );
640 list.add( item );
641 mojo.setArtifactItems( list );
642
643 mojo.setOverWriteIfNewer( false );
644
645 mojo.execute();
646
647 File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
648
649 Thread.sleep( 100 );
650
651 long time = System.currentTimeMillis() + 1000;
652 time = time - ( time % 1000 );
653 assertTrue( copiedFile.setLastModified( time ) );
654 Thread.sleep( 100 );
655
656 mojo.execute();
657
658 assertEquals( time, copiedFile.lastModified() );
659 }
660
661 public void testCopyOverWriteReleases()
662 throws Exception
663 {
664 stubFactory.setCreateFiles( true );
665 Artifact release = stubFactory.getReleaseArtifact();
666 assertTrue( release.getFile().setLastModified( 1000L ) );
667 assertEquals( 1000L, release.getFile().lastModified() );
668
669 ArtifactItem item = new ArtifactItem( release );
670
671 List<ArtifactItem> list = new ArrayList<>( 1 );
672 list.add( item );
673 mojo.setArtifactItems( list );
674
675 mojo.setOverWriteIfNewer( false );
676 mojo.setOverWriteReleases( true );
677 mojo.execute();
678
679 File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
680
681 assertTrue( copiedFile.setLastModified( 2000L ) );
682 assertEquals( 2000L, copiedFile.lastModified() );
683
684 mojo.execute();
685
686 long timeCopyNow = copiedFile.lastModified();
687 assertEquals( 1000L, timeCopyNow );
688 }
689
690 public void testCopyOverWriteSnapshot()
691 throws Exception
692 {
693 stubFactory.setCreateFiles( true );
694 Artifact artifact = stubFactory.getSnapshotArtifact();
695 assertTrue( artifact.getFile().setLastModified( 1000L ) );
696 assertEquals( 1000L, artifact.getFile().lastModified() );
697
698 ArtifactItem item = new ArtifactItem( artifact );
699
700 List<ArtifactItem> list = new ArrayList<>( 1 );
701 list.add( item );
702 mojo.setArtifactItems( list );
703
704 mojo.setOverWriteIfNewer( false );
705 mojo.setOverWriteReleases( false );
706 mojo.setOverWriteSnapshots( true );
707 mojo.execute();
708
709 File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
710
711 assertTrue( copiedFile.setLastModified( 2000L ) );
712 assertEquals( 2000L, copiedFile.lastModified() );
713
714 mojo.execute();
715
716 long timeCopyNow = copiedFile.lastModified();
717 assertEquals( 1000L, timeCopyNow );
718 }
719
720 public void testCopyOverWriteIfNewer()
721 throws Exception
722 {
723 stubFactory.setCreateFiles( true );
724 Artifact artifact = stubFactory.getSnapshotArtifact();
725 assertTrue( artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 ) );
726
727 ArtifactItem item = new ArtifactItem( artifact );
728
729 List<ArtifactItem> list = new ArrayList<>( 1 );
730 list.add( item );
731 mojo.setArtifactItems( list );
732 mojo.setOverWriteIfNewer( true );
733 mojo.execute();
734
735 File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
736
737
738 long time = System.currentTimeMillis() - 10000;
739 time = time - ( time % 1000 );
740 assertTrue( copiedFile.setLastModified( time ) );
741
742
743 assertTrue( artifact.getFile().setLastModified( time + 4000 ) );
744 mojo.execute();
745
746 assertTrue( time < copiedFile.lastModified() );
747 }
748
749 public void testCopyFileWithOverideLocalRepo()
750 throws Exception
751 {
752 final File localRepo = stubFactory.getWorkingDir();
753
754 List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
755
756 mojo.setArtifactItems( list );
757
758 File execLocalRepo = new File( this.testDir.getAbsolutePath(), "executionLocalRepo" );
759 assertFalse( execLocalRepo.exists() );
760
761 stubFactory.setWorkingDir( execLocalRepo );
762 createArtifactItemArtifacts( list );
763
764 assertFalse( "default local repo should not exist", localRepo.exists() );
765
766 mojo.setLocalRepositoryDirectory( execLocalRepo );
767
768 mojo.execute();
769
770 assertFilesExist( list, true );
771
772 }
773
774 private List<Dependency> createDependencyArtifacts( List<Dependency> items )
775 throws IOException
776 {
777 stubFactory.setCreateFiles( true );
778 for ( Dependency item : items )
779 {
780 String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier();
781 stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(),
782 VersionRange.createFromVersion( item.getVersion() ), null, item.getType(),
783 classifier, item.isOptional() );
784 }
785 return items;
786 }
787
788 private List<ArtifactItem> createArtifactItemArtifacts( List<ArtifactItem> items )
789 throws IOException
790 {
791 for ( ArtifactItem item : items )
792 {
793 createArtifact( item );
794 }
795 return items;
796 }
797
798 private ArtifactItem createArtifact( ArtifactItem item )
799 throws IOException
800 {
801 stubFactory.setCreateFiles( true );
802
803 String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier();
804 String version = item.getVersion() != null ? item.getVersion() : item.getBaseVersion();
805 stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), version, null, item.getType(),
806 classifier );
807 return item;
808 }
809 }