1 package org.apache.maven.plugins.release;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Arrays;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.shared.release.ReleaseExecutionException;
29 import org.apache.maven.shared.release.ReleaseFailureException;
30 import org.apache.maven.shared.release.config.ReleaseDescriptor;
31 import org.apache.maven.shared.release.config.ReleaseUtils;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 @Mojo( name = "prepare", aggregator = true )
48 public class PrepareReleaseMojo
49 extends AbstractScmReleaseMojo
50 {
51
52
53
54
55 @Parameter( defaultValue = "true", property = "resume" )
56 private boolean resume;
57
58
59
60
61 @Parameter( defaultValue = "false", property = "generateReleasePoms" )
62 private boolean generateReleasePoms;
63
64
65
66
67 @Parameter( defaultValue = "false", property = "useEditMode" )
68 private boolean useEditMode;
69
70
71
72
73
74
75 @Parameter( defaultValue = "true", property = "updateDependencies" )
76 private boolean updateDependencies;
77
78
79
80
81
82
83
84 @Parameter( defaultValue = "false", property = "autoVersionSubmodules" )
85 private boolean autoVersionSubmodules;
86
87
88
89
90
91
92
93 @Parameter( defaultValue = "false", property = "dryRun" )
94 private boolean dryRun;
95
96
97
98
99 @Parameter( defaultValue = "true", property = "addSchema" )
100 private boolean addSchema;
101
102
103
104
105 @Parameter( defaultValue = "clean verify", property = "preparationGoals" )
106 private String preparationGoals;
107
108
109
110
111
112
113
114 @Parameter( defaultValue = "", property = "completionGoals" )
115 private String completionGoals;
116
117
118
119
120
121
122 @Parameter( defaultValue = "false", property = "commitByProject" )
123 private boolean commitByProject;
124
125
126
127
128
129
130 @Parameter( defaultValue = "false", property = "ignoreSnapshots" )
131 private boolean allowTimestampedSnapshots;
132
133
134
135
136
137
138
139 @Parameter( defaultValue = "false", property = "allowReleasePluginSnapshot", readonly = true )
140 private boolean allowReleasePluginSnapshot;
141
142
143
144
145
146
147
148 @Parameter
149 private String[] checkModificationExcludes;
150
151
152
153
154
155
156 @Parameter( property = "checkModificationExcludeList" )
157 private String checkModificationExcludeList;
158
159
160
161
162
163
164 @Parameter( property = "releaseVersion" )
165 private String releaseVersion;
166
167
168
169
170
171
172 @Parameter( property = "developmentVersion" )
173 private String developmentVersion;
174
175
176
177
178
179
180
181
182
183
184
185
186 @Parameter( defaultValue = "true", property = "remoteTagging" )
187 private boolean remoteTagging;
188
189
190
191
192
193
194 @Parameter( defaultValue = "true", property = "updateWorkingCopyVersions" )
195 private boolean updateWorkingCopyVersions;
196
197
198
199
200
201
202
203
204
205
206
207 @Parameter( defaultValue = "false", property = "suppressCommitBeforeTag" )
208 private boolean suppressCommitBeforeTag;
209
210
211
212
213
214
215
216
217 @Parameter( defaultValue = "0", property = "waitBeforeTagging" )
218 private int waitBeforeTagging;
219
220
221
222
223
224
225 @Parameter( defaultValue = "default", property = "projectVersionPolicyId" )
226 private String projectVersionPolicyId;
227
228
229
230
231 public void execute()
232 throws MojoExecutionException, MojoFailureException
233 {
234 if ( generateReleasePoms )
235 {
236 throw new MojoFailureException( "Generating release POMs is no longer supported in release:prepare. "
237 + "Please run release:prepare-with-pom instead." );
238 }
239
240 prepareRelease( generateReleasePoms );
241 }
242
243 protected void prepareRelease( boolean generateReleasePoms )
244 throws MojoExecutionException, MojoFailureException
245 {
246
247
248 super.execute();
249
250 ReleaseDescriptor config = createReleaseDescriptor();
251 config.setAddSchema( addSchema );
252 config.setGenerateReleasePoms( generateReleasePoms );
253 config.setScmUseEditMode( useEditMode );
254 config.setPreparationGoals( preparationGoals );
255 config.setCompletionGoals( completionGoals );
256 config.setCommitByProject( commitByProject );
257 config.setUpdateDependencies( updateDependencies );
258 config.setAutoVersionSubmodules( autoVersionSubmodules );
259 config.setAllowTimestampedSnapshots( allowTimestampedSnapshots );
260 config.setSnapshotReleasePluginAllowed( allowReleasePluginSnapshot );
261 config.setDefaultReleaseVersion( releaseVersion );
262 config.setDefaultDevelopmentVersion( developmentVersion );
263 config.setRemoteTagging( remoteTagging );
264 config.setUpdateWorkingCopyVersions( updateWorkingCopyVersions );
265 config.setSuppressCommitBeforeTagOrBranch( suppressCommitBeforeTag );
266 config.setWaitBeforeTagging( waitBeforeTagging );
267 config.setProjectVersionPolicyId( projectVersionPolicyId );
268
269 if ( checkModificationExcludeList != null )
270 {
271 checkModificationExcludes = checkModificationExcludeList.replaceAll( "\\s", "" ).split( "," );
272 }
273
274 if ( checkModificationExcludes != null )
275 {
276 config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
277 }
278
279
280 ReleaseDescriptor sysPropertiesConfig =
281 ReleaseUtils.copyPropertiesToReleaseDescriptor( session.getExecutionProperties() );
282 mergeCommandLineConfig( config, sysPropertiesConfig );
283
284 try
285 {
286 releaseManager.prepare( config, getReleaseEnvironment(), getReactorProjects(), resume, dryRun );
287 }
288 catch ( ReleaseExecutionException e )
289 {
290 throw new MojoExecutionException( e.getMessage(), e );
291 }
292 catch ( ReleaseFailureException e )
293 {
294 throw new MojoFailureException( e.getMessage(), e );
295 }
296 }
297
298 }