1 package org.apache.maven.plugin.coreit;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.artifact.installer.ArtifactInstaller;
24 import org.apache.maven.plugin.MojoExecutionException;
25
26 import java.util.Iterator;
27
28
29
30
31
32
33
34
35
36
37 public class InstallMojo
38 extends AbstractRepoMojo
39 {
40
41
42
43
44
45
46 private ArtifactInstaller installer;
47
48
49
50
51
52
53 public void execute()
54 throws MojoExecutionException
55 {
56 getLog().info( "[MAVEN-CORE-IT-LOG] Installing project artifacts" );
57
58 try
59 {
60 if ( isPomArtifact() )
61 {
62 installer.install( pomFile, mainArtifact, localRepository );
63 }
64 else
65 {
66 installer.install( mainArtifact.getFile(), mainArtifact, localRepository );
67 }
68
69 if ( attachedArtifacts != null )
70 {
71 for ( Iterator it = attachedArtifacts.iterator(); it.hasNext(); )
72 {
73 Artifact attachedArtifact = (Artifact) it.next();
74 installer.install( attachedArtifact.getFile(), attachedArtifact, localRepository );
75 }
76 }
77 }
78 catch ( Exception e )
79 {
80 throw new MojoExecutionException( "Failed to install artifacts", e );
81 }
82 }
83
84 }