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.deployer.ArtifactDeployer;
24 import org.apache.maven.artifact.factory.ArtifactFactory;
25 import org.apache.maven.artifact.repository.ArtifactRepository;
26 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
27 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
28 import org.apache.maven.plugin.AbstractMojo;
29 import org.apache.maven.plugin.MojoExecutionException;
30 import org.apache.maven.plugin.MojoFailureException;
31
32 import java.io.File;
33
34
35
36
37
38
39
40
41
42
43 public class DeployFileMojo
44 extends AbstractMojo
45 {
46
47
48
49
50
51
52 private File file;
53
54
55
56
57
58
59 private String groupId;
60
61
62
63
64
65
66 private String artifactId;
67
68
69
70
71
72
73 private String version;
74
75
76
77
78
79
80 private String repositoryUrl;
81
82
83
84
85
86
87 private String repositoryId;
88
89
90
91
92
93
94 private ArtifactRepositoryFactory repositoryFactory;
95
96
97
98
99
100
101 private ArtifactRepositoryLayout repositoryLayout;
102
103
104
105
106
107
108 private ArtifactFactory artifactFactory;
109
110
111
112
113
114
115 private ArtifactDeployer deployer;
116
117
118
119
120
121
122
123
124 private ArtifactRepository localRepository;
125
126
127
128
129
130
131 public void execute()
132 throws MojoExecutionException, MojoFailureException
133 {
134 getLog().info( "[MAVEN-CORE-IT-LOG] Deploying artifacts" );
135
136 try
137 {
138 ArtifactRepository repository =
139 repositoryFactory.createDeploymentArtifactRepository( repositoryId, repositoryUrl, repositoryLayout,
140 true );
141
142 Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, "jar" );
143
144 deployer.deploy( file, artifact, repository, localRepository );
145 }
146 catch ( Exception e )
147 {
148 throw new MojoExecutionException( "Failed to deploy artifacts: " + e.getMessage(), e );
149 }
150 }
151
152 }