1 package org.apache.maven.plugin.deploy;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Map;
23
24 import org.apache.maven.artifact.deployer.ArtifactDeployer;
25 import org.apache.maven.artifact.factory.ArtifactFactory;
26 import org.apache.maven.artifact.repository.ArtifactRepository;
27 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
28 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
29 import org.apache.maven.plugin.AbstractMojo;
30 import org.apache.maven.plugin.MojoExecutionException;
31 import org.apache.maven.plugin.MojoFailureException;
32
33
34
35
36 public abstract class AbstractDeployMojo
37 extends AbstractMojo
38 {
39
40
41
42 private ArtifactDeployer deployer;
43
44
45
46
47
48
49 protected ArtifactFactory artifactFactory;
50
51
52
53
54
55
56 ArtifactRepositoryFactory repositoryFactory;
57
58
59
60
61
62
63 private Map repositoryLayouts;
64
65
66
67
68
69
70 private ArtifactRepository localRepository;
71
72
73
74
75
76
77
78 private boolean offline;
79
80
81
82
83
84
85 protected boolean updateReleaseInfo;
86
87
88
89 public ArtifactDeployer getDeployer()
90 {
91 return deployer;
92 }
93
94 public void setDeployer( ArtifactDeployer deployer )
95 {
96 this.deployer = deployer;
97 }
98
99 public ArtifactRepository getLocalRepository()
100 {
101 return localRepository;
102 }
103
104 public void setLocalRepository( ArtifactRepository localRepository )
105 {
106 this.localRepository = localRepository;
107 }
108
109 void failIfOffline()
110 throws MojoFailureException
111 {
112 if ( offline )
113 {
114 throw new MojoFailureException( "Cannot deploy artifacts when Maven is in offline mode" );
115 }
116 }
117
118 ArtifactRepositoryLayout getLayout( String id )
119 throws MojoExecutionException
120 {
121 ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( id );
122
123 if ( layout == null )
124 {
125 throw new MojoExecutionException( "Invalid repository layout: " + id );
126 }
127
128 return layout;
129 }
130
131 }