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