1 package org.kuali.maven.mojo.s3;
2
3 import org.apache.maven.execution.MavenSession;
4 import org.apache.maven.plugin.AbstractMojo;
5 import org.apache.maven.plugin.MojoExecutionException;
6 import org.apache.maven.plugin.MojoFailureException;
7 import org.apache.maven.project.MavenProject;
8 import org.apache.maven.settings.Settings;
9
10
11
12
13
14
15 public abstract class BaseMojo extends AbstractMojo {
16
17
18
19
20 public static final String FS = System.getProperty("file.separator");
21
22
23
24
25 public static final String SKIP_PACKAGING_TYPE = "pom";
26
27
28
29
30
31
32 private boolean skip;
33
34
35
36
37
38
39
40
41 private boolean forceMojoExecution;
42
43
44
45
46
47
48
49 private String encoding;
50
51
52
53
54
55
56
57
58 private MavenProject project;
59
60
61
62
63
64
65
66 private Settings settings;
67
68
69
70
71
72
73 private MavenSession mavenSession;
74
75 public void execute() throws MojoExecutionException, MojoFailureException {
76 if (skipMojo()) {
77 return;
78 }
79 executeMojo();
80 }
81
82
83
84
85
86
87
88 protected abstract void executeMojo() throws MojoExecutionException, MojoFailureException;
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 protected boolean skipMojo() {
104 if (skip) {
105 getLog().info("Skipping execution");
106 return true;
107 }
108
109 if (!forceMojoExecution && project != null && SKIP_PACKAGING_TYPE.equals(project.getPackaging())) {
110 getLog().info("Skipping execution for project with packaging type '" + SKIP_PACKAGING_TYPE + "'");
111 return true;
112 }
113
114 return false;
115 }
116
117
118
119
120 public boolean isSkip() {
121 return skip;
122 }
123
124
125
126
127
128 public void setSkip(final boolean skip) {
129 this.skip = skip;
130 }
131
132
133
134
135 public boolean isForceMojoExecution() {
136 return forceMojoExecution;
137 }
138
139
140
141
142
143 public void setForceMojoExecution(final boolean forceMojoExecution) {
144 this.forceMojoExecution = forceMojoExecution;
145 }
146
147
148
149
150 public String getEncoding() {
151 return encoding;
152 }
153
154
155
156
157
158 public void setEncoding(final String encoding) {
159 this.encoding = encoding;
160 }
161
162
163
164
165 public MavenProject getProject() {
166 return project;
167 }
168
169
170
171
172
173 public void setProject(final MavenProject project) {
174 this.project = project;
175 }
176
177
178
179
180 public Settings getSettings() {
181 return settings;
182 }
183
184
185
186
187
188 public void setSettings(final Settings settings) {
189 this.settings = settings;
190 }
191
192
193
194
195 public MavenSession getMavenSession() {
196 return mavenSession;
197 }
198
199
200
201
202
203 public void setMavenSession(final MavenSession mavenSession) {
204 this.mavenSession = mavenSession;
205 }
206
207 }