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